卡方检验的公式(2×2)

卡方检验的公式(2×2)
A short-cut formula for Chi-square test a 2 by 2 table

最近发现一个快速计算卡方检验的公式。
对于2×2的表格

\(
\begin{array}{|c|c|c|}
\hline
a & b & (a+b)\\ \hline
c & d & (c+d)\\ \hline
(a+c) & (b+d) & n\\ \hline
\end{array}
\)
上式中\(n=a+b+c+d\)

卡方检验的统计量是:
\(
\chi^2_1 = \frac{n(ad-bc)^2}{(a+b)(c+d)(a+c)(b+d)}
\)

这个方法和R计算的结果(不要用continuity correction, e.g. chisq(…, correct = FALSE))是一致的。

-- February 17, 2017更新 --

刚刚发现Matthew’s Correlation Coefficient (MCC)的定义和2×2 table的卡方检验有如下联系
\(
|MCC| = \sqrt{\frac{\chi^2}{n}}
\)
因为MCC的范围是-1到1,因此\(\chi^2 \)的范围是0到\(n\)