ft <- fisher.test(my.table)
ft
#
# Fisher's Exact Test for Count Data
#
#data: my.table
#p-value = 2.31e-08
#alternative hypothesis: true odds ratio is not equal to 1
#95 percent confidence interval:
# 2.851947 10.440153
#sample estimates:
#odds ratio
# 5.392849
3条答案
按热度按时间h43kikqp1#
卡方检验没有置信区间(你只是检查第一个分类变量和第二个分类变量是否独立),但是你可以为比例差异计算置信区间,就像这样。
假设您有一些数据,其中第一组中有30%的人报告成功,而第二组中有70%的人报告成功:
现在列联表中有了数据:
你可以在上面运行
chisq.test
,很明显这两个比例是显著不同的,所以分类变量必须是独立的:如果你做
prop.test
,你会发现你有95%的置信度,比例之间的差异在26.29%和53.70%之间,这是有意义的,因为两个观察到的比例之间的实际差异是70%-30%=40%:7xllpg7q2#
对@ mysterous“漂亮回答的补充:如果您有
2x2
列联矩阵,则可以使用fisher.test
而不是prop.test
来检验比例的 * 比率 * 的差异,而不是比率的 * 差异 *。在Fisher精确检验中,零假设对应于比值比(OR)= 1。使用@ mysterRious '示例数据
OR的置信区间以
fit$conf.int
表示为了确认,我们手动计算OR
xnifntxz3#
据我所知,当2X2表中有一个或多个小于5的值时,就会使用fisher.test,但是你在上面的例子中没有做这个限制,为什么它可以使用fisher.test呢?
还有,OR的置信区间是不是只有使用fisher.test才可用?有没有其他方法来计算置信区间?因为感觉我在我的情况下只能使用chisq.test。
非常感谢