R

如何計算以下數據的邏輯回歸的優勢比和 95% 置信區間?

  • September 25, 2017

我從一篇研究論文中獲得了以下數據:

S1 : n = 30 / Rest : n = 66

SH      11  /      8

為了計算 p 值,我做瞭如下操作:

library(MASS)
x = matrix(c(19,11,58,8), nrow=2, byrow=T)
D = factor(c("S1","SH"), levels=c("S1","SH"))
m = glm(x~D, family=binomial)
summary(m)

Call:
glm(formula = x ~ D, family = binomial)

Deviance Residuals: 
[1]  0  0

Coefficients:
       Estimate Std. Error z value Pr(>|z|)   
(Intercept)   0.5465     0.3789   1.443  0.14914   
DSH           1.4345     0.5346   2.683  0.00729 **
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

Null deviance:  7.3387e+00  on 1  degrees of freedom
Residual deviance: -8.8818e-16  on 0  degrees of freedom
AIC: 11.607

Number of Fisher Scoring iterations: 3

p 值為 0.007。這和我在研究論文中看到的一樣。優勢比為 4.20,95% CI 為 (1.47-11.97)

我想知道如何為此計算優勢比和 95% 置信區間?誰能告訴我如何在R中計算這個?有什麼功能嗎?

在 R 中

> exp(summary(m)$coefficients["DSH",1] + 
+     qnorm(c(0.025,0.5,0.975)) * summary(m)$coefficients["DSH",2])
[1]  1.472098  4.197368 11.967884

引用自:https://stats.stackexchange.com/questions/304833

comments powered by Disqus