Hi list
This doesn't particularly concern the interpretation of a mixed model, so I thought it best to post here. I assume it has something to do with using the asList call for an S4 object or some form of grouping done by lme, but I might be way off. I'd like to extract the residuals of a lmer fit as a list, with residuals grouped by random effects, as is returned by an lme model:

library(nlme)
fm1 <- lme(Reaction ~ Days, random=~Days|Subject, sleepstudy)
res1<-resid(fm1, asList=TRUE)
res1

However, when I try the same with a lmer model, asList doesn't work:
library(lmer)
fm2 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy)
res2<-resid(fm1, asList=TRUE)
res2

I had an attempt, but quickly hit the wall in my programming skills. E.g. I can add the appropriate random effect names to each residual using:

a<-as.numeric(sleepstudy$Subject)
names(res)<-a

Is it possible to return a similar structure as res1 for the residuals of fm2? If so, does anyone have some tips?

Cheers

John

	[[alternative HTML version deleted]]

