Skip to content
Prev 20390 / 20628 Next

lmer error: number of observations <= number of random effects

if I understood the design correctly.

Index is a wihtin subject factor (the same participant tested at 3 different ages), while LSI is instead a numerical predictor.

If the above is correct, 
AND
If you assume the LSI will affect similarly across ages, then I would try the following:
mdl<-lmer(SA ~ Index1*LSI+ (1+LSI | ID)+(1 | ID:Index1),data = LSIDATA, control 
lmerControl(optimizer ="bobyqa"), REML=TRUE)]. 
car::Anova(mdl, type 3, test F)

If you assume the LSI will affect differently across ages, then I would try the following:
mdl<-lmer(SA ~ Index1*LSI+ (1 | ID)+(1 +LSI | ID:Index1),data = LSIDATA, control 
lmerControl(optimizer ="bobyqa"), REML=TRUE)]. 
car::Anova(mdl, type 3, test F)


However, 
if Index1 is a between subjects factor (i.e, each ID has one age only). Then, I would keep Index1 as numerical predictor (given that is also equally spaced) and run
mdl<-lmer(SA ~ Index1*LSI+ (1 +Index1:LSI | ID)),data = LSIDATA, control 
lmerControl(optimizer ="bobyqa"), REML=TRUE)]. 
car::Anova(mdl, type 3, test F)

The latter is based on (https://doi.org/10.3389/fpsyg.2013.00328 <https://doi.org/10.3389/fpsyg.2013.00328>) that suggests to keep the highest interaction. 

if you want to keep the age as between subjects factor (i.e, not a numerical predictor), then I would run
mdl<-lmer(SA ~ Index1*LSI+ (1+LSI | ID)),data = LSIDATA, control 
lmerControl(optimizer ="bobyqa"), REML=TRUE)]. 
car::Anova(mdl, type 3, test F)

But I would not make model comparisions by altering the random effect strcuture to see if LSI and Index has a different contribution. I would achieve that goal with a single model and by keeping them always in the fixed part of the LMM.


I hope this makes sense.

Best