Linear mixed model
Analyzes a continuous outcome measured repeatedly in the same patients, or in clustered patients, accounting for the correlation between measurements.
Clinical example
Blood pressure measured at baseline, 6 weeks and 12 weeks in two treatment arms.
When to use it
- The outcome is a continuous measurement taken three or more times per patient, or patients are clustered, for example in wards.
- You want to compare groups, or how groups change over time.
- You need to adjust for other variables.
Assumptions to check
Correct random-effects structure
A random intercept per patient is the usual start. Add a random slope for time if patients' trajectories differ a lot.
Residual assumptions
Check the residuals for a roughly normal shape and constant spread.
What to report
- Estimated difference between groups (or in change over time) with 95% CI
- The random-effects structure you used
- The number of patients and of measurements
Common mistakes
Repeated measurements aren't independent
Treating several measurements per patient as separate patients makes confidence intervals too narrow and p-values too small.
Don't run many separate tests
Testing every pair of groups, outcome or time point separately piles up false positives. Use one model, prespecify the main comparison, and correct for multiple comparisons where needed.
Alternatives
| If your situation is… | Use |
|---|---|
| Yes/no outcome | GEE and mixed-effects logistic regression |
| Only two measurements per patient | Paired t-test |
In your software
# R (long format: one row per measurement)
library(lmerTest)
fit <- lmer(sbp ~ arm * visit + (1 | patient_id), data = trial_long)
summary(fit)
MIXED sbp BY arm WITH visit
/FIXED=arm visit arm*visit | SSTYPE(3)
/PRINT=SOLUTION
/RANDOM=INTERCEPT | SUBJECT(patient_id) COVTYPE(VC).