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
.)Differences between <pkg>nlme</pkg> and <pkg>lme4</pkg>
lme4 covers approximately the same ground as the earlier
nlme package. The most important differences are:
- lme4uses 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 thannlme. - lme4includes generalized linear mixed model (GLMM)
capabilities, via the
glmer
function. - lme4doesnotcurrently implementnlme's
features for modeling heteroscedasticity and
correlation of residuals.
- lme4does not currently offer the same flexibility
asnlmefor 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.
- lme4offers built-in facilities for likelihood
profiling and parametric bootstrapping.
- lme4is designed to be more modular thannlme,
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.
- lme4is not (yet) as well-documented asnlme.
Differences between current (1.0.+) and previous versions of
<pkg>lme4</pkg>
[gn]lmer
now produces objects of classmerMod
rather than classmer
as before- the new version uses a combination of S3 and reference classes
(see
ReferenceClasses
,merPredD-class
, andlmResp-class
) as well as S4 classes; partly for this reason
it is more interoperable withnlme - 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 (seemodular
) - profiling and parametric bootstrapping are new in
the current version
- the new version oflme4doesnotprovide
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 thepbkrtestpackage and leveraged by thelmerTestpackage and theAnova
function in thecarpackage
(seepvalues
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
installinglme4. (Because the problem is not with the
explicitversionof the packages, but with running
packages that were built with different versions ofRcppin 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 withminqa.)