泊松回归的非直观答案

机器算法验证 回归 分类数据 泊松分布
2022-03-23 11:35:23

我对泊松回归不是很熟悉,所以我想我在下面的分析中一定犯了一个错误:

我正在研究吸烟对肺癌发病率的影响。数据集在此处提供。变量smoking_status定义:

吸烟状态:编码 1 = 不吸烟,2 = 只抽雪茄或烟斗,3 = 抽雪茄和雪茄或烟斗,4 = 只抽雪茄,

我稍微修改了数据并制作了两个新的分类变量:烟斗/雪茄吸烟者和香烟吸烟者,以替换吸烟状态。所以吸烟状态 1 映射到 (0,0),2 映射到 (1,0),3 映射到 (1,1) 等等。

我还在我的数据集中添加了一个常量列。这就是我对数据所做的一切。

然后,我使用指数链接函数对该数据集执行泊松回归。我的希望是这两个新变量的系数是正的,但只有 Smoking_smoker 是正的。置信区间也不包含正点。

我是否错误地分析了数据,或者我的数据是错误的?

编辑

输出(来自 Python 库 Statsmodels )

             Generalized Linear Model Regression Results
Dep. Variable:                      y   No. Observations:                   36
Model:                            GLM   Df Residuals:                       31
Model Family:                 Poisson   Df Model:                            4
Link Function:                    log   Scale:                             1.0
Method:                          IRLS   Log-Likelihood:                -815.93
Date:                Thu, 31 Jan 2013   Deviance:                       1391.8
Time:                        13:19:32   Pearson chi2:                 1.22e+03
No. Iterations:                     7

                coef    std err          t      P>|t|      [95.0% Conf. Int.]
------------------------------------------------------------------------------
x1             0.2596      0.006     44.097      0.000         0.248     0.271
x2            -0.1850      0.024     -7.775      0.000        -0.232    -0.138
x3             0.5327      0.031     17.101      0.000         0.472     0.594
x4             0.0004   7.95e-06     54.637      0.000         0.000     0.000
const          2.9593      0.046     63.903      0.000         2.869     3.050

变量依次为年龄、smoke_cigar (0,1)、smoke_cigar (0,1)、人口(以十万计)、constant_term。

一些示例数据:

数组([[ 2., 0., 0., 359., 1.], [ 4., 0., 1., 3270., 1.]])

与目标死亡 [22., 514.] 分别。

1个回答

对评论中材料的简短(实际上很长)更新(如上面@cardinal和我本人所涵盖):

我认为主要问题是由于未指定偏移变量(根据我上面的评论,请参阅 StasK 关于解释系数答案的说明),这通常是处于风险中的人口(或处于风险中的人时)的自然对数。)

为了让泊松回归比较比率而不是计数,您需要指定一个偏移变量(它作为回归方程右侧的常数。)

在 R 中,使用来自http://data.princeton.edu/wws509/datasets/#Smoking的相同数据集(我将其存储为raw.dat、变量名age和) smoke这将是:popdead

# Make a factorial version of the smoking variable
raw.dat$smoke.f <- factor(raw.dat$smoke)

# For this variable 1 = non-smoker, 2 = cigar only, 
# 3 = cigarettes + cigars, 4 = cigarettes only.

# Regression model:
poisson.smoke <- glm(dead ~ age + smoke.f, offset=log(pop), 
                 family="poisson", data = raw.dat)
summary(poisson.smoke)

# snipped output from R:
# Coefficients:
#              Estimate Std. Error z value Pr(>|z|)    
# (Intercept) -3.738877   0.050009 -74.764  < 2e-16 ***
# age          0.333006   0.005591  59.559  < 2e-16 ***
# smoke.f2     0.032927   0.046894   0.702    0.483    
# smoke.f3     0.236353   0.038597   6.124 9.15e-10 ***
# smoke.f4     0.437946   0.039803  11.003  < 2e-16 ***

因此,smoke.f2(仅雪茄)与非吸烟者相比的系数现在为 0.333,取幂后得出的比率为 1.033(95% CI 0.94, 1.13),因此在此模型中没有特别证据表明仅雪茄会增加肺癌风险吸烟者与不吸烟者相比。

其次:关于您的原始模型中雪茄和香烟之间缺乏交互项(并注意,根据您的第二个模型和上面的示例,包括交互项在一个级别上等同于将雪茄 + 香烟视为一个不同的组,其中导致模型具有相同数量的参数和相同的解,但对系数有一些不同的解释。)

这种缺乏交互可能会导致一些问题,但是通过正确指定偏移变量,系数至少指向正确的方向:

# Make two indicator variables for cigar and smoking    
raw.dat$cigar <- ifelse(raw.dat$smoking==2 | raw.dat$smoking==3, 1, 0)
raw.dat$cigarette <- ifelse(raw.dat$smoking==3 | raw.dat$smoking==4, 1, 0)

# Model treating these as independent:
poisson.sep.smoke <- glm(dead ~ age + cigar + cigarette,  offset=log(pop),
                 family="poisson", data = raw.dat)

# snipped output from R:
# Coefficients:
#              Estimate Std. Error z value Pr(>|z|)    
# (Intercept) -3.648010   0.044886 -81.273  < 2e-16 ***
# age          0.334359   0.005576  59.959  < 2e-16 ***
# cigar       -0.153685   0.021252  -7.232 4.77e-13 ***
# cigarette    0.312363   0.027301  11.442  < 2e-16 ***

然后包括两者之间的交互:解决方案方面,这相当于根据我的第一个模型具有所有四个级别(具有三个虚拟变量)。

poisson.int.smoke <- glm(dead ~ age + cigar * cigarette,  offset=log(pop),
                     family="poisson", data = raw.dat)
summary(poisson.int.smoke)

# snipped output from R:    
# Coefficients:
#                  Estimate Std. Error z value Pr(>|z|)    
# (Intercept)     -3.738877   0.050009 -74.764  < 2e-16 ***
# age              0.333006   0.005591  59.559  < 2e-16 ***
# cigar            0.032927   0.046894   0.702    0.483    
# cigarette        0.437946   0.039803  11.003  < 2e-16 ***
# cigar:cigarette -0.234519   0.052428  -4.473 7.71e-06 ***

所以你可以看到交互项 ( cigar:cigarette) 是显着的:换句话说,抽雪茄和抽香烟的效果是相互依赖的。这是指定基于交互项的模型优于所有级别模型的主要优点,因为在这种情况下“自动”测试了交互现象(雪茄和香烟影响之间的独立性)。

这里的cigarcigarette系数对应于smoke.f2smoke.f4之前,并且在数学上,旧系数是该模型中 和 项总和smoke.f3cigarcigarettecigar:cigarette