如何用visreg绘制含offset的glmmTMB模型偏残差图?残差偏离原因?
问题:含Offset的零膨胀负二项模型visreg偏残差与预测曲线偏离问题
使用glmmTMB构建包含offset的零膨胀负二项回归模型后,用visreg绘制条件图时,发现偏残差(partial residuals)与预测曲线距离过远,推测该问题与offset的缩放有关。
以下是相关代码:
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))
对应绘图如下:
- 含偏残差的visreg图:

- 不含偏残差的visreg图:

内容的提问来源于stack exchange,提问作者Sergio Nolazco
相关产品推荐
相关产品推荐

