PickMyTest

Linear Mixed Models (LMM)

Linear mixed models extend RM-ANOVA to handle missing data, unequal time intervals, and nested structures β€” the modern alternative for repeated measures.

Linear Mixed Models (LMM)#

If you would use RM-ANOVA but have missing data, unequal time intervals, or nested structures β€” then linear mixed models (LMM) are your tool. They are not a complicated specialist method but the natural evolution of ANOVA. In fact, RM-ANOVA is a special case of the LMM.

When to Use#

  • You have repeated measures but some data are missing β€” LMM can handle missing values without excluding entire participants
  • Your measurements have unequal time intervals (e.g., assessments at 1, 3, and 12 months)
  • Your data are nested (e.g., students in classrooms, patients in clinics)
  • You need more flexibility than a traditional ANOVA provides β€” such as different covariance structures
  • You want to model individual trajectories (each person can have their own starting point and rate of change)

Fixed and Random Effects β€” Simply Explained#

Imagine you are studying learning progress of students across different classrooms:

  • Fixed effects answer your research question: "Does the new teaching method improve performance?" β€” these are the effects you want to generalize to the population.
  • Random effects model the structure of your data: "Students in the same classroom are more similar to each other than students from different classrooms." β€” they capture variation between clusters (e.g., classrooms).

Key insight: Fixed effects = what you care about scientifically. Random effects = the nesting in your data.

Assumptions#

  • Linearity β€” the relationship between predictors and outcome is linear
  • Normality of residuals (not the raw data!)
  • Normality of random effects
  • Independence of observations at the highest level (e.g., between classrooms)

Tip: LMM are robust to mild violations of normality, especially with larger samples. Check residuals with a QQ plot. Unlike RM-ANOVA, no sphericity assumption is needed.

Formula#

The core idea is simple β€” just add a random component:

Yij=(Ξ²0+b0j)+(Ξ²1+b1j)β‹…Xij+Ξ΅ijY_{ij} = (\beta_0 + b_{0j}) + (\beta_1 + b_{1j}) \cdot X_{ij} + \varepsilon_{ij}

Where:

  • Ξ²0\beta_0 = fixed intercept (overall mean, fixed effect)
  • b0jb_{0j} = random deviation of the intercept for group jj (random intercept)
  • Ξ²1\beta_1 = fixed effect of the predictor (e.g., time)
  • b1jb_{1j} = random deviation of the slope for group jj (random slope)
  • Ξ΅ij\varepsilon_{ij} = residual

In plain language: Each person (or cluster) gets their own starting point and their own rate of change, but all are drawn from a shared distribution.

RM-ANOVA is a special case of the LMM β€” with a balanced design, complete data, and compound symmetry covariance structure, both yield identical results.

Example#

Practical Example: Stress Reduction With Missing Data

60 patients participate in an 8-week stress reduction program. Stress levels are measured at 4 time points (weeks 0, 2, 5, and 8 β€” unequal intervals). 12 patients miss at least one appointment.

With RM-ANOVA: 12 patients are excluded entirely β†’ only 48 patients β†’ loss of information and potential bias.

With LMM: All 60 patients are included. The model uses whatever data each person provides.

Model: Stress ~ Time + (1 + Time | Person)

Results:

  • Fixed effect of time: Ξ²1=βˆ’2.34\beta_1 = -2.34, SE=0.41SE = 0.41, p<.001p < .001 β€” stress decreases by an average of 2.34 points per measurement occasion
  • Random intercept SD: 4.12 β€” individuals start at different stress levels
  • Random slope SD: 1.08 β€” the rate of stress reduction varies across individuals

Effect Size#

For LMM, two R2R^2 measures are reported (following Nakagawa & Schielzeth):

Rmarginal2=Οƒf2Οƒf2+Οƒr2+Οƒe2R^2_{\text{marginal}} = \frac{\sigma^2_f}{\sigma^2_f + \sigma^2_r + \sigma^2_e}

Rconditional2=Οƒf2+Οƒr2Οƒf2+Οƒr2+Οƒe2R^2_{\text{conditional}} = \frac{\sigma^2_f + \sigma^2_r}{\sigma^2_f + \sigma^2_r + \sigma^2_e}

  • Marginal R2R^2: Variance explained by fixed effects alone
  • Conditional R2R^2: Variance explained by fixed + random effects
MeasureInterpretation
Rm2R^2_m = 0.13, Rc2R^2_c = 0.55Fixed effects explain 13%, with random effects 55% β€” cluster structure matters a lot
Rm2β‰ˆRc2R^2_m \approx R^2_cLittle variation between clusters β€” a simpler model may suffice

Tip: When Rm2R^2_m and Rc2R^2_c diverge strongly, the random effects are important and a simple regression model would be inadequate.

Further Reading

  • Winter, B. (2020). Statistics for Linguists: An Introduction Using R. Routledge. (Very accessible introduction to LMM)
  • Nakagawa, S. & Schielzeth, H. (2013). A general and simple method for obtaining R2R^2 from generalized linear mixed-effects models. Methods in Ecology and Evolution, 4(2), 133–142.
  • Baayen, R. H., Davidson, D. J. & Bates, D. M. (2008). Mixed-effects modeling with crossed random effects for subjects and items. Journal of Memory and Language, 59(4), 390–412.