lme4 (version 0.999999-0)

getME: 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. (in this version of the package) from an Robject of class "mer".

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

Usage

getME(object, name)

isREML(x, ...)

isLMM(x, ...) isNLMM(x, ...) isGLMM(x, ...)

Arguments

object,x
a fitted mixed-effects model of class "mer", i.e. typically the result of lmer(), glmer() or
name
a character string specifying the name of the component. Note this may not be the name of slot of object.
...
additional, optional arguments. (None are used in the mer methods.)

Value

  • Unspecified, as very much depending on the name.

See Also

getCall() (in R>= 2.14.0; otherwise in MatrixModels).

More standard methods for *mer() objects, such as ranef, fixef, vcov, etc.

Examples

Run this code
## shows many methds you should consider *before* getME():
showMethods(class = "mer")

(fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy))
gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
              data = cbpp, family = binomial)
nm1 <- nlmer(circumference ~ SSlogis(age, Asym, xmid, scal) ~ Asym|Tree,
              Orange, start = c(Asym = 200, xmid = 725, scal = 350))

Z <- getME(fm1, "Z")
stopifnot(is(Z, "CsparseMatrix"),
          c(180,36) == dim(Z),
	  all.equal(fixef(fm1), getME(fm1, "beta"),
		    check.attr=FALSE, tol = 0))

## All that can be accessed [potentially ..]:
(nmME <- eval(formals(getME)$name))

## internal consistency check ensuring that all work:
## "try(.)" because some are not yet implemented:
str(fm.parts <- sapply(nmME, function(nm) try(getME(fm1, nm)),
                    simplify=FALSE))

str(gm.parts <- sapply(nmME, function(nm) try(getME(gm1, nm)),
                    simplify=FALSE))

str(nm.parts <- sapply(nmME, function(nm) try(getME(nm1, nm)),
                    simplify=FALSE))
isLMM(fm1)
isGLMM(gm1)
## check all :
is.MM <- function(x) c(LMM = isLMM(x), GLMM= isGLMM(x), NLMM= isNLMM(x))
stopifnot(cbind(is.MM(fm1), is.MM(gm1), is.MM(nm1))
	  == diag(rep(TRUE,3)))

Run the code above in your browser using DataCamp Workspace