0

I have done an lmer with a random factor and two fixed factors in R, all orthogonal.

Levels of factors:

  • fixed.factor.1 = 3
  • fixed.factor.2 = 2
  • random.factor = 2
  • Replicates per group = 3
model <- lmer(response.var~fixed.factor.1*fixed.factor.2+
         (1|random.factor),data=df)
summary(model)        
Anova(model,type = 3,test='F')

R warns me about a singularity and the summary of the model shows that the variance associated with the random factor is 0, so the influence of such factor is null. The output of a linear model without random factor gives exactly the same estimates, and does not give warnings. Can it be possible that the variance of the random factor is completely zero, or am I doing something wrong? Can it be that R rounds the variance to 5 decimals, but that the variance is actually not 0?

kjetil b halvorsen
  • 63,378
  • 26
  • 142
  • 467
  • It sounds like your model is overspecified. Please show your model code and describe your data (including information like how many observations per group). – Gregor Thomas Feb 09 '22 at 17:55
  • I have edited the question and added the information @Gregor Thomas –  Feb 09 '22 at 19:00
  • Does your random grouping variable really only have two levels? If so, I'd suggest plugging it in as a fixed effect (ps did you omit an opening bracket e.g. intend `(1|random.factor)` ) – user20650 Feb 09 '22 at 19:28
  • The factor is completely random and cannot be defined as fixed –  Feb 10 '22 at 10:03
  • 2
    Does this answer your question? [Why do I get zero variance of a random effect in my mixed model, despite some variation in the data?](https://stats.stackexchange.com/questions/115090/why-do-i-get-zero-variance-of-a-random-effect-in-my-mixed-model-despite-some-va) Also, see [this thread](https://stats.stackexchange.com/q/37647/28500) and its links for discussion about random effects having few levels. – EdM Feb 10 '22 at 19:19
  • @EdM that was helpful, thanks. I see that the issue lies in the way of calculating the variance of the lmer function. However, although a random factor with two levels may not be practical to fit in a linear mixed model, I cannot omit it from the analysis because it is inherent to the design of the experiment. – Marta Román Feb 11 '22 at 09:11
  • Thanks for your help. I have tried with the function lme from the package nlme and it is working well. The function is calculating the variance of the random effects. – Marta Román Feb 12 '22 at 09:24

0 Answers0