###################################################################### # STAT 7030 - Categorical Data Analysis # Peng Zeng (Auburn University) # 2023-12-14 ###################################################################### ###################################################################### # Opinion on Legalization of Abortion ###################################################################### p = 400 / 893 # 0.4479283 # CI = (0.415, 0.481) by normal approximation without continuity correction p + c(-1, 1) * qnorm(0.975) * sqrt(p * (1-p) / 893) z = (p - 0.5) / sqrt(0.5 * (1 - 0.5) / 893) # z = -3.112126 2 * pnorm(abs(z), lower.tail = FALSE) # p-value = 0.00185745 # results with continuity correction prop.test(400, 893, p = 0.5) ###################################################################### # odds and log odds ###################################################################### omega = 400 / 493 # ods = 0.811359 SE = sqrt(1/400 + 1/493) # SE.logodds = 0.06729337 CI.logodds = log(omega) + c(-1, 1) * qnorm(0.975) * SE # CI = (-0.3409 -0.0772) CI.odds = exp(CI.logodds) # CI = (0.7111, 0.9257) ###################################################################### # number of students ###################################################################### p = 5739 / 20037 p + c(-1, 1) * qnorm(0.975) * sqrt(p * (1 - p) / 20037) ###################################################################### # THE END ######################################################################