Elamur Research
☰
home / papers / 2015 / Fitting Linear Mixed-Effects Models Using lme4

Fitting Linear Mixed-Effects Models Using lme4

Written for the Research library (claude-opus-5-5) from the paper text. Original — jstatsoft.org/index.php/jss/article/view/v067i01/946

Summary

Mixed-effects models combine population-level (fixed) and group-level (random) terms. They are widely used but computationally demanding, especially on data with 10^4–10^6 observations. This paper documents how the lme4 package for R fits linear mixed models through its lmer function. Users specify fixed and random terms in a single R formula. lme4 turns that formula into sparse model matrices and a relative covariance factor governed by a parameter vector θ. Fitting is recast as a penalized least squares problem solved with sparse Cholesky decomposition. This yields a profiled deviance or REML criterion that depends only on θ, which a constrained optimizer then minimizes. lmer is organised into four separable modules, and each step is exposed so that developers can build models the formula syntax cannot express, such as pedigree or smoothing-spline models. Compared with nlme, lme4 offers faster linear algebra, simpler handling of crossed random effects, profile-likelihood intervals and GLMM support. The paper is the reference description of a core tool in applied statistics.

Key points

  • Modular pipeline. lmer is split into four modules: lFormula, mkLmerDevfun, optimizeLmer and mkMerMod. The paper describes stable version 1.1-10.
  • Running example. The sleepstudy data (180 observations, 18 subjects, sleep limited to 3 h per night) is fitted with Reaction ~ Days + (Days | Subject).
    • Fixed effects: intercept 251.4 ms, slope 10.47 ms/day.
    • Random-effect SDs: 24.74 ms (intercept) and 5.92 ms/day (slope).
  • Trade-offs with nlme. nlme remains more convenient for heteroscedastic or autocorrelated residuals and structured covariance matrices.
  • Related projects. Descendants include MixedModels (Julia), lme4pureR and the flexLambda branch. gamm4 and blme build on lme4's extension hooks.
  • Post-fit tools.
    • Profile-based confidence intervals with zeta, density and pairs plots.
    • predict with a re.form argument to control which random effects are conditioned on.
    • simulate, which supports parametric bootstrap and formula-based power analysis.

Our summary of the paper, in our own words — not its text. The work belongs to its authors; read it at the links above.

Fields: Mathematics & statistics

Cited by

380 papers of our library cite it (of the 140673 whose bibliographies we read); 14 of them have a page here, 366 not yet.

Cite

The paper itself, not this page. BibTeX from the library's record of the work. arXiv 1406.5823

@article{bates2015fitting,
  title = {{Fitting Linear Mixed-Effects Models Using lme4}},
  author = {Bates, Douglas and Mächler, Martin and Bolker, Ben and Walker, Steve},
  journal = {Journal of Statistical Software 67(1)},
  year = {2015},
  eprint = {1406.5823},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1406.5823}
}

References

46 references, 0 of them with a card of ours. ↗ leads to the work, «find» searches for one we have no id for yet.

  1. Bates D (2015). MixedModels: A Julia Package for Fitting (Statistical) Mixed-Effects Models. Julia package version 0.3-22, URL https://github.com/dmbates/MixedModels.jl. ↗
  2. Bates D, Maechler M (2015). Matrix: Sparse and Dense Matrix Classes and Methods. R package version 1.2-2, URL http://CRAN.R-project.org/package=Matrix. ↗
  3. Bates D, Maechler M, Bolker B, Walker S (2015). lme4: Linear Mixed-Effects Models Using Eigen and S4. R package version 1.1-10, URL http://CRAN.R-project.org/package= lme4. ↗
  4. Bates D, Mullen KM, Nash JC, Varadhan R (2014). minqa: Derivative-Free Optimization Algorithms by Quadratic Approximation. R package version 1.2.4, URL http://CRAN. R-project.org/package=minqa. find
  5. Bates D, Walker S (2013). lme4pureR: lme4 in Pure R. R package version 0.1-0, URL https://github.com/lme4/lme4pureR. ↗
  6. Bates DM, DebRoy S (2004). “Linear Mixed Models and Penalized Least Squares.” Journal of Multivariate Analysis, 91(1), 1–17. doi:10.1016/j.jmva.2004.04.013. — [doi:10.1016/j.jmva.2004.04.013](https://doi.org/10.1016/j.jmva.2004.04.013) find
  7. Bates DM, Watts DG (1988). Nonlinear Regression Analysis and Its Applications. John Wiley & Sons, Hoboken, NJ. doi:10.1002/9780470316757. — [doi:10.1002/9780470316757](https://doi.org/10.1002/9780470316757) find
  8. Belenky G, Wesensten NJ, Thorne DR, Thomas ML, Sing HC, Redmond DP, Russo MB, Balkin TJ (2003). “Patterns of Performance Degradation and Restoration During Sleep Restriction and Subsequent Recovery: A Sleep Dose-Response Study.” Journal of Sleep Research, 12(1), 1–12. doi:10.1046/j.1365-2869.2003.00… — [doi:10.1046/j.1365-2869.2003.00337.x](https://doi.org/10.1046/j.1365-2869.2003.00337.x) find
  9. Bezanson J, Karpinski S, Shah VB, Edelman A (2012). “Julia: A Fast Dynamic Language for Technical Computing.” arXiv:1209.5145 [cs.PL], URL http://arxiv.org/abs/1209.5145. — [arXiv:1209.5145](https://arxiv.org/abs/1209.5145) ↗
  10. Bolker BM, Gardner B, Maunder M, Berg CW, Brooks M, Comita L, Crone E, Cubaynes S, Davies T, de Valpine P, Ford J, Gimenez O, Kéry M, Kim EJ, Lennert-Cody C, Magnusson A, Martell S, Nash J, Nielsen A, Regetz J, Skaug H, Zipkin E (2013). “Strategies for Fitting Nonlinear Ecological Models in R, AD Mo… — [doi:10.1111/2041-210x.12044](https://doi.org/10.1111/2041-210x.12044) find
  11. Canty A, Ripley B (2015). boot: Bootstrap R (S-PLUS) Functions. R package version 1.3-17, URL http://CRAN.R-project.org/package=boot. ↗
  12. Chambers JM (1993). “Linear Models.” In JM Chambers, TJ Hastie (eds.), Statistical Models in S, chapter 4, pp. 95–144. Chapman & Hall. find
  13. Chen Y, Davis TA, Hager WW, Rajamanickam S (2008). “Algorithm 887: CHOLMOD, Supernodal Sparse Cholesky Factorization and Update/Downdate.” ACM Transactions on Mathematical Software, 35(3), 22:1–22:14. doi:10.1145/1391989.1391995. — [doi:10.1145/1391989.1391995](https://doi.org/10.1145/1391989.1391995) find
  14. Chung Y, Rabe-Hesketh S, Dorie V, Gelman A, Liu J (2013). “A Nondegenerate Penalized Likelihood Estimator for Variance Parameters in Multilevel Models.” Psychometrika, 78(4), 685–709. find
  15. Cook RD, Weisberg S (1982). Residuals and Influence in Regression. Chapman and Hall, New York. find
  16. Davis T (2006). Direct Methods for Sparse Linear Systems. SIAM, Philadelphia, PA. doi: 10.1137/1.9780898718881. — [doi:10.1137/1.9780898718881](https://doi.org/10.1137/1.9780898718881) find
  17. Davis TA, et al. (2015). SuiteSparse: A Suite of Sparse Matrix Software. Version 4.4-5, URL http://www.suitesparse.com/. ↗
  18. Davison AC, Hinkley DV (1997). Bootstrap Methods and Their Applications. Cambridge University Press, Cambridge, England. find
  19. Doran H, Bates D, Bliese P, Dowling M (2007). “Estimating the Multilevel Rasch Model: With the lme4 Package.” Journal of Statistical Software, 20(2), 1–18. doi:10.18637/jss. v020.i02. — [doi:10.18637/jss](https://doi.org/10.18637/jss) find
  20. Dorie V (2015). blme: Bayesian Linear Mixed-Effects Models. R package version 1.0-4, URL http://CRAN.R-project.org/package=blme. ↗
  21. Efron B, Morris C (1977). “Stein’s Paradox in Statistics.” Scientific American, 236, 119–127. doi:10.1038/scientificamerican0577-119. — [doi:10.1038/scientificamerican0577-119](https://doi.org/10.1038/scientificamerican0577-119) find
  22. Gelman A (2005). “Analysis of Variance – Why It Is More Important than Ever.” The Annals of Statistics, 33(1), 1–53. doi:10.1214/009053604000001048. — [doi:10.1214/009053604000001048](https://doi.org/10.1214/009053604000001048) find
  23. Gelman A, Carlin JB, Stern HS, Dunson DB, Vehtari A, Rubin DB (2013). Bayesian Data Analysis. CRC Press. find
  24. Gelman A, Hill J (2006). Data Analysis Using Regression and Multilevel/Hierarchical Models. Cambridge University Press, Cambridge, England. find
  25. Golub GH, Pereyra V (1973). “The Differentiation of Pseudo-Inverses and Nonlinear Least Squares Problems Whose Variables Separate.” SIAM Journal on Numerical Analysis, 10(2), 413–432. doi:10.1137/0710036. — [doi:10.1137/0710036](https://doi.org/10.1137/0710036) find
  26. Guennebaud G, Jacob B, and others (2015). Eigen3. URL http://eigen.tuxfamily.org/. ↗
  27. Henderson Jr CR (1982). “Analysis of Covariance in the Mixed Model: Higher-Level, Nonho-mogeneous, and Random Regressions.” Biometrics, 38(3), 623–640. doi:10.2307/2530044. — [doi:10.2307/2530044](https://doi.org/10.2307/2530044) find
  28. Horn RA, Zhang F (2005). “Basic Properties of the Schur Complement.” In F Zhang (ed.), The Schur Complement and Its Applications, volume 4 of Numerical Methods and Algorithms, pp. 17–46. Springer-Verlag. doi:10.1007/0-387-24273-2\_2. — [doi:10.1007/0-387-24273-2\_2](https://doi.org/10.1007/0-387-24273-2_2) find
  29. Johnson SG (2014). “The NLopt Nonlinear-Optimization Package.” ab-initio.mit.edu/nlopt. find
  30. Kenward MG, Roger JH (1997). “Small Sample Inference for Fixed Effects from Restricted Maximum Likelihood.” Biometrics, 53(3), 983–997. doi:10.2307/2533558. — [doi:10.2307/2533558](https://doi.org/10.2307/2533558) find
  31. Khatri CG, Rao CR (1968). “Solutions to Some Functional Equations and Their Applications to Characterization of Probability Distributions.” Sankhyā: The Indian Journal of Statistics A, 30(2), 167–180. find
  32. Klein K, Neira J (2013). “Nelder-Mead Simplex Optimization Routine for Large-Scale Problems: A Distributed Memory Implementation.” Computational Economics, 43(4), 447–461. doi:10.1007/s10614-013-9377-8. — [doi:10.1007/s10614-013-9377-8](https://doi.org/10.1007/s10614-013-9377-8) find
  33. Laird NM, Ware JH (1982). “Random-Effects Models for Longitudinal Data.” Biometrics, 38(4), 963–974. doi:10.2307/2529876. — [doi:10.2307/2529876](https://doi.org/10.2307/2529876) find
  34. Loy A, Hofmann H (2014). “HLMdiag: A Suite of Diagnostics for Hierarchical Linear Models in R.” Journal of Statistical Software, 56(5), 1–28. doi:10.18637/jss.v056.i05. — [doi:10.18637/jss.v056.i05](https://doi.org/10.18637/jss.v056.i05) find
  35. Nash JC, Varadhan R (2011). “Unifying Optimization Algorithms to Aid Software System Users: optimx for R.” Journal of Statistical Software, 43(9), 1–14. doi:10.18637/jss. v043.i09. — [doi:10.18637/jss](https://doi.org/10.18637/jss) find
  36. Nieuwenhuis R, Te Grotenhuis M, Pelzer B (2012). “Influence.ME: Tools for Detecting Influential Data in Mixed Effects Models.” The R Journal, 4(2), 38–47. find
  37. Pinheiro J, Bates D, DebRoy S, Sarkar D, R Core Team (2015). nlme: Linear and Nonlinear Mixed Effects Models. R package version 3.1-122, URL http://CRAN.R-project.org/ package=nlme. ↗
  38. Pinheiro JC, Bates DM (1996). “Unconstrained Parametrizations for Variance-Covariance Matrices.” Statistics and Computing, 6(3), 289–296. doi:10.1007/bf00140873. — [doi:10.1007/bf00140873](https://doi.org/10.1007/bf00140873) find
  39. Pinheiro JC, Bates DM (2000). Mixed-Effects Models in S and S-PLUS. Springer-Verlag. find
  40. Powell MJD (2009). “The BOBYQA Algorithm for Bound Constrained Optimization Without Derivatives.” Technical Report DAMTP 2009/NA06, Centre for Mathematical Sciences, University of Cambridge, Cambridge, England. URL http://www.damtp.cam.ac. uk/user/na/NA\_papers/NA2009\_06.pdf. ↗
  41. R Core Team (2015). R: A Language and Environment for Statistical Computing. R Foundation for Statistical Computing, Vienna, Austria. URL http://www.R-project.org/. ↗
  42. Sánchez-Espigares JA, Ocaña J (2009). “An R Implementation of Bootstrap Procedures for Mixed Models.” Conference presentation, useR! Accessed 2014-05-25, URL http://www. R-project.org/conferences/useR-2009/slides/SanchezEspigares+Ocana.pdf. find
  43. Sarkar D (2008). lattice: Multivariate Data Visualization with R. Springer-Verlag, New York. URL http://lmdvr.R-Forge.R-project.org. ↗
  44. Satterthwaite FE (1946). “An Approximate Distribution of Estimates of Variance Components.” Biometrics Bulletin, 2(6), 110–114. doi:10.2307/3002019. — [doi:10.2307/3002019](https://doi.org/10.2307/3002019) find
  45. Vaida F, Blanchard S (2005). “Conditional Akaike Information for Mixed-Effects Models.” Biometrika, 92(2), 351–370. doi:10.1093/biomet/92.2.351. — [doi:10.1093/biomet/92.2.351](https://doi.org/10.1093/biomet/92.2.351) find
  46. Wood S, Scheipl F (2014). gamm4: Generalized Additive Mixed Models Using mgcv and lme4. R package version 0.2-3, URL http://CRAN.R-project.org/package=gamm4. ↗