Fisher’s exact test
Fisher’s exact test checks association in a 2×2 table by comparing tables with the same margins.
Fit
When to use it, and when not to
Use it when
- Two independent groups have a binary outcome, especially when expected cell counts are small.
- You want conditional inference, with the two-sided definition stated explicitly.
Not when
- Outcomes are paired within people. Use McNemar’s test, covered in the categorical-tests overview. Read: Choosing a test for a table of counts
- A binary outcome needs covariate adjustment. Use logistic regression. Read: Logistic regression
- Patients are clustered within wards. Use a model that accounts for clustering. Read: Mixed-effects models
Before you start
What you need
- Four nonnegative integer cell countsUse one row per group and one column per outcome category.
- The planned direction and two-sided conventionMallard sums probabilities of tables no more probable than the observed table.
- The effect measure and interval you will reportA test result alone does not give the size or precision of the association.
- Different people contribute independent observations.How to check: Do not enter paired measurements as separate independent groups.
- Inference conditions on the observed row and column totals.How to check: Decide whether this conditional question fits the sampling design and analysis plan.
Plain language
How it works
Keep both row totals and both column totals fixed. Enumerate the possible 2×2 tables. Under no association, each table has a hypergeometric probability. Sum the probabilities of tables no more likely than the observed one for Mallard’s two-sided result.
Lydersen and colleagues compared conditional and alternative tests. Their work explains why exact conditional inference can be conservative and less powerful. It does not justify treating Fisher’s test as a universal upgrade.
Worked example
A worked example
- Setting
- Two independent groups each have 20 patients.
- Question
- Is the binary outcome associated with group?
- Approach
- Group 1 counts: 2 positive, 18 negative. Group 2 counts: 8 positive, 12 negative.
- Result
- The two-sided exact p = 0.065. The sample cross-product odds ratio is 0.17; the observed risks are 10 in 100 and 40 in 100.
- What it means
- The result does not establish equal risks. The displayed odds ratio is the sample cross-product ratio, not a conditional maximum-likelihood estimate.
In practice
Recent studies PubMed search · not vetted
Watch out
Common mistakes
The one to remember
Fisher’s exactness is conditional on the table margins. Its discreteness can make it conservative. Paired observations need a paired method.
- Doubling a one-sided p-value without naming the convention.Instead: Different two-sided definitions can give different values. State the method used.
- Assuming exact means most powerful or unbiased.Instead: Conditioning and discrete counts can make Fisher’s test conservative. Choose the test for the design.
Inside Mallard
How Mallard uses this
Mallard links this article to its Fisher calculator. It reports a probability-ordered two-sided p-value and sample cross-product odds ratio. The method registry links this method to its published analysis article and code.
fisher-exact-conditional-odds-ratio).analysis.fisher_exact, the id a plan cue records.Work it out
Related Learn pages
Related designs and methods
Evidence
Sources & further reading
- Power comparison of two-sided exact tests for association in 2 x 2 contingency tables using standard, mid p and randomized test versions (opens in a new tab) · Stat Med · doi 10.1002/sim.1671
- Recommended tests for association in 2 x 2 tables (opens in a new tab) · Stat Med · doi 10.1002/sim.3531