# Interaction between fixed and random factors in mixed model

I am running an experiment with 3 different factors arranged in a factorial arrangement 3x3x3 (randomized complete block design with 4 blocks). These experimental plots are also replicated spatially and temporally across 3 locations, and 3 years. Thus, there is a total of 9 siteyears (3 locations x 3 years) representing different growth environments. In order to study the effects of three fixed factors on response variable, I am using the mixed model below –

mixed.model <- lmer(rv ~ f1 + f2 + f3 + f1:f2 + f2:f3 + f3:f1 + (1|siteyear/block), data)


However, my supervisor asked if the effect of factors on response variable changes in different siteyears i.e. if there is an interaction between siteyears and factors (f1, f2, f3). I ran a simple linear model with siteyear as fixed factor (given below) to check for the interaction and found significant interaction of f1 and f2 with siteyear.

l.model <- lm (rv ~ f1 + f2 + f3 + f1:f2 + f2:f3 + f3:f1 + siteyear + siteyear:f1 + siteyear:f2 + siteyear:f3, data)


My main question is that is the mixed model still valid in the presence of interaction of fixed effect with random effect (siteyear)? My understanding is that, by including siteyear as random effect, the interaction is accounted for as well. Is that true, and can you please provide an explanation of how it happens? I am also wondering if there is information on such interaction in the output of mixed model, and that lm model was not required to check interaction. Thank you!

My understanding is that, by including siteyear as random effect, the interaction is accounted for as well

I don't think this is correct. The random effects (1|siteyear/block) will account for interactions between siteyear and block but not between siteyear and the fixed factors.

Since you seem to have interest in the estimates for the interaction between siteyear and the fixed factors, I would not include siteyear as a grouping variable for random intercepts. Further, since you have only 4 blocks, this is insuficient for fitting random interecepts so I would include block as a fixed effect as well, ie, the second model, but with block as a fixed effect too. If you believe there is additional variation in the response due to the siteyear:block interaction, you might also consider a mixed model with that interaction as a grouping factor:

rv ~ f1 + f2 + f3 + f1:f2 + f2:f3 + f3:f1 + siteyear + siteyear:f1 + siteyear:f2 + siteyear:f3 + (1|siteyear:block)

• Thank you for your answer! I guess I am not interested in the estimation of interaction between siteyear and fixed factors, but mindful of their presence. So I guess my question is that, knowing that those interactions are present and significant in my data, does that invalidate the output of my mixed model or not? ie. in the presence of significant interactions between fixed factors and siteyear, are the estimates of F (and p) values for fixed factors by mixed.model still ok, or do I need to change the random effect structure or something else?
– gsd
Oct 4, 2020 at 15:04
• I am not interested in the estimation of interaction between siteyear and fixed factors, but worried that their presence invalidates the mixed.model listed above in the question? Is that correct, and if yes, what changes can I make in it? Thank you once again for your help!
– gsd
Oct 4, 2020 at 15:07
• Yes, if there are moderating effects (ie interactions) and you are not incorporating them into your model in some way, then the model will be deficient. Whether or not it is "invalid" will depend on how strong these interactions are and whether you can safely ignore them. So I would recommend including them as fixed effects as in your second model (but with block included), and if the inferences that you are interested in are very much the same as the mixed model, then you can go back to the mixed model, since that is more parsimonious and will have more statistical power. Oct 4, 2020 at 15:15
• Ok. Since I am not interested in the main effect of siteyear (it is almost always going to be significant and is not interesting wrt the study), is the following approach alright as well? (in order to keep the model parsimonious and with higher statisitcal power) mm2 <- lmer(rv ~ f1 + f2 + f3 + f1:f2 + f2:f3 + f3:f1 + f1:siteyear + f2:siteyear + f3:siteyear + (1|siteyear/block), data)
– gsd
Oct 4, 2020 at 17:38
• I am sorry for too many questions, but interaction b/w fixed effects and a random effect is completely new territory for me. Thanks for your patience!
– gsd
Oct 4, 2020 at 17:39