【发布时间】:2017-01-21 14:53:34
【问题描述】:
我刚刚注意到,对于单元格频率较低的 2 x 2 表,即使进行了 Yates 校正,R 似乎也错误地计算了 chi^2 统计数据。
mat <- matrix(c(3, 2, 14, 10), ncol = 2)
chi <- stats::chisq.test(mat)
## Warning message:
## In stats::chisq.test(mat) : Chi-squared approximation may be incorrect
# from the function
chi$statistic
## X-squared
## 1.626059e-31
# as it should be (with Yates correction)
sum((abs(chi$observed - chi$expected) - 0.5)^2 / chi$expected)
## [1] 0.1851001
我是否认为R 计算不正确,而产生 .185 的第二种方法更准确?还是小细胞计数意味着所有赌注都没有了?
更新:
如果没有 Yates 连续性校正,它似乎确实可以正常工作:
chi <- stats::chisq.test(mat, correct = FALSE)
## Warning message:
## In stats::chisq.test(mat, correct = FALSE) :
## Chi-squared approximation may be incorrect
chi$statistic
## X-squared
## 0.004738562
sum((abs(chi$observed - chi$expected))^2 / chi$expected)
## [1] 0.004738562
【问题讨论】:
-
在卡方上查看 Fisher's Exact Test 以获得更小的单元格计数。
标签: r chi-squared