WIPIVERSE All articles

Mixed model

A mixed model, also known as a mixed-effects model or multilevel model, is a statistical modeling framework that incorporates both fixed effects and random effects within a single analysis. Fixed effects estimate population‑averaged relationships that are consistent across all observations, whereas random effects account for variation attributable to hierarchical or clustered structures in the data (e.g., subjects, groups, geographical units, repeated measures).

Core Components

Component Description
Fixed effects Parameters that describe systematic influences of predictor variables that are assumed to be the same for all experimental units (e.g., treatment effects, covariates).
Random effects Terms that capture random variation associated with sampling units or clusters. They are typically modeled as draws from a probability distribution, often assumed to be normal with mean zero and estimable variance components.
Residual error The unexplained variation at the observation level, also assumed to follow a specified distribution (commonly normal).
Covariance structure Specification of how random effects and residual errors are correlated (e.g., unstructured, compound symmetry, autoregressive).

Types of Mixed Models

Type Typical Use Model Form
Linear mixed model (LMM) Continuous outcome data with normal residuals. $ y = X\beta + Zb + \varepsilon $ where $b \sim N(0, G)$, $\varepsilon \sim N(0, R)$.
Generalized linear mixed model (GLMM) Non‑normal outcomes (binary, count, categorical). Extends LMM by linking the linear predictor $X\beta + Zb$ to the mean of the response via a link function (e.g., logit, log).
Nonlinear mixed model (NLME) Nonlinear relationships between predictors and outcome. Incorporates random effects into parameters of a nonlinear deterministic function.
Multivariate mixed model Simultaneous modeling of multiple correlated outcomes. Stacks several response vectors, each with its own fixed and random effects, allowing for cross‑outcome covariance.

Estimation Methods

  • Maximum Likelihood (ML) – Estimates all variance components jointly by maximizing the joint likelihood of the data.
  • Restricted (or Residual) Maximum Likelihood (REML) – Adjusts for the loss of degrees of freedom due to estimating fixed effects, providing less biased variance component estimates in many contexts.
  • Penalized Quasi‑Likelihood (PQL) – Approximate method used for GLMMs with non‑Gaussian outcomes.
  • Bayesian approaches – Employ Markov Chain Monte Carlo (MCMC) or variational inference to obtain posterior distributions for parameters, facilitating incorporation of prior information.

Common Applications

  • Longitudinal studies – Repeated measurements on individuals over time.
  • Clustered or hierarchical data – Students within classrooms, patients within hospitals, or animals within litters.
  • Genetics and breeding – Modeling genetic and environmental contributions to phenotypic traits (e.g., animal “mixed model equations”).
  • Psychology and education – Analyzing data with nested designs (e.g., test scores nested within schools).
  • Ecology – Accounting for spatial or temporal autocorrelation among observational units.

Advantages

  • Provides unbiased estimates of fixed effects in the presence of correlated observations.
  • Allows explicit modeling of variance components, yielding insight into sources of variability.
  • Accommodates unbalanced designs and missing data under the assumption of missing at random (MAR).

Limitations

  • Model specification (choice of random‑effects structure and covariance matrix) can be complex and may affect inference.
  • Computationally intensive for large data sets, especially with non‑Gaussian outcomes and many random effects.
  • Diagnostics for mixed models are less standardized than for simple linear models; assessing model fit and residual assumptions may require specialized tools.

Software Implementations

Software Packages / Functions
R lme4::lmer (LMM), lme4::glmer (GLMM), nlme, lmerTest, brms (Bayesian)
Python statsmodels (MixedLM), PyMC3/PyMC4 (Bayesian), lme4 via rpy2
SAS PROC MIXED, PROC GLIMMIX, PROC NLMIXED
Stata mixed, meglm, menbreg
SPSS Mixed Models procedure
MATLAB fitlme, fitglme

Key References

  • Pinheiro, J. C., & Bates, D. M. (2000). Mixed-Effects Models in S and S‑PLUS. Springer.
  • Gelman, A., & Hill, J. (2007). Data Analysis Using Regression and Multilevel/Hierarchical Models. Cambridge University Press.
  • Van den Boogaart, K. G., & Hoijtink, H. (2000). Linear Mixed Models: A Practical Guide Using R. Wiley.

Related Concepts

  • Hierarchical linear model (HLM) – A specific case of mixed models emphasizing nested data structures.
  • Random‑effects meta‑analysis – Uses a random‑effects component to model between‑study heterogeneity.
  • Variance component analysis – Focuses on partitioning total variance among sources, often within a mixed‑model framework.

Mixed models constitute a foundational tool in modern statistical analysis for handling data that exhibit both fixed systematic effects and random variability due to grouping or hierarchical structures.

Browse

More topics to explore

    Browse all articles