0

I have a fixed effect with three levels and I used the following contrasts that created 2 columns in my data set

 data = data %>%
  mutate(contrast_B = ifelse(group == "A", -0.5,
                               ifelse(type == "B", 0.5, 0))) %>%
  mutate(contrast_C = ifelse(group == "A", -0.5,
                              ifelse(type == "C", 0.5, 0)))

I included them in my model along with other fixed effects which all are binary with two levels as follows.

model <-lmer(log(dependent variable) ~ contrast_B * contrast_C * 
   fixed effect * fixed effect * fixed effect + 
   (1|subject)+ (1|item), data = data....

But I got a message

fixed-effect model matrix is rank deficient so dropping 12 columns/coefficients"

Does anybody know how to fix it?

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
Aroma
  • 1
  • 1
  • 1
    Are you sure you want the full five-way interaction and not an additive model? (i.e. `contrast_B + constrast_C + fe1 + fe2 + ...`) In any case, I'm pretty sure that you want to use `+` and not `*` to combine the contrast components. Furthermore, it's generally best to put your categorical variable `group` directly into the model, specify the contrasts you want, and let R do the work of putting it all together ... – Ben Bolker Feb 06 '22 at 01:31
  • The error likely comes from having a mismatch of levels. For example, if you have two groups, where the first through has three levels and the second group has three levels, like A, B, C, and a, b, c -- you need to have observations where these groups cross A-a A-b A-c B-a B-b B-c C-a C-b C-c and so on. If you don't have all of the groups interweaving it's going to cause this type of problem. If you want the grouping to be purposeful, you need multiple observations in each, as well. – Kat Feb 06 '22 at 13:46
  • @BenBolker Thank you very much for your response. Yes I think you're right, it needs to be an additive model, the interaction between the two contrast components doesn't even make sense. However, I still get the same warning message, but this time dropping fewer columns/coefficents.Even by including (group) directly into the model (though not sure how to specify/code the contrasts in a way other than what I did), I still get the same warning message.The only model I run and I don't get a warning message is when I only include contrast B alone with its interaction with the other fixed effects- – Aroma Feb 08 '22 at 00:40
  • @BenBolker- and then include contrast C in another model with the other fixed effects and their interactions. But this is not really what I want. I want to see how the three groups differ across the other fixed effects (i.e. e.g. which group is affected more by fixed-effect 1 or by the interaction between fixed-effect 1 and fixed-effect 2). – Aroma Feb 08 '22 at 00:42
  • @Kat Thank you very much for your response. I'm not 100% sure I got what you mean. My fixed effects in terms of levels are 3*2*2*2, and I have observations with those effects' levels interweave with each other. I'm not an expert in R, but I was thinking if having/coding the reference level in both contrast B and contrast C could cause any problem? – Aroma Feb 08 '22 at 00:58
  • could we please have a [mcve]? – Ben Bolker Feb 08 '22 at 01:02
  • that is not a reproducible example; we would need data as well. Take a look at https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example for some tips on creating a reproducible example ... – Ben Bolker Feb 08 '22 at 01:28

0 Answers0