Chi-Squared Test of Independence

Tests if two Random Variables (X,Y)(X,Y) are independent.

If X,YX,Y are independent, then the Joint Class Probability is the same as the product of the Margin Class Probabilities. Thus the Null Hypothesis is:

H0:pij=pipj.H_0: p_{i j}=p_{i \bullet} \cdot p_{\bullet j}.

Given H0H_{0} the Test Statistic

Tn=i=1rj=1s(NijnNinNjn)2nNinNjnT_n=\sum_{i=1}^r \sum_{j=1}^s \frac{\left(N_{i j}-n \frac{N_{i \bullet}}{n} \frac{N_{\bullet j}}{n}\right)^2}{n \frac{N_{i \bullet}}{n} \frac{N_{\bullet j}}{n}}

should be small.

We can simulate the test statistic by drawing with replacement from box with r×sr\times s types of balls with Relative Frequencies pipjp_{i \bullet} \cdot p_{\bullet j} . For large nn the distribution is actually independent on the probabilities.

The distribution converges to the Chi-Squared Distribution with (r1)(s1)(r-1)\cdot(s-1) Degrees of Freedom.

Hence the Acceptance Domain is asymptoically given by

I=[0,χ(r1)(s1);1α2]I=\left[0, \chi_{(r-1)(s-1) ; 1-\alpha}^2\right]

Without knowing the probabilities the Class Condition can be checked approximately with

nij5n_{ij}\geq 5

Another test of independence is the so-called Exact Test of Fisher

Application

One can best perform this test using a Contingency Table.