# Generalized linear mixed model

A generalized linear mixed model (GLMM) is a regression model that extends the generalized linear model by adding random effects, so that non-normal responses measured in groups or repeatedly on the same units can be analyzed while accounting for correlation within those groups. A GLMM contains fixed regression effects shared across the population, variance components describing how cluster-specific coefficients vary, and cluster-specific parameters assumed to be randomly drawn from a population distribution.<sup>[1](https://pubmed.ncbi.nlm.nih.gov/17067411/)</sup> The framework is now standard in biostatistics, ecology, and agronomy: in a survey of 1,133 published papers, 51% reported at least one GLMM, and the main R implementations are downloaded more than 10 million times per year.<sup>[2](https://arxiv.org/abs/2609.24422)</sup>

| Key fact | Detail |
|---|---|
| What it estimates | Fixed effects (population-level) and random-effect variances (variance components)<sup>[1](https://pubmed.ncbi.nlm.nih.gov/17067411/)</sup> |
| Core computational problem | The marginal likelihood requires an integral over the random effects that has no closed form for most GLMMs<sup>[1](https://pubmed.ncbi.nlm.nih.gov/17067411/)</sup> |
| Main approximations | Penalized quasi-likelihood (fast, biased), Laplace (default in lme4 and glmmTMB), adaptive Gauss-Hermite quadrature (accurate, limited to few random effects), Bayesian MCMC<sup>[3](https://cran.r-project.org/web/packages/lme4/vignettes/glmer.pdf)</sup> |
| Interpretation | With non-identity links, GLMM fixed effects describe conditional (subject-specific) effects; marginal (population-averaged) effects depend on the link and model assumptions and are not universally attenuated toward zero, and with a log link and a random intercept independent of the covariates, marginalization changes the intercept but preserves the covariate slopes<sup>[4](https://statistics4ecologists-v2a.netlify.app/glmm)</sup><sup> • </sup><sup>[34](https://journals.sagepub.com/doi/10.1191/0962280204sm368ra)</sup> |
| Minimum grouping levels | There is no universal cutoff such as five or eight levels; random effects can be used with fewer than five grouping levels, although estimating their variance becomes difficult or biased<sup>[5](https://ms.mcmaster.ca/~bolker/R/misc/foxchapter/14-Fox-Chap13.pdf)</sup><sup> • </sup><sup>[35](https://repository.library.noaa.gov/view/noaa/65505/)</sup> |
| Known bias | PQL underestimates variance components and fixed effects for clustered binary data; median absolute bias in the random-intercept variance was 48% for PQL versus 29% for quadrature in one simulation study<sup>[6](https://doi.org/10.1080/01621459.1993.10594284)</sup> |

## How it works

Conditionally on the random effects, a GLMM is an ordinary generalized linear model. The conditional mean and variance follow the GLM form: \( \mathrm{var}(y_i \mid b) = \phi \cdot a_i \cdot v(\mu_i) \), where \( v(\cdot) \) is a specified variance function, \( \phi \) the dispersion, and \( a_i \) a known weight; the link function connects \( \mu_i \) to a linear predictor containing fixed and random effects.<sup>[6](https://doi.org/10.1080/01621459.1993.10594284)</sup> The random effects \( b_i \) are assumed Gaussian with mean zero and a dispersion matrix whose unknown parameters are the variance components; overdispersion, correlated errors, shrinkage, and smoothing can all be encompassed in this single framework.<sup>[6](https://doi.org/10.1080/01621459.1993.10594284)</sup>

Inference uses the marginal likelihood, obtained by integrating the random effects out of the joint density:

\[ L(\beta, \Sigma_b; Y) = \prod_{i=1}^{n} \int \prod_{j} f(y_{ij} \mid b_i)\, f(b_i)\, db_i \]

This integral has no closed-form analytical solution for most GLMMs with a normal mixing distribution, which is what forces the approximate methods described below.<sup>[4](https://statistics4ecologists-v2a.netlify.app/glmm)</sup> Interpretation differs by scale. For a logit random-intercept model there is generally no exact conversion between conditional and marginal coefficients: marginal effects require integration or approximation over the random-effect distribution, and the marginal coefficients are attenuated toward zero, so subject-specific models give larger covariate effects than population-averaged ones.<sup>[4](https://statistics4ecologists-v2a.netlify.app/glmm)</sup>

## How it is done

Estimation methods divide into two classes: numerical approximation to the intractable integral, and analytical approximation to the integrand.<sup>[1](https://pubmed.ncbi.nlm.nih.gov/17067411/)</sup> In rough order of increasing accuracy and cost:<sup>[5](https://ms.mcmaster.ca/~bolker/R/misc/foxchapter/14-Fox-Chap13.pdf)</sup>

1. **Penalized quasi-likelihood (PQL).** Approximating the marginal quasi-likelihood with [Laplace's method](https://www.edgepedia.org/laplaces-method) yields PQL estimating equations for the mean parameters and pseudo-likelihood for the variances, implemented through repeated REML-type calls.<sup>[6](https://doi.org/10.1080/01621459.1993.10594284)</sup> It is fast and flexible but gives biased random-effects variances with binary data or Poisson counts with means below 5.<sup>[5](https://ms.mcmaster.ca/~bolker/R/misc/foxchapter/14-Fox-Chap13.pdf)</sup>
2. **Laplace approximation.** Minimizing the penalized sum of unit deviances by PIRLS gives a local quadratic approximation to the log joint density, which serves as the integral approximation.<sup>[3](https://cran.r-project.org/web/packages/lme4/vignettes/glmer.pdf)</sup>
3. **Adaptive Gauss-Hermite quadrature (AGQ).** Quadrature points are centered and scaled using empirical Bayes estimates of the random effects and the Hessian of that suboptimization; it is very accurate for moderate to large observations per cluster, but becomes computationally infeasible as the number of random effects grows because of the dimensionality of the integral.<sup>[7](https://pmc.ncbi.nlm.nih.gov/articles/PMC3866838/)</sup> [Computation](https://www.edgepedia.org/computation) time grows roughly as \( (N_q)^u \), with \( N_q \) quadrature points and \( u \) random effects; Laplace is equivalent to AGQ with a single point, and 7 or fewer points often suffice.<sup>[8](https://joshua-nugent.github.io/pql/main.pdf)</sup>
4. **Bayesian MCMC**, which avoids the integral by sampling.<sup>[5](https://ms.mcmaster.ca/~bolker/R/misc/foxchapter/14-Fox-Chap13.pdf)</sup>

Software defaults differ: SAS PROC GLIMMIX defaults to pseudo-likelihood, R's glmer to AGQ with one point (Laplace), Stata's meglm to AGQ with 7 points, and SPSS to PQL with no AGQ option.<sup>[8](https://joshua-nugent.github.io/pql/main.pdf)</sup> In lme4, the nAGQ argument controls this: the default nAGQ = 1 is Laplace, values above 1 give [adaptive quadrature](https://www.edgepedia.org/adaptive-quadrature), and nAGQ = 0 uses a faster, less exact PIRLS-based fit.<sup>[9](https://lme4.github.io/lme4/reference/glmer.html)</sup> A typical formula uses vertical bars to separate design matrices from grouping factors, for example `cbind(incidence, size - incidence) ~ period + (1 | herd)` with `family = binomial`.<sup>[9](https://lme4.github.io/lme4/reference/glmer.html)</sup> glmmTMB, built on TMB, assumes Gaussian random effects on the linear-predictor scale integrated by the Laplace approximation with automatic-differentiation gradients, and uses lme4-style formulas.<sup>[10](https://glmmtmb.r-universe.dev/glmmTMB/glmmTMB.pdf)</sup>

## Origin

The GLMM rests on Nelder and Wedderburn's 1972 generalized linear model, whose iterative fitting the random-effects extensions linearize.<sup>[11](https://doi.org/10.2307/2344614)</sup> [Estimation](https://www.edgepedia.org/estimation) in generalized linear models with random effects was treated by Robert Schall in [Biometrika](https://www.edgepedia.org/biometrika) in 1991.<sup>[12](https://doi.org/10.1093/biomet/78.4.719)</sup> The same year, Scott L. Zeger and M. Rezaul Karim avoided numerical integration entirely by casting the model in a Bayesian framework and using the Gibbs sampler.<sup>[13](https://doi.org/10.1080/01621459.1991.10475006)</sup> N. E. Breslow and D. G. Clayton consolidated the frequentist framework in the [Journal of the American Statistical Association](https://www.edgepedia.org/journal-of-the-american-statistical-association) in 1993, framing overdispersion, correlated errors, shrinkage estimation, and smoothing within the GLMM and naming the marginal quasi-likelihood variant of the linearization approach.<sup>[6](https://doi.org/10.1080/01621459.1993.10594284)</sup> Research was in full force by the early 1990s, but relatively easy-to-use software such as SAS GLIMMIX and R lme4 took another decade or more to become broadly available.<sup>[14](https://www.frontiersin.org/journals/horticulture/articles/10.3389/fhort.2024.1423462/full)</sup>

## Variants

**HGLM.** Y. Lee and J. A. Nelder introduced hierarchical generalized linear models in 1996, a synthesis that later GLMM reviews credit as unifying the field.<sup>[15](https://doi.org/10.1111/j.2517-6161.1996.tb02105.x)</sup>

**Overdispersed and zero-inflated mixed models.** glmmTMB fits Gaussian, binomial, beta-binomial, Poisson, negative binomial (NB1 and NB2), Conway-Maxwell-Poisson, generalized Poisson, Gamma, Beta, and Tweedie families, with log, logit, probit, cloglog, inverse, and identity links, plus zero-inflation (a logit-link ziformula) and [hurdle models](https://www.edgepedia.org/hurdle-model).<sup>[16](https://cran.r-project.org/web/packages/glmmTMB/vignettes/glmmTMB.pdf)</sup> The two negative binomial parameterizations differ in the variance-mean relation: for nbinom1 the variance increases linearly with the mean, \( \sigma^2 = \mu \cdot (1 + \alpha) \), while nbinom2 is quadratic in the mean.<sup>[17](https://doi.org/10.32614/rj-2017-066)</sup> Structured covariance matrices (ar1, Matérn, reduced-rank, and others) and dispersion models extend the basic form.<sup>[10](https://glmmtmb.r-universe.dev/glmmTMB/glmmTMB.pdf)</sup> glmmTMB also gained a reduced-rank random-effect structure that writes a q-dimensional multivariate random effect as a linear combination of \( d < q \) latent variables, making random effects of dimension in the hundreds or thousands routine and circumventing near-singularity warnings.<sup>[18](https://www.jstatsoft.org/article/download/v112i01/4676)</sup>

## Applications

Ecology and evolution are flagship areas: a widely cited practical guide consolidated GLMM procedures for ecologists in 2009.<sup>[19](https://doi.org/10.1016/j.tree.2008.10.008)</sup> The lme4 documentation's worked example, respiratory disease in 15 herds of cattle (56 binomial observations), shows the workflow, including adding an observation-level random effect for overdispersion, which improved AIC from 194.05 to 186.64.<sup>[9](https://lme4.github.io/lme4/reference/glmer.html)</sup> In the plant sciences and agronomy, GLMMs handle binomial, Poisson, negative binomial, gamma, and beta responses from designed experiments.<sup>[14](https://www.frontiersin.org/journals/horticulture/articles/10.3389/fhort.2024.1423462/full)</sup> In clinical research, GLMMs are used for rare-event meta-analysis of binary outcomes, where simulation suggests at least 10 total events in both arms are needed.<sup>[20](https://pmc.ncbi.nlm.nih.gov/articles/PMC7296731/)</sup>

## Limitations and alternatives

**Few groups.** Random effects can be used with fewer than five grouping levels, although estimates of their variance may then be difficult or biased, and there is no universal five- or eight-level cutoff; simulation guidance suggests more than 1,000 levels when an accurate variance estimate is crucial, more than 100 for reasonable estimates, and treating the variable as fixed below 10 levels.<sup>[5](https://ms.mcmaster.ca/~bolker/R/misc/foxchapter/14-Fox-Chap13.pdf)</sup><sup> • </sup><sup>[35](https://repository.library.noaa.gov/view/noaa/65505/)</sup>

**Approximation bias.** PQL underestimates variance components and fixed effects for clustered binary data, improving rapidly for binomial denominators greater than 1.<sup>[6](https://doi.org/10.1080/01621459.1993.10594284)</sup> In binary-data simulations, median absolute bias in the random-intercept variance was 29% for quadrature versus 48% for PQL, but nonconvergence was more frequent with quadrature (8.8% vs 2.3% of scenarios).<sup>[21](https://journals.plos.org/plosone/article?id=10.1371%2Fjournal.pone.0084601)</sup> For group-randomized trials with few large clusters, PQL's asymptotic bias for a cluster-level covariate is of order \( O_p(1/m) \), inversely proportional to cluster size, so PQL works well in that setting.<sup>[22](https://www3.stat.sinica.edu.tw/statistica/oldpdf/A15n410.pdf)</sup> Which approximation converges worst is not settled: sparse meta-analysis simulations found PQL convergence below 20% while Laplace stayed near 100%,<sup>[20](https://pmc.ncbi.nlm.nih.gov/articles/PMC7296731/)</sup> but another simulation study found nonconvergence more often with quadrature than PQL.<sup>[21](https://journals.plos.org/plosone/article?id=10.1371%2Fjournal.pone.0084601)</sup> Linearization methods are more versatile, handling conditional and marginal GLMMs and REML-like variance estimation, whereas quadrature is strictly maximum likelihood; no one-size-fits-all best method emerges.<sup>[23](https://ideas.repec.org/a/spr/jagbes/v25y2020i4d10.1007_s13253-020-00402-6.html)</sup>

**Diagnostics and inference.** A first GLMM-specific check is whether the fit is singular (a random-effect variance estimated at zero, detectable in lme4 via near-zero Cholesky elements); the blme package adds a weak prior to avoid singularity, and negative binomial models in glmmTMB or lognormal-Poisson models in glmer are quick remedies for overdispersed counts.<sup>[24](https://bbolker.github.io/mixedmodels-misc/glmmFAQ.html)</sup> Likelihood-ratio tests are unreliable for fixed effects at small to moderate sample sizes, and Wald tests can fail badly (the Hauck-Donner effect); small numbers of clusters call for small-sample corrections such as parametric bootstrap; the Kenward-Roger adjustment was developed for Gaussian linear mixed models and lacks a clear theoretical foundation for generalized models.<sup>[19](https://doi.org/10.1016/j.tree.2008.10.008)</sup> The Kenward-Roger small-sample adjustment was introduced by Michael G. Kenward and James H. Roger in 1997.<sup>[25](https://doi.org/10.2307/2533558)</sup>

**Alternatives.** For longitudinal data, the dominant approaches are GLMMs and (weighted) [generalized estimating equations](https://www.edgepedia.org/generalized-estimating-equation), whose differing assumptions and parameter interpretations carry significant implications for reporting.<sup>[26](https://pmc.ncbi.nlm.nih.gov/articles/PMC5434286/)</sup> GEE, introduced by Kung-Yee Liang and Scott L. Zeger in 1986, targets marginal effects but leaves no formal generative model for fit assessment or individual-level prediction.<sup>[27](https://doi.org/10.1093/biomet/73.1.13)</sup> Random-effects, fixed-effects, and GEE models rest on different assumptions about covariate effects on the mean, and the choice should follow the question addressed.<sup>[28](https://onlinelibrary.wiley.com/doi/10.1002/sim.3478)</sup> Marginally interpretable GLMMs offer a middle path, satisfying \( \int \mathrm{E}(Y \mid U = u) f_U(u)\, du = \mathrm{E}(Y) \), though conventional GLMM tests with nonlinear links can then test the wrong hypothesis.<sup>[29](https://par.nsf.gov/servlets/purl/10250251)</sup> Fully Bayesian fitting is available through brms, Paul-Christian Bürkner's 2017 interface to Stan.<sup>[30](https://doi.org/10.18637/jss.v080.i01)</sup>

**Recent computational work** has targeted the settings where classical fitting struggles. For crossed random effects, [Krylov subspace methods](https://www.edgepedia.org/krylov-subspace-methods) (preconditioned conjugate gradients and stochastic Lanczos quadrature, the trace-estimation technique introduced by Shashanka Ubaru, Jie Chen, and Yousef Saad in 2017<sup>[31](https://doi.org/10.1137/16m1104974)</sup>) achieve roughly a two-order-of-magnitude runtime reduction over Cholesky-based computation, with an implementation up to 10,000 times faster than lme4 and glmmTMB at default settings.<sup>[32](https://ar5iv.labs.arxiv.org/html/2505.09552)</sup> For spatial GLMMs, a [Monte Carlo](https://www.edgepedia.org/monte-carlo) maximum likelihood algorithm using stochastic Newton-Raphson, implemented in the R package glmmrBase by [Samuel I](https://www.edgepedia.org/samuel-i). Watson, Yixin Wang, and Emanuele Giorgi, had shorter run times than INLA for moderately sized datasets.<sup>[33](https://doi.org/10.48550/arxiv.2601.16022)</sup> On the Bayesian side, metabeta, a pretrained neural network for prior-amortized in-context Bayesian inference over GLMMs, matches NUTS posteriors while being two to three orders of magnitude faster; the standard fast alternative, ADVI, is systematically overconfident.<sup>[2](https://arxiv.org/abs/2609.24422)</sup>

## References

1. [Statistical inference in generalized linear mixed models: a review (Rijmen et al., British Journal of Mathematical and Statistical Psychology, 2006)](https://pubmed.ncbi.nlm.nih.gov/17067411/)
2. [Prior-Amortized In-Context Bayesian Inference for Generalized Linear Mixed-Effects Models (metabeta) (preprint)](https://arxiv.org/abs/2609.24422)
3. [Fitting generalized linear mixed models using lme4 (vignette)](https://cran.r-project.org/web/packages/lme4/vignettes/glmer.pdf)
4. [Chapter 19 Generalized linear mixed effects models (GLMMs) | Statistics for Ecologists](https://statistics4ecologists-v2a.netlify.app/glmm)
5. [Bolker, 'Linear and generalized linear mixed models' chapter in Fox et al., Ecological Statistics](https://ms.mcmaster.ca/~bolker/R/misc/foxchapter/14-Fox-Chap13.pdf)
6. [N. E. Breslow, D. G. Clayton (1993). Approximate Inference in Generalized Linear Mixed Models. Journal of the American Statistical Association.](https://doi.org/10.1080/01621459.1993.10594284)
7. [An assessment of estimation methods for generalized linear mixed models with binary outcomes](https://pmc.ncbi.nlm.nih.gov/articles/PMC3866838/)
8. [Bias induced by fitting GLMMs with dichotomous outcomes using penalized quasi-likelihood (preprint)](https://joshua-nugent.github.io/pql/main.pdf)
9. [Fitting Generalized Linear Mixed-Effects Models, glmer • lme4 (official documentation)](https://lme4.github.io/lme4/reference/glmer.html)
10. [glmmTMB reference manual (version 1.1.15)](https://glmmtmb.r-universe.dev/glmmTMB/glmmTMB.pdf)
11. [J. A. Nelder, R. W. M. Wedderburn (1972). Generalized Linear Models. Journal of the Royal Statistical Society Series A (General).](https://doi.org/10.2307/2344614)
12. [ROBERT SCHALL (1991). Estimation in generalized linear models with random effects. Biometrika.](https://doi.org/10.1093/biomet/78.4.719)
13. [Scott L Zeger, M. Rezaul Karim (1991). Generalized Linear Models with Random Effects; a Gibbs Sampling Approach. Journal of the American Statistical Association.](https://doi.org/10.1080/01621459.1991.10475006)
14. [The value of generalized linear mixed models for data analysis in the plant sciences (Frontiers, 2024)](https://www.frontiersin.org/journals/horticulture/articles/10.3389/fhort.2024.1423462/full)
15. [Y. Lee, J. A. Nelder (1996). Hierarchical Generalized Linear Models. Journal of the Royal Statistical Society Series B (Statistical Methodology).](https://doi.org/10.1111/j.2517-6161.1996.tb02105.x)
16. [glmmTMB: Getting started with the package (vignette)](https://cran.r-project.org/web/packages/glmmTMB/vignettes/glmmTMB.pdf)
17. [Mollie,E. Brooks and colleagues (2017). glmmTMB Balances Speed and Flexibility Among Packages for Zero-inflated Generalized Linear Mixed Modeling. The R Journal.](https://doi.org/10.32614/rj-2017-066)
18. [Parsimoniously Fitting Large Multivariate Random Effects in glmmTMB (Journal of Statistical Software)](https://www.jstatsoft.org/article/download/v112i01/4676)
19. [Benjamin M. Bolker and colleagues (2009). Generalized linear mixed models: a practical guide for ecology and evolution. Trends in Ecology & Evolution.](https://doi.org/10.1016/j.tree.2008.10.008)
20. [Laplace approximation, penalized quasi-likelihood, and adaptive Gauss–Hermite quadrature for GLMMs: towards meta-analysis of binary outcome with sparse data](https://pmc.ncbi.nlm.nih.gov/articles/PMC7296731/)
21. [Generalized Linear Mixed Models for Binary Data: Are Matching Results from Penalized Quasi-Likelihood and Numerical Integration Less Biased? (PLOS One)](https://journals.plos.org/plosone/article?id=10.1371%2Fjournal.pone.0084601)
22. [Asymptotic bias and variance of the PQL estimator in group-randomized trials (Bellamy, Li, Lin, Ryan, Statistica Sinica)](https://www3.stat.sinica.edu.tw/statistica/oldpdf/A15n410.pdf)
23. [Pseudo-Likelihood or Quadrature? What We Thought We Knew... (Journal of Agricultural, Biological, and Environmental Statistics, 2020)](https://ideas.repec.org/a/spr/jagbes/v25y2020i4d10.1007_s13253-020-00402-6.html)
24. [GLMM FAQ (Ben Bolker)](https://bbolker.github.io/mixedmodels-misc/glmmFAQ.html)
25. [Michael G. Kenward, James H. Roger (1997). Small Sample Inference for Fixed Effects from Restricted Maximum Likelihood. Biometrics.](https://doi.org/10.2307/2533558)
26. [Modern methods for longitudinal data analysis, capabilities, caveats and cautions (2016)](https://pmc.ncbi.nlm.nih.gov/articles/PMC5434286/)
27. [KUNG-YEE LIANG, SCOTT L. ZEGER (1986). Longitudinal data analysis using generalized linear models. Biometrika.](https://doi.org/10.1093/biomet/73.1.13)
28. [Gardiner, Luo, Roman (2009), 'Fixed effects, random effects and GEE: What are the differences?', Statistics in Medicine](https://onlinelibrary.wiley.com/doi/10.1002/sim.3478)
29. [Marginally interpretable GLMMs (peer-reviewed methods paper, NSF public access repository)](https://par.nsf.gov/servlets/purl/10250251)
30. [Paul-Christian Bürkner (2017). brms : An R Package for Bayesian Multilevel Models Using Stan. Journal of Statistical Software.](https://doi.org/10.18637/jss.v080.i01)
31. [Shashanka Ubaru, Jie Chen, Yousef Saad (2017). Fast Estimation of $tr(f(A))$ via Stochastic Lanczos Quadrature. SIAM Journal on Matrix Analysis and Applications.](https://doi.org/10.1137/16m1104974)
32. [Scalable Computations for Generalized Mixed Effects Models with Crossed Random Effects Using Krylov Subspace Methods (preprint, 2025)](https://ar5iv.labs.arxiv.org/html/2505.09552)
33. [Watson, Samuel I., Wang, Yixin, Giorgi, Emanuele (2026). Approximate Likelihood-Based Inference for Spatial Generalized Linear Mixed Models. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2601.16022)
34. [journals.sagepub.com](https://journals.sagepub.com/doi/10.1191/0962280204sm368ra)
35. [repository.library.noaa.gov](https://repository.library.noaa.gov/view/noaa/65505/)

---
*Topic: Encyclopedia › Physical world and mathematics › Mathematics and statistics › Statistics and probability › Statistical inference, estimation, sampling, and testing › Regression analysis › Multilevel and mixed-effects regression*

*Initially written Sep 29, 2026 · Edited: Oct 15, 2026*

*Copyright 2026 EdgeChat AI, a subsidiary of Biostate AI.*

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license
