Ask Mallard

Mixed-effects models

Mixed-effects models combine population-level effects with random effects that represent variation across people, clinics, hospitals, or other clusters.

What question does this help answer?

“How is an outcome associated with predictors when repeated measurements or hierarchical clustering make observations within a unit correlated?”

When to use it

Use mixed-effects models for repeated measurements, multilevel data, clustered studies, longitudinal trajectories, or settings where subject- or cluster-specific variation is scientifically meaningful.

When not to use it

Do not add random effects automatically. The hierarchy, number of clusters, outcome type, estimand, and covariance structure should justify the model.

How it works in plain language

Fixed effects estimate average relationships of interest. Random effects allow units such as patients or clinics to have their own intercepts and, when appropriate, slopes. This accounts for correlation among observations from the same unit.

What random intercepts look like

Random intercepts. Several thin parallel lines, one per cluster at its own level, around a thicker average line with the same slope.Random intercepts: each cluster its own level, one shared slopePredictorOutcomeAverage lineAdding a random slope would let each cluster's line tilt as well; more complex structures are notautomatically better.
Conceptual diagram. It shows the structure of the idea, not data from any study.

Why Mallard may recommend it

Mallard may recommend a mixed model when measurements repeat within the same person, patients are nested within clinicians or sites, or a cluster-randomized design is used.

Key assumptions

  • The random-effects structure is scientifically and statistically defensible.
  • The conditional outcome distribution and link are appropriate.
  • The number and size of clusters support the intended model.
  • Missingness assumptions are considered for longitudinal data.
  • Model convergence and singular fits are evaluated.

What to watch out for

More complex random-effects structures are not always better. Interpretation differs from population-average models such as GEE.

Clinical example

Model repeated blood-pressure measurements over 12 months using fixed effects for treatment and time and random intercepts for participants.

How to interpret it

A treatment coefficient describes the modeled conditional difference after accounting for the random-effects structure. Random-effect estimates describe unexplained between-unit variability.

Code for this method
Loading…
Recent studies that used this
Searching PubMed…
Work it out
Related Learn pages
Sources & further reading
  1. Real longitudinal data analysis for real people: building a good enough mixed model (opens in a new tab) · Stat Med · doi 10.1002/sim.3775
  2. Repeated Measures Designs and Analysis of Longitudinal Data (opens in a new tab) · Anesth Analg · doi 10.1213/ANE.0000000000003511
Last source review: 2026-09-05
AI-generated educational content
Mallard uses reputable methodological and reporting sources, but this material may contain errors or omit important context. Verify important methodological decisions with the cited sources and, when appropriate, a qualified research methodologist or statistician.