lme4 (version 1.0-4)

refit: Refit a model by maximum likelihood criterion

Description

Refit a model with a different response vector

Usage

refit(object, newresp, ...)

## S3 method for class 'merMod': refit(object, newresp = NULL, ...)

Arguments

object
a fitted model, usually of class "lmerMod", to be refit with a new response
newresp
a numeric vector providing the new response. Must be of the same length as the original response.
...
optional additional parameters. None are used at present.

Value

  • an object like x but fit by maximum likelihood

Details

Refit a model 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.

Examples

Run this code
## 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))
fit1 <- lmer(y~x+(1|f),data=d)
res <- c(fit1,lapply(as.data.frame(Y[,-1]),
        refit,object=fit1))

Run the code above in your browser using DataLab