我可以用glm 和offset() 报告一些实验的结果。似乎(至少从这个实验中)您对predict 的调用不会给出将offset 考虑在内的结果。相反,为此目的似乎需要summary.glm。我首先对?glm 中的第一个示例进行了相当严重的修改(如果您确实提供了数据,这将更符合您的担忧,因为这样我们就可以更多地使用您需要“测试”的 newdata 参数.)
counts <- c(18,17,15,20,10,20,25,13,12)
outcome <- gl(3,1,9)
treatment <- gl(3,3)
print(d.AD <- data.frame(treatment, outcome, counts))
glm.D93 <- glm(counts ~ outcome + treatment + offset(1:9), family = poisson())
glm.D93d <- glm(counts ~ outcome + treatment , family = poisson())
> predict(glm.D93d, type="response")
1 2 3 4 5 6 7 8 9
21.00000 13.33333 15.66667 21.00000 13.33333 15.66667 21.00000 13.33333 15.66667
> predict(glm.D93, type="response")
1 2 3 4 5 6 7 8 9
21.00000 13.33333 15.66667 21.00000 13.33333 15.66667 21.00000 13.33333 15.66667
据我所知,offset 仅在将估计系数与 NULL 估计(通常为 0)进行比较以进行统计推断时才明显。这是由summary.glm 完成的:
> summary(glm.D93)$coef
Estimate Std. Error z value Pr(>|z|)
(Intercept) 2.044522 0.1708987 11.963362 5.527764e-33
outcome2 -1.454255 0.2021708 -7.193203 6.328878e-13
outcome3 -2.292987 0.1927423 -11.896644 1.232021e-32
treatment2 -3.000000 0.2000000 -15.000000 7.341915e-51
treatment3 -6.000000 0.2000000 -30.000000 9.813361e-198
> summary(glm.D93d)$coef
Estimate Std. Error z value Pr(>|z|)
(Intercept) 3.044522e+00 0.1708987 1.781478e+01 5.426767e-71
outcome2 -4.542553e-01 0.2021708 -2.246889e+00 2.464711e-02
outcome3 -2.929871e-01 0.1927423 -1.520097e+00 1.284865e-01
treatment2 1.337909e-15 0.2000000 6.689547e-15 1.000000e+00
treatment3 1.421085e-15 0.2000000 7.105427e-15 1.000000e+00
偏移量只会改变参考水平(在这个被破坏的例子中有相当奇怪的变化),而$linear.predictors 和$fitted 对数据的拟合不受影响。我没有在 glm 中看到影响这一点的评论,但 ?lm 中有评论:“由 offset 指定的偏移量不会包含在 predict.lm 的预测中,而由公式中的偏移项指定的偏移量将是。”我承认我从阅读?model.offset 获得的洞察力非常有限。