细节可参考:
https://www.plob.org/article/9194.html
https://blog.csdn.net/u011955252/article/details/50704459
https://www.cnblogs.com/emanlee/archive/2008/10/25/1319569.html
https://statsandr.com/blog/fisher-s-exact-test-in-r-independence-test-for-a-small-sample/
使用结论:
一:对于2*2的列联表:
(1)当T(此处为最小理论频数,下同)>=5, n>=40 时,直接用Pearson 卡方检验;
(2)当1 = 40 时,需要用连续性校正公式做卡方检验。这是因为卡方分布为连续型分布,而2*2列联表资料是分类资料,所以样本量较小时要进行连续性校正。
(3)当T<1 , 或者 n < 40, 或做卡方检验后所得的P值接近检验水准a 时,用Fisher exact test
二:对于行×列表资料检验
要求每个格子中的理论频数T均大于5或1<1或1
注意:
理论频数,并非实际观测值
可参考:https://www.cnblogs.com/emanlee/archive/2008/10/25/1319569.html
理论频数计算:
> b <- data.frame(CD=c(19,34), contol=c(24,10))
> b
CD contol
1 19 24
2 34 10
> chisq.test(b)$expected
CD contol
[1,] 26.1954 16.8046
[2,] 26.8046 17.1954
在通过判断理论值T及总数n进行选择Chi-square test还是Fisher exact test