# Is Pearson's chi-squared test of independence conditional on marginal distributions?

The Wikipedia page on Pearson's chi-squared test states that a difference to Fisher's exact test is that the latter makes the "assumption of fixed marginal distributions". I assume that applies to the use of chi-squared as a test of independence, because that is what Fisher's exact test does.

However, the description of the chi-squared test for independence clearly shows that it is a goodness-of-fit test which compares the observed joint distribution $$O_{i,j}$$ to the one expected under independence from the marginal distributions, $$E_{i,j} = N p_{i\cdot} p_{\cdot j},$$ which in turn are estimated from the observed marginals, $$p_{i\cdot} = \frac{O_{i\cdot}}{N} = \frac1N \sum_j O_{ij},$$ and correspondingly for $$p_{\cdot j}$$. As far as I can see that means that the test is conditional on given $$N$$, $$p_{i\cdot}$$, and $$p_{\cdot j}$$.

Can someone clear this up? Maybe Wikipedia is simply wrong?

The "exactness" of Fisher's test depends on the assumption that each of the row totals and column totals (the "margins") is given as part of the experimental design. That's what's meant by "fixed marginal distributions." In that case the distribution of counts among cells exactly follows a hypergeometric distribution.

With the chi-square test, in contrast, only the total number of counts, $$N$$, is taken as pre-specified. Although you do observe particular row totals and column totals, those are not fixed by design. Unlike with pre-specified row and column totals, the statistical test must take into account the sampling variability that might have led to those observed row and column totals, given only the toal number of counts.

In practice, Fisher's test is often applied in situations where the row and column totals weren't fixed by design. That's generally taken to be OK, as the test is then typically more conservative (less likely to report false positives) than alternate tests like chi-square.

• (1) Pearson's test is also asymptotically valid for models with no, either, or both sets of marginal totals fixed. (2) The use of Fisher's Exact Test when marginal totals aren't fixed is often positively argued for - see When and how to avoid inappropriate use of Fisher's exact test & links. Dec 17, 2020 at 8:40
• Fisher himself did not assume the marginals were fixed by the design (although it were in the urexperiment involving Dr. Muriel Bristol tasting tea). He argued that the marginals were ancillary statistics and so could be conditioned upon. (that have been shown in general not to be exactly true). Feb 5, 2021 at 20:06