Testing for independence

H0 :  X and Y are independent
HA :  X and Y are dependent  

The following test statistic is used:

If X and Y are independent
χ2 has (approximately) a chi-squared distribution with no unknown parameters
If X and Y are associated
The pattern of observed counts, nxy, is expected to be different from that of the exy, so χ2 is expected to be larger.

P-value

The p-values is interpreted in the same way as for other hypothesis tests — it describes the strength of evidence against the null hypothesis:

p-value Interpretation
over 0.1 no evidence against the null hypothesis (independence)
between 0.05 and 0.1    very weak evidence of dependence between the row and column variables
between 0.01 and 0.05    moderately strong evidence of dependence between the row and column variables
under 0.01 strong evidence of dependence between the row and column variables

Warning about low estimated cell counts

The χ2 test statistic has only approximately a chi-squared distribution. The p-value found from it can be relied on if:

If the cell counts are small enought that these conditions do not hold, the p-value is less reliable. (But advanced statistical methods are required to do better!)