Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

mkReTrms

Make Random Effect Terms: Create Z, Lambda, Lind, etc.


Description

From the result of findbars applied to a model formula and the evaluation frame fr, create the model matrix Zt, etc, associated with the random-effects terms.

Usage

mkReTrms(bars, fr, drop.unused.levels=TRUE,
                     reorder.terms=TRUE,
                     reorder.vars=FALSE)

Arguments

bars

a list of parsed random-effects terms

fr

a model frame in which to evaluate these terms

drop.unused.levels

(logical) drop unused factor levels? (experimental)

reorder.terms

arrange random effects terms in decreasing order of number of groups (factor levels)?

reorder.vars

arrange columns of individual random effects terms in alphabetical order?

Value

a list with components

Zt

transpose of the sparse model matrix for the random effects

theta

initial values of the covariance parameters

Lind

an integer vector of indices determining the mapping of the elements of the theta vector to the "x" slot of Lambdat

Gp

a vector indexing the association of elements of the conditional mode vector with random-effect terms; if nb is the vector of numbers of conditional modes per term (i.e. number of groups times number of effects per group), Gp is c(0,cumsum(nb)) (and conversely nb is diff(Gp))

lower

lower bounds on the covariance parameters

Lambdat

transpose of the sparse relative covariance factor

flist

list of grouping factors used in the random-effects terms

cnms

a list of column names of the random effects according to the grouping factors

Ztlist

list of components of the transpose of the random-effects model matrix, separated by random-effects term

See Also

Other utilities: findbars, mkRespMod, nlformula, nobars, subbars. getME can retrieve these components from a fitted model, although their values and/or forms may be slightly different in the final fitted model from their original values as returned from mkReTrms.

Examples

data("Pixel", package="nlme")
mform <- pixel ~ day + I(day^2) + (day | Dog) + (1 | Side/Dog)
(bar.f <- findbars(mform)) # list with 3 terms
mf <- model.frame(subbars(mform),data=Pixel)
rt <- mkReTrms(bar.f,mf)
names(rt)

lme4

Linear Mixed-Effects Models using 'Eigen' and S4

v1.1-26
GPL (>= 2)
Authors
Douglas Bates [aut] (<https://orcid.org/0000-0001-8316-9503>), Martin Maechler [aut] (<https://orcid.org/0000-0002-8685-9910>), Ben Bolker [aut, cre] (<https://orcid.org/0000-0002-2127-0443>), Steven Walker [aut] (<https://orcid.org/0000-0002-4394-9078>), Rune Haubo Bojesen Christensen [ctb] (<https://orcid.org/0000-0002-4494-3399>), Henrik Singmann [ctb] (<https://orcid.org/0000-0002-4842-3657>), Bin Dai [ctb], Fabian Scheipl [ctb] (<https://orcid.org/0000-0001-8172-3603>), Gabor Grothendieck [ctb], Peter Green [ctb] (<https://orcid.org/0000-0002-0238-9852>), John Fox [ctb], Alexander Bauer [ctb], Pavel N. Krivitsky [ctb, cph] (<https://orcid.org/0000-0002-9101-3362>, shared copyright on simulate.formula)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.