## 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