# Pearson's independence test

First question here.

I know that for I*J contingency tables, Pearson's test of independence the distribution under null is $\chi^2((I-1)(J-1))$. I am curious why it is the case and no books I see seems to prove this.

You can just give me a link or book/paper names if you have that. I know that by a direct application of multivariate CLT we can test $p=p_0$ for the ($IJ$) cells and the test statistic follows $\chi^2(IJ-1)$.

To be clear, I know intuitive explanation like 'estimating k variables reduces k degree of freedom' and that's not something I want.

Many thanks.

The key part of the proof is to show that Pearson's statistic is a score test statistic. (In theoretical statistics, a score test statistic is one based on the log-likelihood derivatives.) Specifically, let $y_{ij}$, $i=1,\ldots,I$, $j=1,\ldots,J$ be the table of counts. We assume that the $y_{ij}$ are Poisson distributed with means $\mu_{ij}$ given by the log-linear model $$\log\mu_{ij}=\mu_0+\alpha_i+\beta_j$$ where the $\alpha_i$ and $\beta_j$ are row and column effects respectively. Then Pearson's statistic for independence can be shown to be equal to the score test statistic for testing the above log-linear model vs the saturated model in which all the $\mu_{ij}$ are different. The statistic is on $(I-1)(J-1)$ degrees of freedom because that is the difference in the number of parameters in the two models. The proof that Pearson's statistic is a score test is harder than one might expect, and is given here:
Finally, the chisquare distribution for the statistic is proved by showing that the log-likelihood derivatives are asymptotically normal as the means $\mu_{ij}$ become large.