lmer {lme4} | R Documentation |
This generic function fits a linear mixed-effects model with nested or crossed grouping factors for the random effects.
lmer(formula, data, family, method = c("REML", "ML", "PQL", "Laplace", "AGQ"),...)
formula |
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 "|" separates an
expression for a model matrix and a grouping factor. |
data |
an optional data frame containing the variables named in
formula . By default the variables are taken from the
environment from which lmer is called. |
family |
a GLM family, see glm . If family is
missing then a linear mixed model is fit; otherwise a generalized
linear mixed model is fit. |
method |
a character string. For a linear mixed model the
default is "REML" indicating that the model should be fit by
maximizing the restricted log-likelihood. The alternative is
"ML" indicating that the log-likelihood should be
maximized. (This method is sometimes called "full" maximum
likelihood.) For a generalized linear mixed model the criterion
is always the log-likelihood but this criterion does not have a
closed form expression and must be approximated. The default approximation is
"PQL" or penalized quasi-likelihood. Alternatives are
"Laplace" or "AGQ" indicating the Laplacian and
adaptive Gaussian quadrature approximations respectively. The
"PQL" method is fastest but least accurate. The
"Laplace" method is intermediate in speed and accuracy.
The "AGQ" method is the most accurate but can be
considerably slower than the others. |
... |
Optional arguments for methods. Currently none are used. |
This is a revised version of the lme
function from the
nlme
package. This version uses a different method of
specifying random-effects terms and allows for fitting generalized
linear mixed models as well as linear mixed models.
Additional standard arguments to model-fitting functions can be passed
to lmer
.
data
that should be used in the fit. This can be a logical
vector, or a numeric vector indicating which observation numbers are
to be included, or a character vector of the row names to be
included. All observations are included by default.NA
s. The default action (na.fail
) causes
lme
to print an error message and terminate if there are any
incomplete observations.lmerControl
.
Defaults to an empty list.TRUE
the corresponding
components of the fit (the model frame, the model matrices)
are returned.
An lme-class{lmer}
object.
(fm1 <- lmer(decrease ~ treatment + (1|rowpos) + (1|colpos), OrchardSprays))