cregg icon indicating copy to clipboard operation
cregg copied to clipboard

Same factor levels in different attributes

Open chriswratil opened this issue 6 years ago • 3 comments

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

chriswratil avatar Feb 05 '19 19:02 chriswratil

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!

leeper avatar Feb 05 '19 20:02 leeper

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

m-jankowski avatar Feb 14 '19 10:02 m-jankowski

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: https://github.com/leeper/cregg/issues/22

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

leeper avatar Mar 15 '19 10:03 leeper