z <- data.frame(Titanic) Titanic1 <- data.frame(Class = rep(z[, 1], z[, 5]), Sex = rep(z[, 2], z[, 5]), Age = rep(z[, 3], z[, 5]), Survived = rep(z[, 4], z[, 5])) ans = glm(Survived ~ Sex + Age, data=Titanic1, family = binomial(link="logit")) summary(ans)
Deviance Residuals: Min 1Q Median 3Q Max -1.8509 -0.6831 -0.6831 0.8061 1.7719 Coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept) -0.7800 0.2246 -3.473 0.000514 *** SexFemale 2.2940 0.1199 19.126 < 2e-16 *** AgeAdult -0.5564 0.2276 -2.445 0.014493 * --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 (Dispersion parameter for binomial family taken to be 1) Null deviance: 2769.5 on 2200 degrees of freedom Residual deviance: 2329.1 on 2198 degrees of freedom AIC: 2335.1 Number of Fisher Scoring iterations: 4
Coefficientsの表で、Estimateの値が標準化回帰係数βに相当。Std.Errorが標準誤差、Pr(>|z|)がp値。
95%オッズ比を求めるには、標準誤差を1.96倍した値を標準化回帰係数に足す値と引く値を作って、その値をeの乗数にする。
この7.83〜12.54がオッズ比の95%信頼区間。
推定されたオッズ比は、e^2.2940=9.914516537なので、オッズ比と95%信頼区間は、9.9(7.8〜12.5)になる。