【发布时间】:2020-05-30 01:08:36
【问题描述】:
我试图了解如何从泊松回归中的模拟数据中恢复模型估计。 StackExchange/CrossValidated (https://stats.stackexchange.com/questions/11096/how-to-interpret-coefficients-in-a-poisson-regression, https://stats.stackexchange.com/questions/128926/how-to-interpret-parameter-estimates-in-poisson-glm-results) 上还有其他类似的解释系数的帖子,但我认为我的问题是不同的(尽管公认相关)。我试图恢复已知的关系,以了解模型发生了什么。我在这里发帖而不是 CrossValidated,因为我认为这不是统计解释,而是我如何通过代码获得已知/模拟的关系。
这里有一些模拟数据 y 和 x 与某些响应 resp 有已知关系
set.seed(707)
x<-rnorm(10000,mean=5,sd=1)
y<-rnorm(10000,mean=5,sd=1)
resp<-(0.5*x+0.7*y-0.1*x*y) # where I define some relationships
使用线性回归,非常简单:
summary(lm(resp~y+x+y:x))
输出显示 x、y 和交互之间的精确线性关系。
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.592e-14 1.927e-15 8.260e+00 <2e-16 ***
y 7.000e-01 3.795e-16 1.845e+15 <2e-16 ***
x 5.000e-01 3.800e-16 1.316e+15 <2e-16 ***
y:x -1.000e-01 7.489e-17 -1.335e+15 <2e-16 ***
现在,如果我对泊松回归感兴趣,我需要整数,我只是四舍五入,但保持预测变量和响应之间的关系:
resp<-round((0.5*x+0.7*y-0.1*x*y),0)
glm1<-glm(resp~y+x+y:x,family=poisson())
summary(glm1)
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.419925 0.138906 3.023 0.0025 **
y 0.163919 0.026646 6.152 7.66e-10 ***
x 0.056689 0.027375 2.071 0.0384 *
y:x -0.011020 0.005261 -2.095 0.0362 *
我的理解是,由于链接功能,需要对结果求幂才能理解它们。但是在这里,求幂估计和截距 + 估计都不能让我回到原始值。
> exp(0.419925+0.163919)
[1] 1.792917
> exp(0.163919)
[1] 1.178119
如何将这些值解释为与原始 0.7*y 关系相关?
现在,如果我将相同的线性方程放入指数函数中,我会直接得到值 - 无需使用 exp():
resp<-round(exp(0.5*x+0.7*y-0.1*x*y),0)
summary(glm(resp~y+x+y:x,family=poisson()))
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.002970 0.045422 0.065 0.948
y 0.699539 0.008542 81.894 <2e-16 ***
x 0.499476 0.008912 56.047 <2e-16 ***
y:x -0.099922 0.001690 -59.121 <2e-16 ***
有人可以向我解释我在这里误解了什么,以及如何在不首先使用exp() 函数的情况下找到已知关系的原始值,如上所述?
【问题讨论】:
标签: r non-linear-regression poisson coefficients exp