公众号-科研私家菜学习记录(2)
2021-08-04 本文已影响0人
明眸意海
泊松回归
- 定义:当因变量是单位时间某事件的发生次数时就应该考虑用泊松回归,比如想研究的因变量是过去一个月病人发生脑卒中的次数,就考虑用泊松回归。
- 分析代码:
data(Affairs, package="AER")
summary(Affairs)
table(Affairs$affairs)
# fit full model
fit.full <- glm(affairs ~ gender + age + yearsmarried + children +
religiousness + education + occupation +rating,
data=Affairs,family=poisson())
summary(fit.full)
- OR值计算
# interpret coefficients
coef(fit.reduced)
# OR值 回归系数的反对数
exp(coef(fit.reduced))
# OR值的置信区间
exp(confint(fit.reduced))
# OR值和置信区间
exp(cbind(OR = coef(fit.reduced), confint(fit.reduced)))