Rebuilds the random effect terms
mkNewReTrms(object, newdata, re.form=NULL,
na.action=na.pass,
allow.new.levels=FALSE,
sparse = max(lengths(orig.random.levs)) > 100)a list with components
transpose of the sparse model matrix for the random effects
initial values of the covariance parameters
an integer vector of indices determining the mapping of
the elements of the theta vector to the "x" slot of
Lambdat
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 bounds on the covariance parameters
transpose of the sparse relative covariance factor
list of grouping factors used in the random-effects terms
a list of column names of the random effects according to the grouping factors
list of components of the transpose of the random-effects model matrix, separated by random-effects term
names of the terms (in the same order as Zt,
i.e. reflecting the reorder.terms argument)
a fitted merMod object
data frame for which to create new RE terms object
(formula, NULL, or NA) specify which random effects to condition on when predicting. If NULL,
include all random effects; if NA or ~0,
include no random effects
function determining what should be done
with missing values for fixed effects in newdata
(logical) if new levels (or NA values) in
newdata are allowed. If FALSE (default), such new values in
newdata will trigger an error; if TRUE, then the prediction
will use the unconditional (population-level) values for data with
previously unobserved levels (or NAs)
generate sparse contrast matrices?
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.
fm1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
nd <- data.frame(Days = 5, Subject = "new")
try(mkNewReTrms(fm1, newdata = nd))
t1 <- mkNewReTrms(fm1, newdata = nd, allow.new.levels = TRUE)
Run the code above in your browser using DataLab