# This code examines association between # myocardinal infarction and diabetes in # 1:1 matched case-control study # First enter the counts as a matrix. m <- matrix(c(9,37,16,82),2,2) dimnames(m) <- list(c("case_E","case_NE"),c("control_E","control_NE")) m # Evaluate McNemar's test mcnemar.test(m) # Evaluate McNemar's test without # using the continuity correction mcnemar.test(m, correct=F) # Evaluate an exact p-value based on a # binomial distirbution for the # discordant pairs binom.test(m[1,2], (m[1,2]+m[2,1]), p=.5) # Conditional logistic regression mdat <- read.table("c:/Documents and Settings/kkoehler.IASTATE/My Documents/courses/st565/R/midiab.matched.txt", header=F, col.names=c("group","MI","diabetes")) mdat$time <- 1 mdat # Attach the library of survival analysis functions library(survival) conlogit.out <- coxph(Surv(time,MI) ~ diabetes + strata(group),data=mdat) conlogit.out