[R] lme plot

Deepayan Sarkar deepayan.sarkar at gmail.com
Fri Mar 24 21:06:59 CET 2006


On 3/23/06, Leonardo D Bacigalupe <L.Bacigalupe at sheffield.ac.uk> wrote:
> Hi all,
>
> I have a questions regarding mixed effects models:
>
> I'm trying to plot e.g. fitted vs residuals for each level of the
> random effects, and i'm getting the same error.
> I guess this might be a problem of the graphic capabilities of R.
>
> Is there any way to obtain those plots?
>
> library(nlme)
> attach(ergoStool)
> names(ergoStool)
> [1] "effort"  "Type"    "Subject"
> m1<-lme(effort~Type,random=~1|Subject)
> plot(m1,form=resid(.,type="p")~fitted(.)|Subject,abline=0)#resid and
> fitted for each level of subject
> Error in as.vector(x, "list") : cannot coerce to vector

I haven't tried figuring out what's wrong here, but using attach() is
generally a bad idea, I think. A lot of effort has gone into designing
interfaces that don't require it, just use them.

m1 <- lme(effort~Type,random=~1|Subject, data = ergoStool)
plot(m1, form=resid(.,type="p")~fitted(.) | Subject, abline=0)

seems to work for me.

Deepayan




More information about the R-help mailing list