# Edps/Psych/Soc 584 # Fall 2018 # C.J.Anderson # # UofI Admissions Scandel (2 x 2 table) # The data were from White's e-mail. # # Part of the argument that White made was that the general admission rate was 69% and # the rate on the I List was higher but it only lead to only additional 13 students being # admitted. # # 160 students on the I list # 123 admitted # 76.88% admitted from I list # # 69% of 160 = 110.... so 123 - 110 = 13 (i.e., number admitted from I list minus 69% is 13) # library(Epi) # for twoby2 library(MASS) # for loglm library(vcd) # for assocstats # create data frame var.levels <- expand.grid(admit=c("yes","no"), Ilist=c("Ilist","General")) ( scandel <- data.frame(var.levels, count=c(123, 37, 18000 , 8000) ) ) # tabular form scandel.tab <- xtabs(count ~ admit + Ilist, data=scandel) addmargins(scandel.tab) # data should be in matrix form -- this keeps row & column names and level values ( scandel.mat <- as.matrix(scandel.tab) ) # Compute differences, relative risk & odds ratio, including CIs twoby2(scandel.mat) # Chi-square test statistics: data frame (case data) loglm(count ~ admit + Ilist, data=scandel) # or --- this includes Yate's correction for continuity, which isn't used much anymore chisq.test(scandel.tab) # or ax <- as.factor(scandel$admit) ix <- as.factor(scandel$Ilist) glm(count ~ ax + ix, data=scandel, family=poisson) # or assocstats(scandel.tab)