# Case-control study assessing whether exposure to tap water
# is associated with cryptosporidiosis among AIDS patients
tab <- matrix(c(2, 29, 35, 64, 12, 6), 3, 2, byrow=TRUE)
dimnames(tab) <- list("Tap water exposure" = c("Lowest", "Intermediate", "Highest"),
"Outcome" = c("Case", "Control"))
tab <- Rev(tab, direction="column")
OddsRatio(tab[1:2,])
OddsRatio(tab[c(1,3),])
OddsRatio(tab[1:2,], method="mle")
OddsRatio(tab[1:2,], method="midp")
OddsRatio(tab[1:2,], method="wald", conf.level=0.95)
# in case of zeros consider using glm for calculating OR
dp <- data.frame (a=c(20,7,0,0), b=c(0,0,0,12), t=c(1,0,1,0))
fit <- glm(cbind(a,b) ~ t, binomial, dp)
exp(coef(fit))
Run the code above in your browser using DataLab