lme残差中的识别功能问题

问题描述

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

数据:https://drive.google.com/file/d/1Usasdah-28Tdu1Y5JEWxNyNudzHgZIHfyvV/view?usp=sharing

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),10))
fb <- as.factor(rep(rep(1:4,rep(n.g,4)),10))
rb <- rep(rnorm(4),4))
for (i in 1:9) rb <- c(rb,rep(rnorm(4),4)))
## simulate auto-correlated errors within groups
e<-array(0,0)
for (i in 1:40) {
  eg <- rnorm(n.g,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))

这将起作用。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...