【R】 オッズ比と95%信頼区間を出力する
作業効率アップのためにサンプルスクリプトをここから引用した。
データフレーム:data1
目的変数:Y
説明変数:X1, X2
res<-glm(data1$Y~.,data=data1,family=binomial)
res1<-summary(res)
res1
coe<-res1$coefficient
coe
OR<-exp(coe[,1])
ORlow<-exp(coe[,1]-1.96*coe[,2])
ORhigh<-exp(coe[,1]+1.96*coe[,2])
res2<-cbind(coe,OR,ORlow,ORhigh)
res2
出力される値は
P値=Pr(>|z|)
オッズ比=OR
95%CI=ORlowーORhigh
となる