Fit (Generalized) Linear Mixed-Effects Models
Fit a linear or generalized linear mixed-effects model with nested or crossed grouping factors for the random effects.
lmer(formula, data, family, method, control, start, subset, weights, na.action, offset, contrasts, model, ...) lmer2(formula, data, family, method, control, start, subset, weights, na.action, offset, contrasts, model, ...)
- a two-sided linear formula object describing the
fixed-effects part of the model, with the response on the left of a
~operator and the terms, separated by
+operators, on the right. The vertical bar character
- an optional data frame containing the variables named in
formula. By default the variables are taken from the environment from which
- a GLM family, see
familyis missing then a linear mixed model is fit; otherwise a generalized linear mixed model is fit.
- a character string. For a linear mixed model the
"REML"indicating that the model should be fit by maximizing the restricted log-likelihood. The alternative is
"ML"indicating that the log-likelihood shou
- a list of control parameters. See below for details.
- a list of relative precision matrices for the random
effects. This has the same form as the slot
"Omega"in a fitted model. Only the upper triangle of these symmetric matrices should be stored.
- subset, weights, na.action, offset, contrasts
- further model
specification arguments as in
lm; see there for details.
- logical indicating if the model component
should be returned (in slot
- potentially further arguments for methods. Currently none are used.
This is a revised version of the
lme function from the
lmer2 function is a development version of
uses a modified internal representation of the model. Typically
lmer2 is faster and more reliable than
lmer. At present
lmer2 can only fit linear mixed-effects models (that is, the
family argument must be left unspecified) and not all the
"lmer" objects are defined for
objects. In particular, there is no
mcmcsamp method for
When all the methods for the
"lmer" objects and all the options
lmer function have been duplicated for the new
representation, the new representation will replace the old one and
"2" will be dropped from the name.
Additional standard arguments to model-fitting functions can be passed
[object Object],[object Object],[object Object],[object Object]
- An object of class
". There are many methods applicable to
"lmer"objects, see the above help page.
(fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy)) (fm2 <- lmer(Reaction ~ Days + (1|Subject) + (0+Days|Subject), sleepstudy)) anova(fm1, fm2)