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 Thanks leonardo Leonardo D. Bacigalupe Department of Animal and Plant Sciences University of Sheffield Sheffield S10 2TN United Kingdom L.Bacigalupe at sheffield.ac.uk
Leonardo D Bacigalupe <L.Bacigalupe <at> sheffield.ac.uk> writes:> 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 don't believe your idea is wrong, and I don't understand why this does not work, but a similar line on page 176 of Pinheiro/Bates does (there, the call to getData returns non-null). The lines I don't understand in plot.lme are alist <- lapply(as.list(allV), as.name) names(alist) <- allV # next line alist <- c(as.list(as.name("data.frame")), alist) mode(alist) <- "call" data <- eval(alist, sys.parent(1)) This code turn up again and again in nlme, but I admit I don't understand what it means. Anybody taking the challenge to dissect it? Dieter
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 vectorI 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