Ref 《统计建模与R软件》[薛毅、陈萍] chapter 5<若干重要的非参数检验>
> x <- as.table(matrix(c(157,24,69,18),nrow = 2,dimnames = list(case=c('A','B'),control=c('A','B'))))
> x
control
case A B
A 157 69
B 24 18
> chisq.test(x)
Pearson's Chi-squared test with Yates' continuity correction
data: x
X-squared = 1.9244, df = 1, p-value = 0.1654
# 另外
> fisher.test(x)
Fisher's Exact Test for Count Data
data: x
p-value = 0.1504
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
0.8141327 3.5153422
sample estimates:
odds ratio
1.702999
OR=1.702999
OR还有三个包可以计算(你自己去check)
1、http://www.inside-r.org/packages/cran/abd/docs/odds.ratio
2、http://minato.sip21c.org/msb/man/oddsratio.html
3、http://artax.karlin.mff.cuni.cz/r-help/library/bstats/html/oddsratio.html
也可以手工计算
1、http://a-little-book-of-r-for-biomedical-statistics.readthedocs.org/en/latest/src/biomedicalstats.html
2、http://www.r-bloggers.com/computing-odds-ratios-in-r/