This function overloads lmer from the lme4-package
(lme4::lmer) and adds a couple of slots needed for the computation of
Satterthwaite denominator degrees of freedom. All arguments are the same as
for lme4::lmer and all the usual lmer-methods work.
Usage
lmer(
formula,
data = NULL,
REML = TRUE,
control = lmerControl(),
start = NULL,
verbose = 0L,
subset,
weights,
na.action,
offset,
contrasts = NULL,
devFunOnly = FALSE
)Arguments
- formula
a two-sided linear formula object describing both the fixed-effects and random-effects part of the model, with the response on the left of a
~operator and the terms, separated by+operators, on the right. Random-effects terms are distinguished by vertical bars (|) separating expressions for design matrices from grouping factors. By default, non-scalar random effects (where the design matrix has more than one column, e.g.(1+x|f)) are fitted with unstructured (general positive semidefinite) covariance matrices.Two vertical bars (
||) can be used to specify multiple uncorrelated random effects for the same grouping variable. With default settings, the||-syntax works only for design matrices containing numeric (continuous) predictors; to fit models with independent categorical effects, usediag(f|g)or setoptions(lme4.doublevert.default = "diag_special")(seehelp(getDoublevertDefault)in lme4 version2.0-0or higher).Tags preceding a random effect term specify covariance structure:
us(default:us(f|g)is equivalent to(f|g)): unstructured, positive semi-definitediag: diagonal (all correlations set to zero). Specifydiag(f|g, hom = TRUE)to fit a homogeneous diagonal covariance matrixcs: compound symmetric (all pairwise correlations set identical). Specifycs(f|g, hom = TRUE)for homogeneous variances.ar1: autoregressive order 1. Note that AR1 models are homogeneous by default; specifyar1(f|g, hom = FALSE)for heterogeneous variances.
- data
an optional data frame containing the variables named in
formula. By default the variables are taken from the environment from whichlmeris called. Whiledatais optional, the package authors strongly recommend its use, especially when later applying methods such asupdateanddrop1to the fitted model (such methods are not guaranteed to work properly ifdatais omitted). Ifdatais omitted, variables will be taken from the environment offormula(if specified as a formula) or from the parent frame (if specified as a character vector).- REML
logical scalar - Should the estimates be chosen to optimize the REML criterion (as opposed to the log-likelihood)?
- control
a list (of correct class, resulting from
lmerControl()orglmerControl()respectively) containing control parameters, including the nonlinear optimizer to be used and parameters to be passed through to the nonlinear optimizer, see the*lmerControldocumentation for details.- start
a numeric vector or a named list with one optional component named
parortheta, giving starting values for covariance parameters. Numericstartis equivalent tolist(par = start). Parameters corresponding to unstructured covariance matrices are on the scale of the Cholesky factor of the relative covariance matrix. By default, all relative covariance matrices are identity matrices.- verbose
integer scalar. If
> 0verbose output is generated during the optimization of the parameter estimates. If> 1verbose output is generated during the individual penalized iteratively reweighted least squares (PIRLS) steps.- subset
an optional expression indicating the subset of the rows of
datathat 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.- weights
an optional vector of ‘prior weights’ to be used in the fitting process. Should be
NULLor a numeric vector. Priorweightsare not normalized or standardized in any way. In particular, the diagonal of the residual covariance matrix is the squared residual standard deviation parametersigmatimes the vector of inverseweights. Therefore, if theweightshave relatively large magnitudes, then in order to compensate, thesigmaparameter will also need to have a relatively large magnitude.- na.action
a function that indicates what should happen when the data contain
NAs. The default action (na.omit, inherited from the 'factory fresh' value ofgetOption("na.action")) strips any observations with any missing values in any variables.- offset
this can be used to specify an a priori known component to be included in the linear predictor during fitting. This should be
NULLor a numeric vector of length equal to the number of cases. One or moreoffsetterms can be included in the formula instead or as well, and if more than one is specified their sum is used. Seemodel.offset.- contrasts
an optional list. See the
contrasts.argofmodel.matrix.default.- devFunOnly
logical - return only the deviance evaluation function. Note that because the deviance function operates on variables stored in its environment, it may not return exactly the same values on subsequent calls (but the results should always be within machine tolerance).
Details
For details about lmer see lmer
(help(lme4::lmer)). The description of all arguments below is taken
verbatim and unedited from the lme4-package.
In cases when a valid lmer-object
(lmerMod) is produced, but when the computations needed for
Satterthwaite df fails, the lmerMod object is returned - not an
lmerModLmerTest object.
See also
lmer and lmerModLmerTest