Mixed Effects Model

Statistics
Introduced by
Laird & Ware
Year
1982
Type
Mixed effects regression
Family
Regression / GLM

What does it do?

A mixed effects model (also called a linear mixed model) extends ordinary regression by including fixed effects, which are population-level parameters shared by all observations, and random effects, which capture subject-, group-, or cluster-level variability.

It is a common tool for repeated-measures, longitudinal, and multilevel data in which observations within the same unit are correlated.

The intuition behind the method

Imagine tracking students' test scores across several schools over multiple time points. Students within the same school are more similar to each other than to students from other schools, and each student's repeated scores are correlated across time. An ordinary regression ignores both dependencies, which can make standard errors too small and inflate false-positive rates. A mixed model adds school- and student-level random intercepts (and possibly slopes) that absorb this grouping structure, so the fixed effects estimate population-level relationships without being distorted by the clustering.

History

Laird and Ware (1982, Biometrics) developed random-effects models for longitudinal data. The paper describes two-stage random-effects models in which some parameters vary across individuals with a specified second-stage distribution, a family that includes growth and repeated-measures models as special cases, and fitting based on empirical Bayes and maximum likelihood estimation using the EM algorithm.

When to use it

Use a mixed effects model when the outcome is continuous and observations are clustered or repeated: longitudinal studies with multiple measurements per subject, educational data with students nested in classrooms or schools, clinical trials with patients nested in sites, or designs with another natural grouping variable. The key signal is non-independence; if ignoring the clustering would give artificially small standard errors and inflated Type I error, a mixed model is warranted. Do not use it when observations are truly independent (standard OLS is simpler and equally valid), when there are too few groups to estimate the between-group variance reliably, or when the outcome is not continuous (use a generalized linear mixed model instead). When only a few groups are available, the between-group variance is estimated imprecisely; report the number of groups and consider a fixed-effects or Bayesian alternative, such as the Bayesian mixed-effects model, in that case.

Limitations and considerations

  • Requires decisions about random-effect structure (random intercepts only vs. random slopes) that can substantially affect conclusions; over-specified random structures may fail to converge.
  • Inference on fixed effects depends on approximations to denominator degrees of freedom (Kenward-Roger, Satterthwaite) that are imperfect, especially with small samples.
  • Assumes normally distributed random effects and residuals; pronounced departures (e.g., heavily skewed outcomes) can distort variance component estimates.
  • Computationally more demanding than OLS; complex random-effect structures with many predictors and groups may require long fitting times or fail to converge.
  • Interpretation of random-effect variance components requires understanding of variance partitioning (ICC), which is less intuitive than plain OLS slopes.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Accounts for non-independence from repeated measures, longitudinal, or nested data, so standard errors reflect the clustering when the random-effect structure is adequate; p-values rely on approximate denominator degrees of freedom, especially in small samples.
  • Handles unbalanced designs and missing observations at a given time point gracefully — subjects with incomplete data contribute whatever measurements they have.
  • Simultaneously models population-level fixed effects and unit-level random effects, providing both group-average and subject-specific predictions.
  • Generalises naturally to generalized linear mixed models (GLMMs) for binary, count, or other non-normal outcomes.
  • Partial pooling of group estimates shrinks noisy group-level estimates toward the grand mean, reducing overfitting compared to separate regressions per group.

Applications

  • Longitudinal clinical trials measuring patient outcomes at multiple follow-up time points.
  • Educational research assessing student achievement with students nested in classrooms and schools.
  • Ecological studies with repeated measurements from the same plots or individuals across seasons.
  • Psycholinguistic experiments with both subjects and items as crossed random effects.
  • Pharmacokinetics modelling individual drug-concentration profiles with a shared population model.
  • Workplace studies with employees nested in teams or organisations.

How it works

How it works

1

The model is written as y = Xβ + Zb + ε, where X holds the predictors for fixed effects β, Z holds the design matrix for random effects b, and ε is the residual error. The random effects b and ε are assumed normally distributed with covariance matrices G and R respectively.

Formula
y = X\beta + Zb + \varepsilon,\quad b \sim \mathcal{N}(0,G),\quad \varepsilon \sim \mathcal{N}(0,R)
2

Fixed effects β represent the average (population-level) relationship between predictors and the outcome. They are interpreted in the same way as ordinary regression coefficients and are usually the main targets for inference.

3

Random effects b capture how each group (subject, school, clinic, etc.) deviates from the population average. A random intercept gives each group its own baseline level; a random slope lets the effect of a predictor differ across groups. The grouping structure encoded in Z can be nested (students within schools) or crossed (subjects and items in psycholinguistic designs, where the same subjects respond to the same items), and the random-effects specification should match the design. The distribution of these deviations is estimated rather than fitted separately for each group.

4

Parameters are estimated by maximum likelihood (ML) or restricted maximum likelihood (REML). ML uses the full marginal likelihood of the outcomes, whereas REML works with a likelihood from which the fixed effects have been removed. REML is commonly preferred for estimating variance components because it accounts for the degrees of freedom used by the fixed effects, which reduces the downward bias of ML variance estimates in smaller samples. REML variance estimates are less biased than ML estimates, although they are not unbiased in general.

5

Fixed-effect hypotheses are tested with approximate t and F tests using denominator degrees of freedom from Kenward-Roger or Satterthwaite approximations, or with likelihood-ratio tests comparing nested models fitted by ML; REML likelihoods are not comparable when the fixed-effect structure differs. Random-effect variance components are compared using AIC, BIC, or likelihood-ratio tests on REML fits. Null values of variance components lie on the boundary of the parameter space, so standard chi-square reference distributions need care. For a single variance component, the likelihood-ratio statistic is usually referred to a mixture of chi-square distributions rather than a single chi-square, and a parametric bootstrap is a practical alternative when the reference distribution is in doubt.

Common pitfalls

  • Starting with a maximal random-effect structure (all random slopes) without checking whether the data support it — this often causes singular fits or non-convergence. Begin with random intercepts only and add slopes only when theoretically motivated and the data are sufficient.
  • Comparing nested mixed models with REML when the fixed-effect structure differs — likelihood-ratio tests on fixed effects must use ML, not REML.
  • Treating the random-effect predictions (BLUPs) as ordinary estimates with their own standard errors; BLUPs are shrinkage estimates and have a different uncertainty structure.
  • Ignoring the intraclass correlation coefficient (ICC) — if the ICC is near zero there is no meaningful clustering and OLS is simpler and equally valid.
  • Failing to check residual plots at both the within-group and between-group levels; heteroscedasticity or outliers at either level can distort estimates.

Frequently asked questions

What is the difference between a fixed effect and a random effect?

Fixed effects are population-level parameters whose levels are of direct interest and are fully estimated (e.g., treatment vs. control). Random effects represent a sample of levels drawn from a larger population (e.g., participating schools), and their variability is summarised by a variance component rather than individual coefficients.

Should I use ML or REML for estimation?

Use REML when comparing models that differ only in their random-effect structure — REML gives less biased variance component estimates than ML, especially in smaller samples. Use ML when comparing models that differ in their fixed effects via likelihood-ratio tests, because REML likelihoods are not comparable across different fixed-effect structures.

How do I know if I need a mixed model or just OLS with clustered standard errors?

A mixed model is preferable when you want to model and partition the grouping variance, make predictions for specific groups, or have a small number of groups with many observations each. Clustered standard errors (robust SEs) are a lighter-weight fix when you only care about correct inference on fixed effects and do not need group-level predictions.

What is a singular fit warning and what should I do?

A singular fit means one or more variance components are estimated as exactly zero, indicating the random-effect structure is more complex than the data support. Simplify by removing random slopes or constraining the random-effect correlation structure.

Can mixed models handle missing data?

Yes, under the missing at random (MAR) assumption. Subjects with some missing time points still contribute all their observed measurements to the likelihood, so the model uses all available data without imputation. If data are missing not at random (MNAR), additional sensitivity analyses are needed.

Related methods

Sources

  1. Laird, N. M., & Ware, J. H. (1982). Random-effects models for longitudinal data. Biometrics, 38(4), 963–974.

    Open DOI reference
  2. Pinheiro, J. C., & Bates, D. M. (2000). Mixed-Effects Models in S and S-PLUS. Springer.

    ISBN: 978-0387989570