CHAPTER 05 · TOPIC 06
Fisher’s Exact Test
Use hypergeometric probabilities with fixed marginal totals to perform an exact test for a small-sample 2×2 table.
On this page
Fisher's exact test calculates the probability of each table meeting the null hypothesis directly from the hypergeometric distribution, under the condition that the marginal frequencies of the rows and columns of the 2 × 2 table are fixed. It does not rely on large-sample approximations, so it is important for small samples or when expected frequencies are small.
With Fixed Marginal Totals, Only One Cell Is Free#
Exact Probability of the Observed Table#
The denominator is how to choose R₁ items that go into the first row out of N items. The combination of selecting a pieces from the first column and R₁−a pieces from the second column becomes the numerator, and the probability of a table that maintains the marginal frequency is obtained.
One-Sided p-Value#
Which tail supports the alternative hypothesis is determined by the row/column arrangement and the predetermined direction of the effect. Don't look at the data and choose the smaller one-sided p-value.
Two-Sided p-Value#
Steps to enumerate all tables#
- Calculate R₁, R₂, C₁, C₂, N from the observation table
- Enumerate possible a from a_min to a_max
- Calculate b, c, d and hypergeometric probability for each a
- Define one-sided or two-sided extreme tables depending on alternative hypothesis
- Sum the corresponding probabilities to get the p-value
Comparison of Pearson, Yates, and Fisher#
| method | statistical foundations | approximation | Typical use |
| Pearson χ² | Σ(O−E)²/E | chi-square approximation | sufficient expectation |
| Yates χ² | Σ(|O−E|−0.5)²/E | Corrected chi-square approximation | Smaller 2×2 table, conservative reasoning |
| Fisher accurate | conditional hypergeometric distribution | Unnecessary | Small sample/sparse 2×2 table |
Even though the p-value of the Fisher test is accurate, it does not mean that there is no uncertainty in the effect estimate. Report the OR, appropriate confidence interval, and cell frequency, understanding that it is a conditional inference.