getME {robustlmm}R Documentation

Extract or Get Generalize Components from a Fitted Mixed Effects Model

Description

Extract (or “get”) “components” – in a generalized sense – from a fitted mixed-effects model, i.e. from an object of class rlmerMod or merMod.

Usage

## S3 method for class 'rlmerMod'
getME(
  object,
  name = c("X", "Z", "Zt", "Ztlist", "mmList", "y", "mu", "u", "b.s", "b", "Gp", "Tp",
    "Lambda", "Lambdat", "Tlist", "A", "U_b", "Lind", "sigma", "flist", "fixef", "beta",
    "theta", "ST", "is_REML", "n_rtrms", "n_rfacs", "N", "n", "p", "q", "p_i", "l_i",
    "q_i", "k", "m_i", "m", "cnms", "devcomp", "offset", "lower", "rho_e", "rho_b",
    "rho_sigma_e", "rho_sigma_b", "M", "w_e", "w_b", "w_b_vector", "w_sigma_e",
    "w_sigma_b", "w_sigma_b_vector"),
  ...
)

theta(object)

Arguments

object

a fitted mixed-effects model of class rlmerMod, i.e. typically the result of rlmer().

name

a character string specifying the name of the “component”. Possible values are:

"X":

fixed-effects model matrix

"Z":

random-effects model matrix

"Zt":

transpose of random-effects model matrix

"Ztlist":

list of components of the transpose of the random-effects model matrix, separated by individual variance component

"mmList":

list of raw model matrices associated with random effects terms

"y":

response vector

"mu":

conditional mean of the response

"u":

conditional mode of the “spherical” random effects variable

"b.s":

synonym for “u”

"b":

conditional mode of the random effects variable

"Gp":

groups pointer vector. A pointer to the beginning of each group of random effects corresponding to the random-effects terms.

"Tp":

theta pointer vector. A pointer to the beginning of the theta sub-vectors corresponding to the random-effects terms, beginning with 0 and including a final element giving the total number of random effects

"Lambda":

relative covariance factor of the random effects.

"U_b":

synonym for “Lambda”

"Lambdat":

transpose of the relative covariance factor of the random effects.

"Lind":

index vector for inserting elements of \theta into the nonzeros of \Lambda

"A":

Scaled sparse model matrix (class dgCMatrix) for the unit, orthogonal random effects, U, equal to getME(.,"Zt") %*% getME(.,"Lambdat")

"sigma":

residual standard error

"flist":

a list of the grouping variables (factors) involved in the random effect terms

"fixef":

fixed-effects parameter estimates

"beta":

fixed-effects parameter estimates (identical to the result of fixef, but without names)

"theta":

random-effects parameter estimates: these are parameterized as the relative Cholesky factors of each random effect term

"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.

"is_REML":

returns TRUE for rlmerMod-objects (for compatibility with lme4)

"n_rtrms":

number of random-effects terms

"n_rfacs":

number of distinct random-effects grouping factors

"N":

number of rows of X

"n":

length of the response vector, y

"p":

number of columns of the fixed effects model matrix, X

"q":

number of columns of the random effects model matrix, Z

"p_i":

numbers of columns of the raw model matrices, mmList

"l_i":

numbers of levels of the grouping factors

"q_i":

numbers of columns of the term-wise model matrices, ZtList

"k":

number of random effects terms

"m_i":

numbers of covariance parameters in each term

"m":

total number of covariance parameters, i.e., the same as dim@nth below.

"cnms":

the “component names”, a ‘list’.

"devcomp":

a list consisting of a named numeric vector, cmp, and a named integer vector, dims, describing the fitted model. The elements of cmp are:

ldL2

always NA, for consistency with lme4 output

ldRX2

always NA, for consistency with lme4 output

wrss

always NA, for consistency with lme4 output

ussq

always NA, for consistency with lme4 output

pwrss

always NA, for consistency with lme4 output

drsum

always NA, for consistency with lme4 output

REML

always NA, for consistency with lme4 output

dev

always NA, for consistency with lme4 output

sigmaML

always NA, for consistency with lme4 output

sigmaREML

REML estimate of residual standard deviation

The elements of dims are:

N

number of rows of X

n

length of y

p

number of columns of X

nmp

n-p

nth

length of theta

q

number of columns of Z

nAGQ

see glmer

compDev

see glmerControl

useSc

TRUE if model has a scale parameter

reTrms

number of random effects terms

REML

0 indicates the model was fitted by maximum likelihood, any other positive integer indicates fitting by restricted maximum likelihood

GLMM

TRUE if a GLMM

NLMM

TRUE if an NLMM

"offset":

model offset

"lower":

lower bounds on random-effects model parameters (i.e, "theta" parameters). In order to constrain random effects covariance matrices to be semi-positive-definite, this vector is equal to 0 for elements of the theta vector corresponding to diagonal elements of the Cholesky factor, -Inf otherwise. (getME(.,"lower")==0 can be used as a test to identify diagonal elements, as in isSingular.)

"rho_e":

rho function used for the residuals

"rho_b":

list of rho functions used for the random effects

"rho_sigma_e":

rho function used for the residuals when estimating sigma

"rho_sigma_b":

list of rho functions used for the random effects when estimating the covariance parameters

"M":

list of matrices, blocks of the Henderson's equations and the matrices used for computing the linear approximations of the estimates of beta and spherical random effects.

"w_e":

robustness weights associated with the observations

"w_b":

robustness weights associated with the spherical random effects, returned in the same format as ranef()

"w_b_vector":

robustness weights associated with the spherical random effects, returned as one long vector

"w_sigma_e":

robustness weights associated with the observations when estimating sigma

"w_sigma_b":

robustness weights associated with the spherical random effects when estimating the covariance parameters, returned in the same format as ranef()

"w_sigma_b_vector":

robustness weights associated with the spherical random effects when estimating the covariance parameters, returned as one long vector

"ALL":

get all of the above as a list.

...

potentially further arguments; not here.

Details

The function theta is short for getME(, "theta").

The goal is to provide “everything a user may want” from a fitted rlmerMod object as far as it is not available by methods, such as fixef, ranef, vcov, etc.

Value

Unspecified, as very much depending on the name.

See Also

getCall(); more standard methods for rlmerMod objects, such as ranef, fixef, vcov, etc.: see methods(class="rlmerMod")

Examples

## shows many methods you should consider *before* using getME():
methods(class = "rlmerMod")

## doFit = FALSE to speed up example
(fm1 <- rlmer(Reaction ~ Days + (Days|Subject), sleepstudy,
              method="DASvar", doFit=FALSE))
Z <- getME(fm1, "Z")
stopifnot(is(Z, "CsparseMatrix"),
          c(180,36) == dim(Z),
	  all.equal(fixef(fm1), b1 <- getME(fm1, "beta"),
		    check.attributes=FALSE, tolerance = 0))

## A way to get *all* getME()s :
## internal consistency check ensuring that all work:
parts <- getME(fm1, "ALL")
str(parts, max=2)
stopifnot(identical(Z,  parts $ Z),
          identical(b1, parts $ beta))
stopifnot(all.equal(theta(fm1), getME(fm1, "theta")))

[Package robustlmm version 3.3-1 Index]