lmer(formula, data = NULL, REML = TRUE,
control = lmerControl(), start = NULL, verbose = 0L,
subset, weights, na.action, offset, contrasts = NULL,
devFunOnly = FALSE, ...)
~
operator and the terms, separated by +
operators,
on the right. Random-effectsformula
. By default the
variables are taken from the environment from which
lmer
is called. While data
is optional, the
package authors stronglylmerControl()
or glmerControl()
respectively) containing control parameters, including the nonlinealist
of starting values for the
parameters in the model. For lmer
this can be a numeric
vector or a list with one component named "theta"
.> 0
verbose
output is generated during the optimization of the
parameter estimates. If > 1
verbose output is
generated during the individual PIRLS steps.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 rNULL
or a numeric vector.NA
s. The default
action (na.omit
, inherited from the 'factory
fresh' value of getOption("na.action")
) strips any
observations with any missiNULL
or a
numeric vector of length equal to the number of cases.
One or more
contrasts.arg
of model.matrix.default
.method
argument was used in earlier versions of the package. Its
functionality has been replaced by the REML
argument.merMod
, for which many methods
are available (e.g. methods(class="merMod")
)formula
argument is
specified as a character vector, the function will
attempt to coerce it to a formula. However, this is not
recommended (users who want to construct formulas by
pasting together components are advised to useas.formula
orreformulate
);
model fits will work but subsequent methods such asdrop1
,update
may fail.lm
and glm
which
automatically detect perfectly collinear predictor
variables, [gn]lmer
cannot handle design matrices
of less than full rank. For example, in cases of models
with interactions that have unobserved combinations of
levels, it is up to the user to define a new variable
(for example creating ab
within the data from the
results of interaction(a,b,drop=TRUE)
).devFunOnly
is TRUE
takes a single numeric
vector argument, representing the theta
vector.
This vector defines the scaled variance-covariance
matrices of the random effects, in the Cholesky
parameterization. For models with only simple
(intercept-only) random effects, theta
is a vector
of the standard deviations of the random effects. For
more complex or multiple random effects, running
getME(.,"theta")
to retrieve the theta
vector for a fitted model and examining the names of the
vector is probably the easiest way to determine the
correspondence between the elements of the theta
vector and elements of the lower triangles of the
Cholesky factors of the random effects.lm
## linear mixed models - reference values from older code
(fm1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy))
summary(fm1)# (with its own print method)
fm1_ML <- update(fm1,REML=FALSE)
(fm2 <- lmer(Reaction ~ Days + (1|Subject) + (0+Days|Subject), sleepstudy))
anova(fm1, fm2)
sm2 <- summary(fm2)
print(fm2, digits=7, ranef.comp="Var") # the print.merMod() method
print(sm2, digits=3, corr=FALSE) # the print.summary.merMod() method
Run the code above in your browser using DataCamp Workspace