在没有看到数据集(不可用)的情况下,它似乎大多是正确的。泊松回归的好处在于,当按照建议使用时,它们可以提供比率。可能值得记住的一件事是,可能存在过度分散,您应该切换到负二项式回归(请参阅 MASS 包)。
泊松回归不关心数据是否聚合,但实际上非聚合数据很脆弱,可能会导致一些意外错误。请注意,您不能surv == 0在任何情况下都拥有。当我测试的估计是相同的:
set.seed(1)
n <- 1500
data <-
data.frame(
dead = sample(0:1, n, replace = TRUE, prob = c(.9, .1)),
surv = ceiling(exp(runif(100))*365),
gender = sample(c("Male", "Female"), n, replace = TRUE),
diagnosis = sample(0:1, n, replace = TRUE),
age = sample(60:80, n, replace = TRUE),
inclusion_year = sample(1998:2011, n, replace = TRUE)
)
library(dplyr)
model <-
data %>%
group_by(gender,
diagnosis,
age,
inclusion_year) %>%
summarise(Deaths = sum(dead),
Person_time = sum(surv)) %>%
glm(Deaths ~ gender + diagnosis + I(age - 70) + I(inclusion_year - 1998) + offset(log(Person_time/10^3/365.25)),
data = . , family = poisson)
alt_model <- glm(dead ~ gender + diagnosis + I(age - 70) + I(inclusion_year - 1998) + offset(log(surv/10^3/365.25)),
data = data , family = poisson)
sum(coef(alt_model) - coef(model))
# > 1.779132e-14
sum(abs(confint(alt_model) - confint(model)))
# > 6.013114e-11
当你得到一个速率时,将变量居中是很重要的,这样截距是可解释的,例如:
> exp(coef(model)["(Intercept)"])
(Intercept)
51.3771
可以解释为基本利率,然后协变量是利率比率。如果我们想要 10 年后的基准利率:
> exp(coef(model)["(Intercept)"] + coef(model)["I(inclusion_year - 1998)"]*10)
(Intercept)
47.427
我目前已将包含年份建模为趋势变量,但您可能应该检查非线性,有时对时间点进行分类很有用。我在本文中使用了这种方法:
D. Gordon、P. Gillgren、S. Eloranta、H. Olsson、M. Gordon、J. Hansson 和 KE Smedby,“皮肤黑色素瘤发病率的时间趋势(按详细解剖位置和紫外线照射模式):回顾性人群基于研究,”黑色素瘤研究,第一卷。25,没有。4,第 348-356 页,2015 年 8 月。