lme 残差中识别函数的问题

Problems with the identify function in the lme residuals

我在使用识别功能时遇到问题。 我正在尝试识别调整后模型的残差图上的点,但是 identify function 给出了错误。

library(mgcv)
require(gamm4)

fit4.gamm <- gamm(log(massaseca)~factor(Trat)+s(Tempo,k=10,bs="ps",m=2,
                                           by=factor(Trat)),
                  random=list(id=pdSymm(~Tempo)),data=dados)
comp_lme = fit4.gamm$lme

x11()
plot(comp_lme)

错误:

identify(comp_lme)
Error in xy.coords(x, y, setLab = FALSE) : 
  'x' is a list, but does not have components 'x' and 'y'

从文档中取一个可重现的例子:

library(mgcv)
library(gamm4)
n <- 200;sig <- 2
set.seed(0)
n.g <- 10
n<-n.g*10*4
## simulate smooth part...
dat <- gamSim(1,n=n,scale=2)
f <- dat$f
## simulate nested random effects....
fa <- as.factor(rep(1:10,rep(4*n.g,10)))
ra <- rep(rnorm(10),rep(4*n.g,10))
fb <- as.factor(rep(rep(1:4,rep(n.g,4)),10))
rb <- rep(rnorm(4),rep(n.g,4))
for (i in 1:9) rb <- c(rb,rep(rnorm(4),rep(n.g,4)))
## simulate auto-correlated errors within groups
e<-array(0,0)
for (i in 1:40) {
  eg <- rnorm(n.g, 0, sig)
  for (j in 2:n.g) eg[j] <- eg[j-1]*0.6+ eg[j]
  e<-c(e,eg)
}
dat$y <- f + ra + rb + e
dat$fa <- fa;dat$fb <- fb
## fit model .... 
b <- gamm(y~s(x0,bs="cr")+s(x1,bs="cr")+s(x2,bs="cr")+
            s(x3,bs="cr"),data=dat,random=list(fa=~1,fb=~1),
          correlation=corAR1())

您正在尝试什么:

plot(b$lme)      #lattice plot
identify(b$lme)  #doesn't work with lattice plots

相反,制作您自己的基本情节:

plot(fitted(b$lme), resid(b$lme))
identify(fitted(b$lme), resid(b$lme))

这会起作用。