01 / 20

Fisher's Exact Test

Understand the gold-standard statistical test for analyzing small-sample categorical data in \(2 \times 2\) contingency tables: when to use it, how it works, and why it matters.

Biostatistics

What is Categorical Data?

In biostatistics, we often measure outcomes that fall into distinct categories rather than continuous numbers. For example: Did the patient recover? (Yes / No). Was the gene expressed? (Present / Absent).

Categorical
Data sorted into groups: Yes/No, Treated/Untreated, Alive/Dead
Continuous
Measured on a scale: blood pressure, weight, temperature

The \(2 \times 2\) Contingency Table

A \(2 \times 2\) table cross-tabulates two binary variables. Each cell holds a count of observations. The row and column totals are called marginal totals.

Outcome Treatment Success Failure Total Drug Placebo Total a b c d
\(a+b\)
\(c+d\)
\(a+c\)
\(b+d\)
n

Why is it Called "Exact"?

Most statistical tests (like the \(\chi^2\) test) use approximations that assume large sample sizes. Fisher's Exact Test computes the exact probability of observing the data, making it valid for any sample size, especially small ones.

Exact
Calculates the precise probability using combinatorics: no approximation needed
Approximate
The \(\chi^2\) test uses a continuous distribution to approximate discrete counts

The Hypergeometric Formula

Fisher's Exact Test calculates the probability of observing a particular table configuration using the hypergeometric distribution. Given fixed marginal totals, the probability of cell \(a\) taking a specific value is:

Breaking Down the Formula

1
Fix the margins: Assume the row totals \((a+b)\), \((c+d)\) and column totals \((a+c)\), \((b+d)\) are given constants.
2
Count arrangements: The numerator counts the ways to split each row's total between the two columns.
3
Divide by total: The denominator counts all possible ways to distribute \(n\) subjects into the first column.
4
Result: A probability between 0 and 1. Smaller values mean the observed table is more unlikely under the null hypothesis of no association.

Fisher's Test vs. \(\chi^2\)

Feature Fisher's Exact \(\chi^2\) Test
Calculation Exact combinatorial Asymptotic approximation
Sample size Any size (even tiny) Needs expected counts > 5
Table size Best for \(2 \times 2\) Any \(r \times c\)
Computation Factorial-based \(\chi^2\) statistic
Null hypothesis No association between row and column variables

How to Apply Fisher's Exact Test

1
Organize data into a \(2 \times 2\) contingency table with cell counts \(a, b, c, d\).
2
State hypotheses: \(H_0\): no association. \(H_a\): there is an association.
3
Calculate the probability of the observed table using the hypergeometric formula.
4
Find all tables with the same marginals that are as extreme or more extreme than observed.
5
Sum the probabilities of all extreme tables to get the \(p\)-value.
6
Compare the \(p\)-value to significance level \(\alpha\) (usually 0.05). If \(p \leq \alpha\), reject \(H_0\).

Example: Drug Trial

A small pilot study tests whether a new drug reduces infection. 12 patients are randomized: 5 receive the drug, 7 receive a placebo.

Observed Data No Infection Infection Total Drug Placebo Total 4 1 2 5 5 7 6 6 12

Computing the Exact Probability

While the factorial formula is correct, it's much easier to calculate using the binomial coefficient form:

Finding More Extreme Tables

Keeping the marginals fixed (row totals 5, 7 and column totals 6, 6), we enumerate all possible tables by varying \(a\). The table is "more extreme" if it shows an even stronger drug effect (higher \(a\)).

\(a = 4\) (observed)
\(P = 0.1136\)
\(a = 5\) (more extreme)
\(P = 0.0076\)

Example 2: A Significant Result

A researcher studies whether a gene mutation is associated with a disease. With only 14 subjects:

Gene Mutation Study Disease Healthy Total Mutation+ Mutation- Total 6 1 1 6 7 7 7 7 14

One-Tailed vs. Two-Tailed Tests

One-Tailed
Tests a directional hypothesis: "Drug is better than placebo." Sum probabilities in one direction only.
Two-Tailed
Tests for any association: "Drug and outcome are related." Sum extreme probabilities from both ends.

Visualizing the \(p\)-value

For fixed marginals, there are only a few possible tables. The \(p\)-value sums the probabilities of tables as extreme or more extreme than observed. Below is a probability distribution for all possible values of cell \(a\) in Example 2 (marginals: 7, 7, 7, 7, \(n=14\)):

Value of a P(a) 0 1 2 3 4 5 6 7 Extreme (summed for p-value) Extreme (other tail)

Common Mistakes

✕ Using \(\chi^2\) for Small Samples
When any expected cell count is below 5, the \(\chi^2\) approximation is unreliable. Use Fisher's instead.
✕ Forgetting to Sum Extreme Tables
The \(p\)-value is NOT just the probability of the observed table. You must include all tables as extreme or more extreme.
✕ Confusing One- and Two-Tailed
A two-tailed test sums extremes from both ends. Using one-tailed when two-tailed is appropriate halves the \(p\)-value incorrectly.

Question 1 of 5

When is Fisher's Exact Test preferred over the \(\chi^2\) test?

Question 2 of 5

In the hypergeometric formula for Fisher's test, what does the denominator \(\binom{n}{a+c}\) represent?

Question 3 of 5

Given a \(2 \times 2\) table with cells \(a = 3\), \(b = 1\), \(c = 1\), \(d = 5\), what is the total sample size \(n\)?

Question 4 of 5

What are the marginal totals in a contingency table?

Question 5 of 5

A Fisher's Exact Test returns \(p = 0.032\). At significance level \(\alpha = 0.05\), what is the correct conclusion?