# 泊松回归

2017/11/07 08:31

• 泊松回归介绍

glm(Y ~ X1 + X2 + X3, family=poisson(link="log"),data=mydata)

> data(breslow.dat,package = "robust") #导入robust包中的breslow数据
> names(breslow.dat)                   #变量名称
[1] "ID"    "Y1"    "Y2"    "Y3"    "Y4"    "Base"  "Age"   "Trt"   "Ysum"  "sumY"  "Age10"
[12] "Base4"
> summary(breslow.dat[c(6,7,8,10)]) #获得6、7、8、10的变量数据等同于 breslow.dat[,c(6,7,8,10)]
Base             Age               Trt          sumY
Min.   :  6.00   Min.   :18.00   placebo  :28   Min.   :  0.00
1st Qu.: 12.00   1st Qu.:23.00   progabide:31   1st Qu.: 11.50
Median : 22.00   Median :28.00                  Median : 16.00
Mean   : 31.22   Mean   :28.34                  Mean   : 33.05
3rd Qu.: 41.00   3rd Qu.:32.00                  3rd Qu.: 36.00
Max.   :151.00   Max.   :42.00                  Max.   :302.00

#绘制图形观察基本的情况
> opar <- par(no.readonly = TRUE)  #复制一份图形设置
> par(mfrow = c(1,2))              #修改参数
> attach(breslow.dat)

> hist(sumY,breaks = 20,xlab="Seizure Count",
+      main="Distribution of Seizure")
> boxplot(sumY~Trt,xlab ="Treatment",main="Group Comparisons")
> par(opar)                        #还原原来的设置

#拟合泊松回归
> fit <- glm(sumY ~ Base + Age + Trt, data=breslow.dat, family=poisson())  # family = poisson()
> summary(fit)

Call:
glm(formula = sumY ~ Base + Age + Trt, family = poisson(), data = breslow.dat)

Deviance Residuals:
Min       1Q   Median       3Q      Max
-6.0569  -2.0433  -0.9397   0.7929  11.0061

Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept)   1.9488259  0.1356191  14.370  < 2e-16 ***
Base          0.0226517  0.0005093  44.476  < 2e-16 ***
Age           0.0227401  0.0040240   5.651 1.59e-08 ***
Trtprogabide -0.1527009  0.0478051  -3.194   0.0014 **
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for poisson family taken to be 1)

Null deviance: 2122.73  on 58  degrees of freedom
Residual deviance:  559.44  on 55  degrees of freedom
AIC: 850.71

Number of Fisher Scoring iterations: 5

0
0 收藏

0 评论
0 收藏
0