I am dealing with multiple measurements of the same variable in different subject in three geographical areas. Unfortunately, the number of measurements of the variable differs among subjects. My data set looks like this:

#A   Z13.1  4.5
#A   Z13.1  5.7
#A   Z13.1  7.6
#A   Z15.2  5.1
#A   Z15.2  3.9
#B   T15.3  2.1
#B   T15.3  9.1
#B   T20.6  1.1
#B   T20.6  3.2
#B   T20.6  4.3

In my opinion, the best option for analysing such a data set would be a mixed model ANOVA, in order to take into account the variability within each area (random variability among subjects from the same area, the random factor) and the variability between areas (the fixed factor, the area). After checking the normality of the data set and the homogeneity of the variance, as far as I understood the proper mixed model would be the following (using afex and lsmeans in R):

model1 <-  lmer(VARIABLE ~ AREA + (1|AREA/ID), data= my_data)
ref <- lsmeans(model1, specs = c("AREA"))
ref_df <- as.data.frame(summary(ref))
pd <- position_dodge(0.1)
g4 <- ggplot(ref_df, aes(x=AREA, y=lsmean))+
  geom_errorbar(aes(ymin=lsmean-SE, ymax=lsmean+SE), width=.1,position=pd)+

If I got it right the Subject (random factor) is nested in Area (fixed factor). Of note when I run such analysis I get this warning:

Model may not have converged with 1 eigenvalue close to zero: 5.0e-09

  • Am I right with the mixed model? Are the factors placed properly?
  • What about the warning I received?
  • Do you have any suggestions ?
  • $\begingroup$ it doesn't make sense to include AREA as both a fixed effect and a random effect ... $\endgroup$
    – Ben Bolker
    Dec 29, 2018 at 14:47
  • $\begingroup$ So @BenBolker is lmer(VARIABLE ~ AREA + (1 | ID), data = my_data) correct? $\endgroup$
    – Luca
    Dec 29, 2018 at 15:24

1 Answer 1


A few comments:

  • After checking the normality of the dataset and the homogeneity of the variance

You should check normality and homogeneity of the residuals, not the marginal distribution of the response variable ...

  • your model seems correct, except that you should use VARIABLE ~ AREA + (1|ID): you shouldn't include the same variable as both a fixed and a random effect (except in some special cases); in any cases, three areas would probably not be enough to practically fit a random effect in any case (without regularization/Bayesian priors), and wouldn't allow you test differences among specific areas (as in your post-hoc pairwise comparisons).

  • you might want to move from lsmeans to emmeans (almost identical, but slightly more up-to-date); I'd also recommend Tukey rather than Bonferroni adjustment unless you have particular reasons ...


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.