[R-sig-ME] plotting residuals vs. fitted values by group

Douglas Bates bates at stat.wisc.edu
Tue Jan 18 19:26:35 CET 2011


Try

library(lattice)
xyplot(resid(mod5) ~ fitted(mod5)|species_site, mod5 at frame)

The reason for using mod5 at frame is to get the data frame to which the
model was actually fit.

On Tue, Jan 18, 2011 at 12:16 PM, Rachel Cohen <s0957429 at sms.ed.ac.uk> wrote:
> Hi, I am quite new to using R and am currently trying to plot the residuals
> vs. fitted values by group, taken from an lmer model within
> lme4_0.999375-36.  The model i'm using is:
>
> mod5<-lmer((centre.log.mass)~centre.log.dbh+centre.log.height+(1+centre.log.height|species_site),REML=F)
>
> I have tried:
> plot(mod5, resid(.)~fitted(.)|species_site)
>
> but get the following error message:
>
> Error in xy.coords(x, y, xlabel, ylabel, log) :
>  'x' and 'y' lengths differ
>
> I'm not sure what this means?  I have managed to plot the overall model
> residuals vs. fitted values by using:
>
> fit<-fitted(mod5)
> res<-resid(mod5)
> plot(fit,res, main="Model V Residuals vs. Fitted Mass", ylab="Ln Residual",
> xlab="Ln Fitted Mass")
>
> However, I'm not sure how to get an individual group-level plot for each of
> my 12 groups of residuals vs. fitted.
>
> Any help would be greatly appreciated!
>
> Rachel Cohen
>
> --
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>




More information about the R-sig-mixed-models mailing list