我正在尝试绘制我的跨栏模型的预测。
模型:
mm14C<-hurdle(littersize1~X1+mont|mont,dist = "poisson", zero = "bin", data=data,weights=w)
Predict 函数可以很好地预测值:
stripchart(data$X1~data$littersize1,ylab="Litter size",font.lab = 1, family = "serif", cex.lab = 1.5, method="jitter",xlim=c(-1.9,1),col="grey", xlab="Connectivity to Males",jitter=0.3, pch=18)
xk<-seq(from=-2, to=2, length=1000)
x2<-seq(from=1, to=12, length=1000)
my.data<-data.frame(X1=xk, mont=x2)
pred.vals<-predict(mm14C, newdata=my.data,weights = w, type="response")
lines(pred.vals~xk,lty=1, col="black
然而,它给 SE 的预测带来了误差
G<-predict(mm14C, newdata=my.data, se.fit=TRUE,weights = w, type="response")
f<-G$fit
fseup<-(G$fit +1.96*G$se.fit)
fselow<-(G$fit-1.96*G$se.fit)
lines(fseup~xk-1,lty=3, col="green")
lines(fselow~xk,lty=3, col="green")
错误:G$fit 中的错误:$ 运算符对原子向量无效我曾尝试在模型中仅保留一个变量 (X1),并仅使用 Poisson glm 来测试问题是否出在模型上。但我总是遇到同样的错误。