Learn R Programming

lme4 (version 1.1-26)

lme4-package: Linear, generalized linear, and nonlinear mixed models

Description

lme4 provides functions for fitting and analyzing mixed models: linear (lmer), generalized linear (glmer) and nonlinear (nlmer.)

Arguments

Differences between <span class="pkg">nlme</span> and <span class="pkg">lme4</span>

lme4 covers approximately the same ground as the earlier nlme package. The most important differences are:

  • lme4 uses modern, efficient linear algebra methods as implemented in the Eigen package, and uses reference classes to avoid undue copying of large objects; it is therefore likely to be faster and more memory-efficient than nlme.

  • lme4 includes generalized linear mixed model (GLMM) capabilities, via the glmer function.

  • lme4 does not currently implement nlme's features for modeling heteroscedasticity and correlation of residuals.

  • lme4 does not currently offer the same flexibility as nlme for composing complex variance-covariance structures, but it does implement crossed random effects in a way that is both easier for the user and much faster.

  • lme4 offers built-in facilities for likelihood profiling and parametric bootstrapping.

  • lme4 is designed to be more modular than nlme, making it easier for downstream package developers and end-users to re-use its components for extensions of the basic mixed model framework. It also allows more flexibility for specifying different functions for optimizing over the random-effects variance-covariance parameters.

  • lme4 is not (yet) as well-documented as nlme.

Differences between current (1.0.+) and previous versions of <span class="pkg">lme4</span>

  • [gn]lmer now produces objects of class '>merMod rather than class mer as before

  • the new version uses a combination of S3 and reference classes (see ReferenceClasses, merPredD-class, and lmResp-class) as well as S4 classes; partly for this reason it is more interoperable with nlme

  • The internal structure of [gn]lmer is now more modular, allowing finer control of the different steps of argument checking; construction of design matrices and data structures; parameter estimation; and construction of the final merMod object (see modular)

  • profiling and parametric bootstrapping are new in the current version

  • the new version of lme4 does not provide an mcmcsamp (post-hoc MCMC sampling) method, because this was deemed to be unreliable. Alternatives for computing p-values include parametric bootstrapping (bootMer) or methods implemented in the pbkrtest package and leveraged by the lmerTest package and the Anova function in the car package (see pvalues for more details).

Caveats and trouble-shooting

  • Some users who have previously installed versions of the RcppEigen and minqa packages may encounter segmentation faults (!!); the solution is to make sure to re-install these packages before installing lme4. (Because the problem is not with the explicit version of the packages, but with running packages that were built with different versions of Rcpp in conjunction with each other, simply making sure you have the latest version, or using update.packages, will not necessarily solve the problem; you must actually re-install the packages. The problem is most likely with minqa.)