| refit {lme4} | R Documentation |
Refit a model with a different response vector
refit(object, newresp, ...) ## S3 method for class 'merMod' refit(object, newresp = NULL, rename.response=FALSE, ...)
object |
a fitted model, usually of class
|
newresp |
an (optional) numeric vector providing the new response. Must be of the same length as the original response. |
rename.response |
when refitting the model,
should the name of the response variable in the formula
and model frame be replaced with the name of |
... |
optional additional parameters. None are used at present. |
Refit a model, possibly after modifying the response vector. This
could be done using an update method but
this approach should be faster because it bypasses the
creation of the model representation and goes directly to
the optimization step.
Setting rename.response to TRUE may be necessary
if one wants to do further operations (such as update)
on the fitted model. However, the refitted model will
still be slightly different from the
equivalent model fitted via update; in particular,
the terms component is not updated to reflect
the new response variable, if it has a different name
from the original.
an object like x, but fit by maximum likelihood
## using refit() to fit each column in a matrix of responses
set.seed(101)
Y <- matrix(rnorm(1000),ncol=10)
res <- list()
d <- data.frame(y=Y[,1],x=rnorm(100),f=rep(1:10,10))
## need to disregard convergence checks because we
## are doing a fake example
fit1 <- lmer(y~x+(1|f),data=d,
control=lmerControl(check.conv.grad="ignore",
check.conv.hess="ignore"))
res <- c(fit1,lapply(as.data.frame(Y[,-1]),
refit,object=fit1))