Sara Krause <skkrause <at> gmail.com> writes: > > Hi, > > I am new to R and not fantastic at statistics so it may well be that I am > doing something silly but I can't figure out what it is and hoping that > somebody can help. > > I am running package lme4, and trying to get a Residuals vs. Fitted graph. > When I try to plot, I receive an error. > > Error in as.double(y) : > cannot coerce type 'S4' to vector of type 'double' > > Here is the code I am using > > library("lme4") > > m1<-lmer(y~trt*time*loc_block*Season+(1|ID), data=d) > > plot(m1,add.smooth=F,which=1) > > Error in as.double(y) : > cannot coerce type 'S4' to vector of type 'double' > > I searched the forums for some answers but haven't found anything > useful. Any insight into what I am doing wrong and how to fix it. > > Sara
The standard diagnostics which you have seen in 'lm' are not implemented for 'lme4'. You have to do it yourself, but it's not *too* hard: library(lme4) ## from ?lmer fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy) f <- fitted(fm1) r <- residuals(fm1) plot(f,r) sm <- loess(r~f) v <- seq(min(f),max(f),length=101) lines(v,predict(sm,data.frame(f=v)),col=2) Further questions about lme4 should probably go to the r-sig-mixed-models mailing list. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.