mer-class {lme4}R Documentation

Mixed Model Representations and *mer Methods

Description

The mer class represents linear or generalized linear or nonlinear mixed-effects models. It incorporates sparse model matrices for the random effects and corresponding sparse Cholesky factors. The summary.mer class represents the summary of these objects.

Usage

## Methods with "surprising" arguments
## S4 method for signature 'mer':
deviance(object, REML = NULL, ...)
## S4 method for signature 'mer':
expand(x, sparse = TRUE, ...)
## S4 method for signature 'mer':
logLik(object, REML = NULL, ...)
## S4 method for signature 'mer':
print(x, digits, correlation, symbolic.cor, signif.stars, ...)

Arguments

object object of class mer.
REML logical indicating if REML should be used. A value of NULL, the default, or NA indicates that the REML values should be returned if the model was fit by REML, otherwise the ML values.
x object of class mer to expand.
sparse logical scalar indicating if the sparse form of the expanded T and S matrices should be returned.
digits number of digits to use when printing tables of parameter estimates. Defaults to max(3, getOption("digits") - 3).
correlation logical - should the correlation matrix of the fixed-effects parameter estimates be printed? Defaults to TRUE.
symbolic.cor logical - should a symbolic form of the correlation matrix be printed instead of the numeric form? Defaults to FALSE.
signif.stars logical - should the ‘significance stars’ be printed as part of the table of fixed-effects parameter estimates? Defaults to getOption("show.signif.stars").
... potential further arguments passed to methods.

Objects from the Class

Objects can be created by calls of the form new("mer", ...) or, more commonly, via the lmer, glmer or nlmer functions.

Slots

The class "mer" represents a linear or generalized linear or nonlinear or generalized nonlinear mixed model and contains the slots:

env:
An environment (class "environment") created for the evaluation of the nonlinear model function. Not used except by nlmer models.
nlmodel:
The nonlinear model function as an object of class "call". Not used except by nlmer models.
frame:
The model frame (class "data.frame").
call:
The matched call to the function that created the object. (class "call").
flist:
The list of grouping factors for the random effects.
X:
Model matrix for the fixed effects. In an nlmer fitted model this matrix has n * s rows where n is the number of observations and s is the number of parameters in the nonlinear model.
Zt:
The transpose of model matrix for the random effects, stored as a compressed column-oriented sparse matrix (class "dgCMatrix").
pWt:
Numeric prior weights vector. This may be of length zero (0), indicating unit prior weights.
offset:
Numeric offset vector. This may be of length zero (0), indicating no offset.
y:
The response vector (class "numeric").
Gp:
Integer vector of group pointers within the random effects vector. The elements of Gp are 0-based indices of the first element from each random-effects term. Thus the first element is always 0. The last element is the total length of the random effects vector.
dims:
A named integer vector of dimensions. Some of the dimensions are n, the number of observations, p, the number of fixed effects, q, the total number of random effects, s, the number of parameters in the nonlinear model function and nf, the number of random-effects terms in the model.
ST:
A list of S and T factors in the TSST' Cholesky factorization of the relative variance matrices of the random effects associated with each random-effects term. The unit lower triangular matrix, T, and the diagonal matrix, S, for each term are stored as a single matrix with diagonal elements from S and off-diagonal elements from T.
V:
Numeric gradient matrix (class "matrix") of the nonlinear model function. Not used except by nlmer models.
A:
Scaled sparse model matrix (class "dgCMatrix") for the the unit, orthogonal random effects, U.
Cm:
Reduced, weighted sparse model matrix (class "dgCMatrix") for the unit, orthogonal random effects, U. Not used except by nlmer models.
Cx:
The "x" slot in the weighted sparse model matrix (class "dgCMatrix") for the unit, orthogonal random effects, U, in generalized linear mixed models. For these models the matrices A and C have the same sparsity pattern and only the "x" slot of C needs to be stored.
L:
The sparse lower Cholesky factor of P(AA'+I)P' (class "dCHMfactor") where P is the fill-reducing permutation calculated from the pattern of nonzeros in A.
deviance:
Named numeric vector containing the deviance corresponding to the maximum likelihood (the "ML" element) and "REML" criteria and various components. The "ldL2" element is twice the logarithm of the determinant of the Cholesky factor in the L slot. The "usqr" component is the value of the random-effects quadratic form.
fixef:
Numeric vector of fixed effects.
ranef:
Numeric vector of random effects on the original scale.
u:
Numeric vector of orthogonal, constant variance, random effects.
eta:
The linear predictor at the current values of the parameters and the random effects.
mu:
The means of the responses at the current parameter values.
muEta:
The diagonal of the Jacobian of mu by eta. Has length zero (0) except for generalized mixed models.
var:
The diagonal of the conditional variance of Y given the random effects, up to prior weights. In generalized mixed models this is the value of the variance function for the glm family.
resid:
The residuals, y-mu, weighted by the sqrtrWt slot (when its length is >0).
sqrtXWt:
The square root of the weights applied to the model matrices X and Z. This may be of length zero (0), indicating unit weights.
sqrtrWt:
The square root of the weights applied to the residuals to obtain the weighted residual sum of squares. This may be of length zero (0), indicating unit weights.
RZX:
The dense solution (class "matrix") to L RZX = ST'Z'X = AX.
RX:
The upper Cholesky factor (class "matrix") of the downdated X'X.

The "summary.mer" class contains the "mer", class and has additional slots,

methTitle:
character string specifying a method title
logLik:
the same as logLik(object).
ngrps:
the number of levels per grouping factor in the flist slot.
sigma:
the scale factor for the variance-covariance estimates
coefs:
the matrix of estimates, standard errors, etc. for the fixed-effects coefficients
vcov:
the same as vcov(object).
REmat:
the formatted Random-Effects matrix
AICtab:
A named vector of values of AIC, BIC, log-likelihood and deviance

Methods

VarCorr
signature(x = "mer"): Extract variance and correlation components. See VarCorr
anova
signature(object = "mer"): returns the sequential decomposition of the contributions of fixed-effects terms or, for multiple arguments, model comparison statistics. See anova.
coef
signature(object = "mer"): returns an object similar to the ranef method but incorporating the fixed-effects parameters, thereby forming a table of linear model coefficients (the columns) by level of the grouping factor (the rows).
coerce
signature(from = "mer", to = "dtCMatrix"): returns the L slot as a "dtCMatrix" (column-oriented, sparse, triangular matrix) object.
deviance
signature(object = "mer"): returns the deviance of the fitted model, or the “REML deviance” (i.e. negative twice the REML criterion), according to the REML argument. See the arguments section above for a description of the REML argument.
expand
signature(object = "mer"):

returns a list of terms in the expansion of the ST slot. If sparse is TRUE, the default, the elements of the list are the numeric scalar "sigma", the REML or ML estimate of the standard deviation in the model, and three sparse matrices: "P", the permutation matrix, "S", the diagonal scale matrix and "T", the lower triangular matrix determining correlations. When sparse is FALSE each element of the list is the expansions of the corresponding element of the ST slot into a list of S, the diagonal matrix, and T, the (dense) unit lower triangular matrix.

fitted
signature(object = "mer"):

returns the fitted conditional means of the responses. See fitted. The napredict function is called to align the result with the original data if the model was fit with na.action = na.exclude.

fixef
signature(object = "mer"):

returns the estimates of the fixed-effects parameters. See fixef.

formula
signature(x = "mer"):

returns the model formula. See formula.

logLik
signature(object = "mer"):

returns the log-likelihood or the REML criterion, according to the optional REML argument (see the arguments section above), of the fitted model. See also logLik.

mcmcsamp
signature(object = "mer"):

Create a Markov chain Monte Carlo sample from a posterior distribution of the model's parameters. See mcmcsamp for details.

model.frame
signature(formula = "mer"): returns the model frame (the frame slot).
model.matrix
signature(object = "mer"): returns the model matrix for the fixed-effects parameters (the X slot).
print
signature(x = "mer"): print information about the fitted model. See the arguments section above for a description of optional arguments.
ranef
signature(object = "mer"): returns the conditional modes of the random effects. See ranef.
refit
signature(object = "mer", newresp = "numeric"): Update the response vector only and refit the model. See refit.
resid
signature(object = "mer"): returns the (raw) residuals. This method calls napredict. See the above description of the fitted method for details. See also resid.
residuals
signature(object = "mer"): Another name for the resid method.
show
signature(object = "mer"): Same as the print method without the optional arguments.
simulate
signature(object = "mer"): simulate nsim (defaults to 1) responses from the theoretical distribution corresponding to the fitted model. The refit method is particularly useful in combination with this method. See also simulate.
terms
signature(x = "mer"): Extract the terms object for the fixed-effects terms in the model formula.
update
signature(object = "mer"): see update on how to update fitted models.
vcov
signature(object = "mer"): Calculate variance-covariance matrix of the fixed effect terms, see also vcov.
with
signature(data = "mer"): Evaluate an R expression in an environment constructed from the frame slot.

See Also

lmer(), glmer() and nlmer(), which produce these objects.
VarCorr for extracting the variance and correlation components of the random-effects terms.

Examples

(fm2 <- lmer(Reaction ~ Days + (1|Subject) + (0+Days|Subject),
             data = sleepstudy))
print(fm2, digits = 10, corr = FALSE) # more precision; no corr.matrix

logLik(fm2)
(V2 <- vcov(fm2))
terms(fm2)
str(model.matrix(fm2))
str(model.frame(fm2))
str(resid(fm2))

VarCorr(fm2)
ee <- expand(fm2)
op <- options(digits = 3)
tcrossprod(ee$sigma * ee$P %*% ee$T %*% ee$S)
options(op)

## Not run: 
## Simulate 'Reaction' according to the fitted model:
dim(ss <- simulate(fm2, nsim = 200, seed = 101)) ## -> 180 x 200
## End(Not run)


[Package lme4 version 0.999375-20 Index]