我在尝试使用“visreg”函数制作条件图时遇到一些麻烦。我的模型是使用“glmmTMB”函数构建的零膨胀负二项式回归,它包含一个偏移量。
为什么部分残差与预测曲线相差这么远?我的猜测是偏移量的缩放发生了一些事情。
y <- c(18, 0, 2, 0, 0, 0, 2, 0, 0, 1, 7, 0, 0, 0, 0, 0, 0, 0, 0)
x1 <- c(501, 1597, 1156, 1134, 1924, 507, 1022, 0, 92, 1729, 85, 963, 544, 1315, 2250, 1366, 458, 385, 930)
x2 <- c(0, 92, 959, 1146, 900, 0, 276, 210, 980, 8, 0, 473, 0, 255, 1194, 542, 983, 331, 923)
offset_1 <- c(59, 34, 33, 35, 60, 58, 59, 33, 34, 61, 58, 58, 55, 26, 26, 18, 26, 26, 26)
data_1 <- data.frame(y,x1,x2,offset_1)
m1 <- glmmTMB(y ~ -1 + x1 + x2 + offset(log(offset_1)), data=data_1,
family = nbinom2, zi = ~1)
summary(m1)
visreg(m1, "x1", scale="response", cond=list(offset_1=1), partial=TRUE,
rug=2,line=list(lwd=0.5, col="black"), points=list(cex=1.4, lwd=0.1, col="black", pch=21))
visreg(m1, "x1", scale="response", cond=list(offset_1=1), partial=FALSE,
rug=2,line=list(lwd=0.5, col="black"), points=list(cex=1.4, lwd=0.1, col="black", pch=21))
以下是添加部分残差 (partials = TRUE) 和不添加部分残差 (partials = FALSE) 的条件图。