Learn R Programming

lme4 (version 1.1-7)

getME: Extract or Get Generalized 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 object of class "merMod".

Usage

getME(object,
      name = c("X", "Z", "Zt", "Ztlist", "mmList", "y", "mu", "u", "b",
               "Gp", "Tp", "L", "Lambda", "Lambdat", "Lind",
               "A", "RX", "RZX", "sigma", "flist",
               "fixef", "beta", "theta", "ST", "REML", "is_REML",
               "n_rtrms", "n_rfacs", "N", "n", "p", "q",
               "cnms", "devcomp", "offset", "lower"))

Arguments

object
a fitted mixed-effects model of class "merMod", i.e., typically the result of lmer(), glmer() or
name
a character vector specifying the name(s) of the component. If length(name)>1, a named list of components will be returned. Possible values are: [object Object],[object Object],[object Object],[object Object],[objec

Value

  • Unspecified, as very much depending on the name.

Details

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

See Also

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

Examples

Run this code
## shows many methods you should consider *before* using getME():
methods(class = "merMod")

(fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy))
Z <- getME(fm1, "Z")
stopifnot(is(Z, "CsparseMatrix"),
          c(180,36) == dim(Z),
	  all.equal(fixef(fm1), getME(fm1, "beta"),
		    check.attributes=FALSE, tolerance = 0))

## A way to get *all* getME()s :
getME.all <- function(obj) {
    sapply(eval(formals(getME)$name), getME, object=obj, simplify=FALSE)
}
## internal consistency check ensuring that all work:
parts <- getME.all(fm1)
str(parts, max=2)

Run the code above in your browser using DataLab