Solution
= Solution
{c}
For observed counts $O_{ij}$ in an $r$ by $c$ <contingency table>, Pearson's <chi-squared test> statistic for independence is
$$
\boxed{X^2=\sum_{i,j}\frac{(O_{ij}-E_{ij})^2}{E_{ij}},
\qquad E_{ij}=\frac{O_{i+}O_{+j}}{O_{++}}.}
$$
Under the null model and the usual large-expected-count conditions, its reference distribution is $\chi^2$ with $(r-1)(c-1)$ degrees of freedom.