Fisher's exact test
The chi-square test relies on an approximation that breaks down when counts are small. Fisher’s exact test (Fisher, 1935) avoids the approximation entirely. Given the table’s row and column totals, it works out the exact probability of every possible table, and asks how unusual yours is.
When to use it
- Two categorical variables, as with chi-square, and any expected count is below 5.
- Small samples in general, such as pilot studies or rare outcomes.
- Whenever you want an exact p-value and the table is small enough to compute it, which modern software usually can.
Remember, the rule is about expected counts (row total × column total / N), not observed ones.
Worked example: cylinders and transmission
In R’s mtcars data, is the number of cylinders related to whether a car has a manual (1) or automatic (0) transmission?
| Cylinders | Automatic | Manual |
|---|---|---|
| 4 | 3 | 8 |
| 6 | 4 | 3 |
| 8 | 12 | 2 |
With only 32 cars, several expected counts fall below 5. The smallest, for six-cylinder manuals, is 7 × 13 / 32 ≈ 2.8. Chi-square isn’t reliable here, so Analytika chooses the exact test.
P-value: 0.009105 P-value method: exact, all 81 tables with the observed margins Table: 2x3 Cramer's V: 0.5226 N: 32 95% CI: [0.1118, 0.8455] Rows excluded for missing values: 0 of 32
> fisher.test(table(mtcars$cyl, mtcars$am)) Fisher's Exact Test for Count Data data: table(mtcars$cyl, mtcars$am) p-value = 0.009105
The exact p-values match. Analytika enumerated all 81 possible tables with these row and column totals. Its test suite checks this case against R.
Interpretation
- p = .009: there’s evidence that number of cylinders and transmission type are associated.
- Cramér’s V = .52, 95% CI [.11, .85]: a strong association, though very imprecise with 32 cars.
- The pattern: most four-cylinder cars were manual (8 of 11), and most eight-cylinder cars automatic (12 of 14).
APA write-up
Because several expected cell counts were below 5, a Fisher-Freeman-Halton exact test was used. Number of cylinders was associated with transmission type, p = .009, Cramér’s V = .52, 95% CI [.11, .85]. Most four-cylinder cars had manual transmissions, while most eight-cylinder cars were automatic.
2×2 tables and the odds ratio
For a 2×2 table, Fisher’s test is usually reported with an odds ratio. For transmission (am) by engine shape (vs) in the same data, Analytika’s 2×2 Fisher template gives an odds ratio of 1.96, 95% CI [0.38, 10.59], p = .473: no evidence of an association, and an interval so wide it’s consistent with a strong effect in either direction. In that case the expected counts were all at least 5, so Analytika’s own choice would have been the chi-square test. That shows the two tests usually agree when counts are adequate.
Common questions
Is Fisher’s test only for 2×2 tables?
No. The Fisher-Freeman-Halton extension handles larger tables, as in the example above. Very large tables with big samples can be slow to compute exactly, but chi-square is fine there anyway.
Why not always use Fisher’s test?
You can, and some statisticians recommend it for any small table. It assumes fixed row and column totals, which makes it slightly conservative in some designs. With large expected counts, chi-square and Fisher give nearly identical answers.
What about Yates’ continuity correction?
It’s an older adjustment that makes 2×2 chi-square tests more conservative. With exact tests readily available, Fisher’s test is usually the better choice for small 2×2 tables.
How to run it
- SPSS: for 2×2 tables, Crosstabs prints Fisher’s test automatically. For larger tables, use Crosstabs → Exact → Exact (this needs the Exact Tests option in some SPSS editions).
- R:
fisher.test(table(df$a, df$b)) - Python:
scipy.stats.fisher_exact(table)(2×2 tables). - Analytika: ask whether two variables are related. It checks expected counts and switches to the exact test when they’re too small.
References
- Fisher, R. A. (1935). The design of experiments. Oliver & Boyd.
More in Categorical data
Try it with the free tools
Run this on your own data
Upload a dataset and ask your question in plain English. Analytika checks the assumptions, picks the test, runs it, and writes the results up in APA format.