I run a Linear Mixed-Effects Models (LMMs) with a repeated measures design with the lmer function on R.

    mod <- lmer(response ~ factor1*factor2 + (1|ID_repeated), 

What covariance structure is implemented on the lmer function and how I can change it, in case?

I couldn't find any information about that!


1 Answer 1


The model as you have written it for lmer() only allows for a Gaussian distribution of the random intercept terms among the individuals, that is, the estimated response when both factor1 and factor2 are at their reference levels (under standard treatment coding).

The lme() function allows for more detailed specification of covariance structure. This page is a useful guide to how these two functions can be called to model the same experimental designs, and for how lme() can be invoked to specify covariance structure.

  • $\begingroup$ Thank you so much for your comment and suggestions! $\endgroup$
    – Alice
    Commented Aug 16, 2020 at 16:23
  • $\begingroup$ Maybe I applied the wrong function and missed something in the model. Could you please specify what you mean with "when both factor1 and factor2 are at their reference levels (under standard treatment coding)"? My factors are two categorical variables of space and time. Factor 1 has 2 levels (site 1 - site 2) and factor 2 has 4 levels (4 different days). My ID are the replicates. Thanks in advance! $\endgroup$
    – Alice
    Commented Aug 16, 2020 at 16:28
  • $\begingroup$ @Alice the default in R (unlike some other software) is to take the lowest level of a categorical predictor as the reference. So if site1 is the reference level for factor1 and say day0 is the reference level for days, the random intercepts will be the estimated values of response if an individual had been at site1 on day0. Those are values estimated by the model; an individual doesn't need to have been at site1 on day0 to have such an estimate made. With your model, all effects of site2, other days, and the interactions will be the same for all individuals. $\endgroup$
    – EdM
    Commented Aug 16, 2020 at 17:28
  • $\begingroup$ Thanks again for this explanation and thanks for your patience. I'm a newbie both with R and these models. May I ask you another question? How would you modify then the model if you wanted to see the effects of factor 1 (site), factor 2 (time), and their interactions on the response variable? (always with ID as a replicate). If it would take too long to answer, no problem, thanks anyway! $\endgroup$
    – Alice
    Commented Aug 16, 2020 at 19:46
  • 1
    $\begingroup$ Random slopes can generate some interesting correlation patterns but I prefer to use serial correlation models most of the time, e.g., generalized least squares or Markov models. $\endgroup$ Commented Oct 13, 2021 at 12:42

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.