I am trying to understand how the linear mixed models output from the lmer function maps to the statistical notation for these models.

Lets assume to have a categorical (with 3 levels) fixed effect, a continuous fixed effects, the interaction between them and a random effect for the individual.

This is the equation i am used to see for linear mixed models, although i know there is also a matrix notation:

$y_{ij} = \beta_0 + \beta _1 CATG_{ij} + \beta _2 CONT_{ij} + \beta _3 CATG\cdot CONT_{ij} + b_i+\epsilon_{ij}$

The output of lmer would give me estimates for the following:


I do understand what they mean, just can't map it to the equation as it seems that the categorical covariate is encoded in dummy variables both for the intercept and for the slope.

Any thoughts?

  • $\begingroup$ The equation as written doesn't include the interaction term between the categorical and continuous effects. Think some about how to write an equation including the interaction. Note that the default in R is to report coefficients for the reference level of a categorical variable, and then for differences from that reference level. $\endgroup$ – EdM Mar 16 '17 at 19:35
  • $\begingroup$ I have rewrote the equation. I tested to include -1 in the formula for lmer, however and now it make sense as it provides the parameters per level (but lost the global mean, which i was expecting from the linear regression, shouldn't the intercept now be the global mean?). Nevertheless, can't figure how to map this to the equation. $\endgroup$ – SwatchPuppy Mar 16 '17 at 21:34

If you are using treatment contrasts for your categorical variable (the default in R and as implied by your lmer output), the intercept represents the value of the response variable at the reference level (Level1) of the categorical variable and at a value of 0 for the continuous variable. As you have written the equation there are then 2 different coefficients hiding in what you have written as $\beta_1$, representing separately the difference of each of Level2 and Level3 from Level1 (again, at a value of 0 for the continuous variable). For $\beta_2$, the value reported is for cases when the categorical variable is at Level1. Thus there are 2 different coefficients hiding in what you have written as $\beta_3$, representing how much to add or subtract from $\beta_2$ when the categorical variable is at either Level2 or Level3 instead.

Implied in your equation is that the random effect is only involved in the intercept; note that you can also include random slopes.

There are other ways to report such results, but you have to specify other contrasts in your call to the regression function.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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