## Comparing two proportions ## # Table 2.3, p. 27 (attack v. no attack) x<-c(189,104) # placebo, aspirin n<-c(11034,11037) # test H0:p1=p2 (equal probabilities of heart attack) prop.test(x,n,p=c(.5,.5)) prop.test(x,n)$p.value # Test H0:p1=p2 v. H1:p1>p2 prop.test(x,n,alt="greater")$p.value # sample difference of proportions: temp<-prop.test(x,n) names(temp$estimate)<-NULL # optional temp$estimate[[1]]-temp$estimate[[2]] # relative risk temp$estimate[[1]]/temp$estimate[[2]] # odds ratio x[1]*(n[2]-x[2])/(x[2]*(n[1]-x[1]))