Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Same factor levels in different attributes #13

Open
chriswratil opened this Issue Feb 5, 2019 · 3 comments

Comments

Projects
None yet
3 participants
@chriswratil
Copy link

chriswratil commented Feb 5, 2019

Hi Thomas,
I encountered a small problem with cj(): in case you have two levels across any attributes that have the same name, cj() will not work. While there are tweaks around this (of course), it is not very convenient. In my example, we simply have a candidate experiment in which the attributes are priorities and the attribute levels are whether the candidates have or not have these priorities. Hence, the attribute levels are "Is a priority" vs. "Is not a priority" and this is repeated for several attributes.
Could potentially be fixed.
Thanks so much for providing this great package!
Chris

@leeper leeper added the bug label Feb 5, 2019

@leeper

This comment has been minimized.

Copy link
Owner

leeper commented Feb 5, 2019

Thanks - this has been on the back of mind for a while, so glad you brought it up. The hacky solution is to change the factor levels to something like "Feature: Level" rather than "Level" but this should be fixed so you don't have to do that!

@m-jankowski

This comment has been minimized.

Copy link

m-jankowski commented Feb 14, 2019

This is also a problem when using mm_diffs().

In my case, I wanted to conduct a subgroup analysis conditional on the gender of the respondents (labeled as "Male" or "Female"). The conjoint experiment, however, also contained levels with these labels ("Male" and "Female"). Particularly problematic is that mm_diffs() did not throw an error message, but returned wrong estimates without any warnings.

Here is an artificial example using the immigration data:

Data

data("immigration")

Create subgroups

immigration$ethnosplit <- cut(immigration$ethnocentrism, 2)

Rename subgroup levels

immigration$subgroup <- as.factor(ifelse(as.numeric(immigration$ethnosplit) == 1,
"Male",
"Female"))

Estimate correct MMs by subgroup

mm_correct <- cj(na.omit(immigration),
ChosenImmigrant ~ Gender + Education + LanguageSkills,
estimate = "mm",
id = ~ CaseID,
by = ~ ethnosplit)

plot(mm_correct,
group = "ethnosplit",
vline = 0.5)

image

Differences between subgroups

mmdiff_correct <- mm_diffs(na.omit(immigration),
ChosenImmigrant ~ Gender + Education + LanguageSkills,
id = ~ CaseID,
by = ~ ethnosplit)

plot(mmdiff_correct)

image

Using subgroups with identical level names returns wrong estimates

mmdiff_problem <- mm_diffs(na.omit(immigration),
ChosenImmigrant ~ Gender + Education + LanguageSkills,
id = ~ CaseID,
by = ~ subgroup)

plot(mmdiff_problem)

image

@leeper

This comment has been minimized.

Copy link
Owner

leeper commented Mar 15, 2019

Okay, that's definitely bad but actually a separate issue. @m-jankowski I'm going to move your comment to a new issue to keep track of things: #22

The issue here remains simply that things get wonky when multiple features have the same factor levels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.