A Comparison of R Packages for Estimating Generalized Linear Mixed Models
Abstract
Generalized linear mixed models (GLMMs) are widely used for analyzing correlated data, such as longitudinal and multilevel data. With over 15 R packages available on CRAN for fitting GLMMs, practitioners face a difficult choice regarding which package yields accurate estimates, converges reliably, and offers reasonable computational speed. Existing comparisons are either limited to methods within a single package or focus on narrow criteria such as speed alone. To address this gap, we systematically compared seven representative R packages -- lme4, GLMMadaptive, glmmTMB, MASS, hglm, brms, and rstanarm -- that implement different estimation frameworks. By using Monte Carlo simulations across 24 scenarios, we evaluated each package in terms of convergence ratios, computational time, estimation accuracy, and hypothesis testing performance. Our results showed that lme4AGQ and GLMMadaptive yield the highest accuracy and convergence ratios, although GLMMadaptive becomes slower under complex random-effect structures. lme4LA and glmmTMB are computationally fast but exhibit lower convergence ratios and larger bias, especially for variance components. MASS and hglm are also fast, but MASS yields liberal univariate tests and hglm lacks support for correlated random effects and multivariate testing. Between two Bayesian packages, rstanarm converges reliably and produces valid univariate tests, whereas brms is extremely slow, limiting its practical utility. Based on these findings, we provide practical recommendations for choosing GLMM tool in applied research.
Turn this paper into a lesson
ArcXiv compiles a structured reading guide from this paper's metadata: plain-English importance, contributions, prerequisite concepts, which sections to read first, flashcards, and a quiz. Grounded in the abstract, never invented.