Linear mixed models for a continuous outcome with grouped or clustered data — repeated measures, students within classrooms, sites in a trial. The grouping soaks up correlation that plain OLS would ignore.
Note
Examples
- Repeated measures: random intercept per subject
systolic_bp ~ phase + (1|patient)— does a continuous outcome change over repeated visits, each subject as its own control. - Treatment x time interaction (random intercept)
pain_score ~ treatment * week + (1|patient)— does the trajectory over time differ between two arms (difference-in-differences). - Growth curve: random intercept and slope of time
seedling_height ~ week + (week | seedling)— the average time slope judged against scattering individual growth rates. - Conditional growth: treatment moderating individual slopes
seedling_height ~ fertilizer * week + (1 + week | seedling)— whether two arms diverge in growth rate, with random intercepts and slopes. - Two-level cluster-randomized trial (random intercept)
cholesterol ~ treatment + (1|clinic)— a trial randomising whole clusters, one continuous outcome per member. - Cluster RCT with a baseline covariate (adjusted)
blood_pressure ~ treatment + baseline_bp + (1|clinic)— a cluster trial adjusted for a baseline covariate. - Multisite trial: treatment effect varying across sites
recovery_days ~ treatment + (treatment | site)— a treatment effect allowed to vary across sites (random slope). - Within-subjects one-way design: repeated condition factor
enzyme_activity ~ condition + (1|sample)— a repeated 3-level condition factor compared within each subject.