I'm doing association analysis and I'm using a Chi-Squared test on a 2x2 contingency table.

The usual definition of the Chi-Squared test is given e.g. here and here, the term in the denominator is usually the same as the term on the right side in the bracket in the numerator.

So when it's used for analysing the strength of an observed association $p_{12}$ between two events $p_1$ and $p_2$ it could be written like this:

$$ \chi^2 = \frac{N(p_{12}-p_1 p_2)^2}{p_1 p_2} $$

However I found a definition that differs from that one in a script about data mining on page 3.

The author also puts the probabilities of the events not occurring in the denominator:

$$ \chi^2 = \frac{N(p_{12}-p_1 p_2)^2}{p_1 p_2 (1-p_1)(1-p_2)} $$

Given that in my case $p_1$ and $p_2$ are generally very small the term barely changes the results I'm getting, but what is the statistical reasoning behind this? Is it some kind of correction that improves the statistic?


1 Answer 1


This is just the standard chi-square formula $(O-E)^2/E$ applied to a contingency table. However, the chi-square statistic will apply this intuitive formula for all cells in the underlying contingency table, and add them up. So the chi-square statistic for row-column association is of the following form:

$$\chi^2=N\sum_r\sum_c\frac {(f_{rc}-f_{r\bullet}f_{\bullet c})^2}{f_{r\bullet}f_{\bullet c}} $$

Suitably rearranged and simplified. As you have only $4$ cells ($2$ rows and $2$ columns), the joint probabilities can be re-expressed in terms of you $p$ variables in the contingency table as: $$\begin{array}{c|c}\ f_{11}=p_{12} & f_{12}=p_1-p_{12} & f_{1\bullet}=p_1 \\ \hline f_{21}=p_2-p_{12} & f_{22}=1+p_{12} -p_1-p_2 & f_{2\bullet}=1-p_1\\ \hline f_{\bullet 1}=p_2 & f_{\bullet 2}=1-p_2 & f_{\bullet\bullet}=1 \end{array}$$

Your formula applies to the contribution of top-left cell in the contingency table to the chi-square statistic. There is a bit of tedious work in simplifying the squared terms, but you have:

$$\begin{array}{c|c}\ (p_{12}-p_1p_2)^2 & (p_1-p_{12}-p_1(1-p_2))^2 \\ \hline (p_2-p_{12}-(1-p_1)p_2)^2 & (1+p_{12} -p_1-p_2-(1-p_1)(1-p_2))^2\\ \end{array} =\begin{array}{c|c}\ (p_{12}-p_1p_2)^2 & (p_1p_2-p_{12})^2 \\ \hline (p_1p_2-p_{12})^2 & (p_{12} -p_1p_2)^2\\ \end{array}$$

So this shows the numerator contribution to the chi-square statistic from each cell in the contingency table is the same, and equal to $N(p_{12}-p_1p_2)^2$. Now all that is left is to show that the sum of the denominators is equal to the combined denominator. We have:

$$\frac{1}{p_1p_2}+\frac{1}{p_1(1-p_2)}+\frac{1}{(1-p_1)p_2}+\frac{1}{(1-p_1)(1-p_2)} =\frac{(1-p_1)(1-p_2)+(1-p_1)p_2+p_1(1-p_2)+p_1p_2}{p_1p_2(1-p_1)(1-p_2)} =\frac{[1-p_1-p_2+p_1p_2]+[p_2-p_1p_2]+[p_1-p_1p_2]+p_1p_2}{p_1p_2(1-p_1)(1-p_2)}=\frac{1}{p_1p_2(1-p_1)(1-p_2)}$$

Putting this all together and you have the final answer:


  • $\begingroup$ I'm a bit confused about the $N$ though. The $N$ from my initial equation is the total number of observations, but if I add up the four terms over the cells then I would have another factor of $4$ which is the number of cells. Doesn't that mean that the final factor should atually by $4N$? $\endgroup$
    – Khris
    Dec 19, 2016 at 14:04
  • 1
    $\begingroup$ The summation is of the form $\frac {Ne}{a}+\frac {Ne}{b}+\frac {Ne}{c}+\frac {Ne}{d} $. If $a=b=c=d $ then you do indeed get $4\frac {Ne}{a} $ as you suggest - this occurs when $p_1=p_2=\frac {1}{2} $. But this formula is more general. You can think of the term $\frac {1}{(1-p_1)(1-p_2)} $ as a more general factor than $4$ $\endgroup$ Dec 19, 2016 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.