Mixed-effects models (also called hierarchical or multilevel models) handle data with natural grouping structures — repeated measurements on the same patient, patients nested within hospitals, or students within schools. They include both fixed effects (population-average effects of predictors, the same for everyone) and random effects (subject-specific deviations that account for the correlation among observations within the same cluster). A random intercept allows each subject's baseline to differ; a random slope allows each subject's response to a predictor to differ. By explicitly modeling the within-cluster correlation, mixed-effects models produce correct standard errors (unlike ordinary regression, which treats all observations as independent), efficiently borrow strength across clusters, and provide subject-specific predictions that are shrunk toward the population mean.
Health data almost always has structure. Patients are measured repeatedly over time (longitudinal data), patients are treated in hospitals that vary in quality (nested data), and clinical trials recruit from multiple centers (clustered data). In all these settings, observations within the same group are more similar to each other than observations across groups. Standard regression assumes independence and will produce incorrect standard errors — typically too small — when this correlation exists, leading to false confidence in results.
Mixed-effects models handle this by introducing random effects — subject-specific (or cluster-specific) parameters drawn from a population distribution. A random intercept for patient assumes each patient has their own baseline level, drawn from a normal distribution centered on the population mean. A random slope for time assumes each patient has their own rate of change. Together, these define a family of patient-specific trajectories that share a common structure but vary around it. The fixed effects capture the population-average relationship (the mean trajectory), while the random effects capture how individual trajectories deviate from it.
Estimation of mixed-effects models uses restricted maximum likelihood (REML) or full maximum likelihood. REML produces less biased estimates of variance components and is the default in most software. The individual-level predictions (Best Linear Unbiased Predictions, or BLUPs) combine each subject's own data with the population-level estimates, weighted by the relative precision of each. A subject with many measurements gets a prediction close to their own data; a subject with few measurements gets a prediction pulled ("shrunk") toward the population mean. This shrinkage is not a limitation — it is a statistically optimal way to handle the varying information content across subjects.
The choice between random intercepts only, random intercepts and slopes, and more complex random effects structures is driven by the data and the research question. Likelihood ratio tests, AIC, and BIC can compare nested models. The key practical considerations are: does the model converge? (Complex random effects structures with many correlated parameters may fail to converge with limited data.) Do the random effects make scientific sense? (A random slope for treatment group requires that treatment effects truly vary across clusters, not just baseline levels.) And is the random effects distribution reasonable? (The standard assumption is multivariate normal; severe departures may require robust or non-parametric alternatives.)