Fisher Exact Test
Reviewed byRemya Krishnan
Definition
The Fisher exact test is a statistical test used to determine whether there is a significant association between two categorical variables in a 2 x 2 contingency table. Unlike the chi square test, which uses an approximation, the Fisher exact test calculates the exact probability of obtaining the observed distribution (or one more extreme) under the null hypothesis of no association, given the observed row and column totals.[3] It is particularly appropriate when sample sizes are small.
Explore the concept
Five tables, one exact p
Slide the four liver events between the arms to see every table the margins allow, then switch conventions and watch which tables add up to the p value.
Margins stay fixed
4 events · 45 drug · 42 placebo · 87 patientsThis table's probability
6.7%
if the drug has no effect
p value
0.12
2 of 5 tables counted
The trial's table: p = 0.12
The big idea: The Fisher exact test lists every 2 x 2 table with the observed margins and adds up the probabilities of those at least as extreme as the one observed. It needs no large sample approximation, but with very few events it is conservative, and two sided p values depend on the convention the software uses.
Figures are the article's liver toxicity example: 4 of 45 patients on the drug (8.9%) and 0 of 42 on placebo, two sided p = 0.12. Computed here with scipy: hypergeometric probabilities of the five possible tables (5.0, 23.2, 38.3, 26.8 and 6.7%), the two sided p (0.117, summing tables no more likely than the observed), the doubled one sided p (0.134), the one sided p (0.067), the p for each hypothetical split (the smallest, 0.050, when all 4 events are on placebo), the expected counts (2.1 and 1.9) and the uncorrected chi square p (0.048). The other splits are what ifs, not trial results.
Why it matters
Many research questions involve testing associations between two categorical variables when sample sizes are limited. The chi square test, the most commonly used alternative, relies on a large sample approximation that becomes inaccurate when expected cell frequencies are small (conventionally below 5).[1][2] In these situations, the Fisher exact test provides a reliable p value by computing exact probabilities rather than relying on approximations. It is widely used in medical research, genetics, epidemiology, and any field where researchers encounter small sample sizes or rare events. Clinical trials often use it for safety analyses, where adverse events may be rare and standard asymptotic tests would be unreliable.
How it works
The Fisher exact test is based on the hypergeometric distribution.[3] It considers all possible 2 x 2 tables that have the same row and column totals (marginals) as the observed table and calculates the probability of each under the null hypothesis of independence. The p value is the sum of the probabilities of all tables as extreme as or more extreme than the observed table. For a one sided test, "more extreme" means further in the specified direction. For a two sided test, the most common definition, used by R and SciPy, sums every table whose probability is no greater than that of the observed table; another convention doubles the one sided p value, so software can report different two sided p values for the same table.[3][4][5]
For a 2 x 2 table with cells a, b, c, and d, and marginal totals R1 = a + b, R2 = c + d, C1 = a + c, and C2 = b + d, the probability of the observed table is given by the hypergeometric formula: (R1! × R2! × C1! × C2!) divided by (N! × a! × b! × c! × d!), where N is the total sample size. The test can be one sided (testing for association in a specified direction) or two sided (testing for any association).
For tables larger than 2 x 2, extensions of the Fisher exact test exist (such as the Freeman Halton test), though computational demands increase substantially with table size.[3] Modern statistical software handles these computations efficiently, making the Fisher exact test practical even for moderately large tables.
The test is conservative, particularly with small samples. Because it conditions on both sets of margins, only a limited number of tables are possible, so the p value can take only a few distinct values and the actual Type I error rate is often well below the nominal alpha; it also tends to reject less often than the uncorrected chi square test. Some statisticians recommend the mid p value, which counts only half the probability of the observed table, to reduce this conservatism, at the cost of no longer guaranteeing that the Type I error rate stays at or below alpha.[3]
When to use it
The Fisher exact test should be used when analyzing 2 x 2 contingency tables with small sample sizes (by a common rule of thumb that goes back to Cochran, when any expected cell frequency is below 5), when analyzing rare events (such as adverse reactions in clinical trials), and when exact p values are needed rather than approximations.[1][2] It is also appropriate as a default test for 2 x 2 tables in any sample size, since it remains valid at any sample size (its Type I error rate does not exceed the chosen alpha) and modern computers can handle the computation easily, although it is conservative. The chi square test remains more practical for larger tables (beyond 2 x 2) with adequate cell sizes.
Key takeaways
- Many research questions involve testing associations between two categorical variables when sample sizes are limited.
- It considers all possible 2 x 2 tables that have the same row and column totals (marginals) as the observed table and calculates the probability of each under the null hypothesis of independence.
- The Fisher exact test should be used when analyzing 2 x 2 contingency tables with small sample sizes (by a common rule of thumb that goes back to Cochran, when any expected cell frequency is below 5), when analyzing rare events (such as adverse reactions in clinical trials), and when exact p values are needed rather than approximations.
- A common error is using the chi square test when expected cell frequencies are very small, producing inaccurate p values, when the Fisher exact test would be appropriate.
Common mistakes
- A common error is using the chi square test when expected cell frequencies are very small, producing inaccurate p values, when the Fisher exact test would be appropriate. Conversely, some researchers believe the Fisher exact test can only be used with small samples, when in fact it is valid for any sample size.
- Another mistake is applying only a one sided test without justification; unless there is a strong a priori reason to expect the association in a particular direction, a two sided test should be used.
- Researchers sometimes report Fisher exact test results without also reporting the observed proportions or odds ratio, making the clinical or practical significance of the association impossible to evaluate.
- Finally, applying the Fisher exact test to data with more complex structures (such as matched pairs or repeated measures) is incorrect; these designs require other methods such as McNemar's test.[1]
Example
A clinical trial examines whether a new drug causes liver toxicity. Among 45 patients receiving the drug, 4 develop elevated liver enzymes (8.9%). Among 42 patients receiving placebo, 0 develop elevated liver enzymes (0%). The 2 x 2 table has very small expected cell frequencies (expected count for the drug plus liver toxicity cell is approximately 2.1), making the chi square test inappropriate. The Fisher exact test yields p = 0.12 (two sided). With only 4 patients having the event, no possible split of those events between the two arms could give a two sided p value below 0.05, which shows how conservative the test is when events are very few. Despite the numerical difference in proportions, the result is not statistically significant at the 0.05 level, although the investigators flag liver toxicity for monitoring in subsequent larger trials.
Test your understanding
5 questions that adapt as you go: answer two in a row correctly and they get harder.
Question 1 of 5
Scenario:
For the same 2 x 2 table, one statistics program reports a two sided Fisher p-value of 0.117 and another reports 0.134.
Question:
Why do the two programs disagree?
Hardness: Interpret
Sources
- [1]Field A. Discovering Statistics Using IBM SPSS Statistics. 6th ed. SAGE Publications, 2024. ISBN 9781529630008
- [2]Cochran WG. Some methods for strengthening the common χ² tests. Biometrics. 1954;10(4):417-451. doi:10.2307/3001616
- [3]Agresti A. A survey of exact inference for contingency tables. Stat Sci. 1992;7(1):131-153. doi:10.1214/ss/1177011454
- [4]R Core Team. fisher.test: Fisher's Exact Test for Count Data. R documentation, package stats. https://stat.ethz.ch/R-manual/R-devel/library/stats/html/fisher.test.html
- [5]SciPy Developers. scipy.stats.fisher_exact. SciPy v1.18.0 Manual. https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.fisher_exact.html
Cite this term
Paperguide. (2026, October 15). Fisher Exact Test. In Paperguide Research Glossary. https://paperguide.ai/research-glossary/fisher-exact-test/(Paperguide, 2026)