Tutorials › Biostatistics › Fisher’s Exact Test for Small Sample Sizes

Categorical Data & Exact Tests

Fisher's Exact Test for Small Sample Sizes

A practical guide to Fisher's exact test for 2×2 contingency tables, including the hypergeometric distribution, exact p-values, one-sided and two-sided tests, odds ratios, a complete clinical-trial example, and implementation in R.

Intermediate 15 min read

What You'll Learn

  • Why Fisher's exact test is useful when sample sizes or cell counts are small
  • How a 2×2 contingency table is represented mathematically
  • How the hypergeometric distribution produces the exact probability
  • How one-sided and two-sided Fisher p-values are constructed
  • How to interpret Fisher's test alongside an odds ratio and confidence interval
  • How to perform Fisher's exact test in R and avoid common reporting mistakes

Introduction

Clinical trials frequently compare two groups on a binary outcome: response versus non-response, treatment success versus failure, adverse event versus no adverse event, or disease present versus absent.

These data are commonly summarized using a 2×2 contingency table. When sample sizes are large, a Pearson chi-square test is often appropriate. But when the sample size is small, or when one or more expected cell counts are small, the usual chi-square approximation may be unreliable.

Fisher's exact test provides an alternative. Rather than relying on an asymptotic chi-square distribution, Fisher's test calculates probabilities directly from the observed margins of the contingency table.

Key idea: Fisher's exact test evaluates the probability of obtaining the observed 2×2 table, or tables at least as extreme according to the selected alternative, under the null hypothesis of no association between the two categorical variables.

When Is Fisher's Exact Test Used?

Fisher's exact test is especially useful when the data form a 2×2 contingency table and the sample size is small.

Examples in clinical research include:

  • A small Phase I or Phase II study comparing response rates
  • A rare adverse event occurring in only a few patients
  • A pilot study with very few participants
  • A small diagnostic study with sparse cells
  • A small case-control study
  • A subgroup analysis with limited observations

There is no universal sample-size cutoff that says Fisher's test must be used. The important issue is whether the approximation underlying the chi-square test is adequate for the observed data and the analysis objective.

Important: The familiar rule that Fisher's exact test is required whenever an expected cell count is below 5 is a useful teaching heuristic, but it is not a universal law. The choice between exact and asymptotic methods should be based on the design, sparsity of the data, estimand, and prespecified statistical analysis plan.

The 2×2 Contingency Table

Suppose a clinical trial compares an experimental treatment with a control. The binary outcome is response.

Response No Response Total
Treatment \(a\) \(b\) \(a+b\)
Control \(c\) \(d\) \(c+d\)
Total \(a+c\) \(b+d\) \(n\)

The total sample size is:

\[ n=a+b+c+d \]

The treatment response rate is:

\[ \hat p_T=\frac{a}{a+b} \]

and the control response rate is:

\[ \hat p_C=\frac{c}{c+d} \]

The question is whether the observed difference in response is compatible with the null hypothesis of no association between treatment assignment and response.

The Null Hypothesis

For a 2×2 table, Fisher's exact test is commonly expressed as a test of independence.

The null hypothesis is:

\[ H_0:\text{treatment assignment and outcome are independent} \]

For a treatment-response example, this can equivalently be expressed as:

\[ H_0:p_T=p_C \]

The alternative may be two-sided:

\[ H_A:p_T\ne p_C \]

or directional. For example, if the scientific question is whether the experimental treatment has a higher response rate:

\[ H_A:p_T>p_C \]
Prespecify the alternative. A one-sided Fisher test should be used only when a directional hypothesis was specified before examining the observed results. Switching from a two-sided test to a one-sided test after seeing the data is not a valid way to obtain a smaller p-value.

Why the Chi-Square Approximation Can Be Problematic

The Pearson chi-square test uses an asymptotic approximation. Its test statistic is approximately chi-square distributed when the sample size is sufficiently large.

With sparse data, however, the approximation can be poor.

Consider a table in which several cells contain zero, one, or two observations. The possible tables are highly discrete, and a continuous chi-square distribution may not accurately represent the exact sampling distribution.

Fisher's approach avoids this approximation by calculating probabilities from the exact distribution implied by the table margins.

The Key Idea: Fixed Margins

Fisher's exact test conditions on the marginal totals. For the general table:

Response No Response Total
Treatment \(a\) \(b\) \(a+b\)
Control \(c\) \(d\) \(c+d\)
Total \(a+c\) \(b+d\) \(n\)

Once the margins are fixed, the number of treatment patients who respond is a hypergeometric random variable.

This is the mathematical foundation of Fisher's exact test.

The Hypergeometric Distribution

Suppose:

  • \(n\) = total number of patients
  • \(K\) = total number of responses
  • \(n_T\) = number assigned to treatment
  • \(X\) = number of responders assigned to treatment

Then, conditional on the margins:

\[ X\sim\operatorname{Hypergeometric}(N=n,\;K,\;n_T) \]

The probability of observing exactly \(x\) treatment responders is:

\[ P(X=x) = \frac{ {K\choose x} {n-K\choose n_T-x} }{ {n\choose n_T} } \]

This formula is the heart of Fisher's exact test.

What Does the Hypergeometric Formula Mean?

The numerator counts the number of ways to select:

  • \(x\) responders for the treatment group, and
  • \(n_T-x\) nonresponders for the treatment group.

The denominator counts all possible ways to select \(n_T\) patients from the full population of \(n\) patients.

Therefore, the ratio gives the probability of obtaining exactly \(x\) treatment responders given the fixed row and column totals.

Why is this called "exact"? The probability is calculated from the discrete hypergeometric distribution rather than from a large-sample approximation such as the chi-square distribution.

A Complete Worked Clinical Example

Suppose a small randomized clinical study compares an experimental treatment with control. The primary binary outcome is clinical response. The study contains only 20 patients, with 10 assigned to each group.

The observed results are:

Response No Response Total
Experimental 7 3 10
Control 1 9 10
Total 8 12 20

The observed response rates are:

\[ \hat p_T=\frac{7}{10}=0.70 \]

and:

\[ \hat p_C=\frac{1}{10}=0.10 \]

The observed difference in response rates is therefore:

\[ \hat p_T-\hat p_C = 0.70-0.10 = 0.60 \]

or 60 percentage points.

Step 1: Identify the Margins

The table has:

  • 20 total patients
  • 10 treatment patients
  • 10 control patients
  • 8 total responders
  • 12 total nonresponders

Under Fisher's exact framework, these margins are treated as fixed for the conditional calculation.

Let \(X\) be the number of responders in the experimental group. The observed value is:

\[ X=7 \]

Step 2: Determine the Possible Values of \(X\)

Because there are only 8 responders in total and 10 patients in the treatment group, the treatment group could have received between 0 and 8 of the responders.

Thus:

\[ X\in\{0,1,2,3,4,5,6,7,8\} \]

Each possible value corresponds to a different 2×2 table with the same marginal totals.

Step 3: Calculate the Probability of the Observed Table

For the observed value \(X=7\):

\[ P(X=7) = \frac{ {8\choose7} {12\choose3} }{ {20\choose10} } \]

The individual components are:

\[ {8\choose7}=8 \]

and:

\[ {12\choose3}=220 \]

while:

\[ {20\choose10}=184756 \]

Therefore:

\[ P(X=7) = \frac{8\times220}{184756} \approx0.009472 \]

So the probability of obtaining exactly this table, conditional on the marginal totals, is approximately 0.00947.

Step 4: What Does "Exact" Testing Actually Do?

Fisher's test does not usually stop after calculating the probability of the observed table.

For a one-sided test asking whether the treatment response rate is higher, we consider tables at least as favorable to the treatment as the observed table.

Here the observed treatment group has 7 of the 8 total responses. The more extreme tables in the direction of treatment benefit include:

\[ X=8 \]

as well as the observed:

\[ X=7 \]

Therefore, the one-sided p-value is:

\[ p_{\text{one-sided}} = P(X\ge7) \]

Step 5: Calculate the One-Sided p-Value

We already calculated:

\[ P(X=7)\approx0.009472 \]

Now calculate the probability of \(X=8\):

\[ P(X=8) = \frac{ {8\choose8} {12\choose2} }{ {20\choose10} } \]

Since:

\[ {8\choose8}=1 \qquad\text{and}\qquad {12\choose2}=66 \]

we obtain:

\[ P(X=8) = \frac{66}{184756} \approx0.000357 \]

Therefore:

\[ p_{\text{one-sided}} = P(X\ge7) = P(X=7)+P(X=8) \]
\[ p_{\text{one-sided}} \approx 0.009472+0.000357 = 0.009829 \]

Thus the one-sided Fisher exact p-value is approximately:

\[ \boxed{p\approx0.0098} \]

At a conventional one-sided significance level of 0.05, this provides evidence against the null hypothesis in favor of a higher response rate in the experimental group.

Two-Sided Fisher's Exact Test

A two-sided test asks whether the two groups differ in either direction. The alternative is:

\[ H_A:p_T\ne p_C \]

The two-sided p-value is more complicated than simply doubling a one-sided Fisher p-value.

A commonly used definition sums the probabilities of all tables that are at least as unlikely as the observed table under the null distribution.

For the worked example, the two-sided Fisher p-value is approximately:

\[ \boxed{p_{\text{two-sided}}\approx0.0198} \]

This is smaller than 0.05, so the data provide evidence of an association between treatment group and response.

Important: There are different conventions for defining a two-sided exact p-value. Statistical software may use a probability-ordering rule, and different exact-test procedures can therefore produce slightly different two-sided p-values. The analysis plan should identify the method used.

One-Sided vs. Two-Sided Testing

Question Alternative Worked Example
Does treatment improve response? \(p_T>p_C\) Approximately 0.0098
Do treatment groups differ? \(p_T\ne p_C\) Approximately 0.0198
Does treatment reduce response? \(p_T Large p-value for this observed table

In most confirmatory clinical trials, the directionality of the hypothesis and the significance level should be specified prospectively.

The Odds Ratio

Fisher's exact test answers a hypothesis-testing question, but it does not by itself describe the magnitude of the association.

For a 2×2 table:

\[ \begin{array}{c|cc} & \text{Response} & \text{No Response}\\ \hline \text{Treatment} & a & b\\ \text{Control} & c & d \end{array} \]

the cross-product odds ratio is:

\[ OR=\frac{ad}{bc} \]

For the worked example:

\[ OR = \frac{7\times9}{3\times1} = 21 \]

Thus the estimated odds of response are approximately 21 times as high in the experimental group as in the control group.

Do not confuse an odds ratio with a risk ratio. An odds ratio compares odds, not probabilities. When the outcome is common, the odds ratio can be substantially farther from 1 than the corresponding risk ratio.

Response Rates, Risk Ratio, and Odds Ratio

For the worked example:

\[ p_T=0.70 \qquad p_C=0.10 \]

The risk ratio is:

\[ RR = \frac{0.70}{0.10} = 7 \]

The odds in the treatment group are:

\[ \frac{0.70}{0.30} = 2.333 \]

The odds in the control group are:

\[ \frac{0.10}{0.90} = 0.1111 \]

Therefore:

\[ OR = \frac{2.333}{0.1111} = 21 \]
Measure Value Interpretation
Risk difference 0.60 60 percentage-point higher response
Risk ratio 7.0 Seven times the response probability
Odds ratio 21.0 Twenty-one times the odds of response
Fisher two-sided p-value Approximately 0.0198 Evidence of an association

Fisher's Test Is a Test, Not an Effect Estimate

A common reporting mistake is to report only:

"Fisher's exact test was significant, \(p=0.0198\)."

That does not tell the reader how large the treatment difference was.

A stronger clinical report provides:

  • Response counts
  • Response percentages
  • An effect estimate such as an odds ratio or risk ratio
  • A confidence interval when appropriate
  • The exact p-value

The p-value addresses compatibility with the null hypothesis; the effect estimate addresses the magnitude of the observed association.

Confidence Intervals for the Odds Ratio

For small samples, the odds-ratio confidence interval can be very wide. This is not a flaw in Fisher's test. It reflects the limited information available in a small study.

In the worked example, the point estimate is:

\[ OR=21 \]

But the uncertainty around an odds ratio estimated from only 20 patients can be substantial.

Small sample sizes create two separate issues: the p-value may require an exact method, while the effect estimate may remain highly imprecise. A statistically significant Fisher test does not imply that the effect estimate is precise.

Why Zero Cells Matter

Small clinical datasets often contain zero counts. For example:

Response No Response
Treatment 0 10
Control 5 5

The usual cross-product odds ratio is:

\[ OR=\frac{0\times5}{10\times5}=0 \]

This can create problems for methods based on the logarithm of the odds ratio, because:

\[ \log(0) \]

is undefined.

Fisher's exact test itself can still be calculated.

This is one reason exact tests are particularly useful for sparse categorical data.

Fisher's Test Does Not Require Large Expected Counts

The chi-square test typically relies on expected counts being sufficiently large for its asymptotic approximation. Fisher's exact test does not make the same large-sample approximation.

For this reason, a table containing expected counts well below 5 can still be an appropriate setting for Fisher's exact test.

Situation Potential Approach
Large sample, adequately populated cells Pearson chi-square may be appropriate
Small sample or sparse 2×2 table Fisher's exact test is often appropriate
Zero or very small observed cells Exact methods are particularly useful
Large stratified trial Consider methods such as CMH or regression models

Fisher's Test and Randomization

There is an intuitive way to understand the exact test. Imagine that the 20 patients in the worked example are fixed, including their 8 responders and 12 nonresponders. Under the null hypothesis, treatment assignment is unrelated to response. If 10 of the 20 patients are assigned to treatment, different allocations of the 8 responders across the treatment and control groups are possible.

Fisher's test asks: How unusual is the observed allocation of responders?

The hypergeometric distribution provides the exact answer.

1
Fix the observed row and column totals.
2
Enumerate possible treatment/control allocations consistent with those margins.
3
Calculate the hypergeometric probability of each possible table.
4
Identify the observed table and the tables considered at least as extreme.
5
Sum the relevant probabilities to obtain the exact p-value.

The Possible Tables in the Worked Example

Because the margins are fixed, the entire probability distribution can be listed.

\(X\): Treatment Responders Treatment Responders Control Responders
0 0 8
1 1 7
2 2 6
3 3 5
4 4 4
5 5 3
6 6 2
7 7 1
8 8 0

The observed study corresponds to \(X=7\). For a directional test favoring treatment, the relevant tail is:

\[ X\ge7 \]

which contains the observed table and the even more treatment-favorable \(X=8\) table.

Why Fisher's Test Is Especially Useful in Small Phase II Studies

Early clinical development frequently involves relatively small patient populations. Suppose a Phase II pilot study enrolls only 12 or 20 patients. A response comparison might look like:

Response No Response
Experimental 6 4
Control 1 1

The table is highly sparse. An asymptotic approximation may not provide a reliable description of the sampling distribution, while Fisher's exact test remains directly applicable.

Fisher's Exact Test vs. Pearson Chi-Square

Feature Fisher's Exact Test Pearson Chi-Square
Primary distribution Hypergeometric Chi-square approximation
Large-sample approximation Not required for the basic 2×2 test Yes
Small samples Well suited May be unreliable
Sparse cells Useful Can be problematic
Zero cells Can be handled May create issues for approximations
Computational burden Historically greater Very small
Modern software Easy to compute Easy to compute

Modern computers make Fisher's test computationally straightforward even for many practical applications.

Does Fisher's Exact Test Always Give a More Conservative Result?

Fisher's exact test is sometimes described as "conservative." That description should be used carefully.

The discreteness of the exact distribution can make attainable p-values coarse, particularly in very small samples. For example, a p-value may jump from a value below 0.05 to a value above 0.05 because only a limited number of possible tables exist.

However, the exact test is not simply a universally conservative replacement for chi-square testing. The results depend on:

  • The observed margins
  • The alternative hypothesis
  • The definition of the exact tail
  • The chosen test statistic or ordering rule

Two-Sided p-Values Require Special Care

One of the most common sources of confusion is the two-sided Fisher p-value. For a normal or t distribution, doubling a one-sided tail probability is often straightforward. For a discrete hypergeometric distribution, there is no single universally obvious way to define "equally extreme" tables.

One widely used definition is the probability-ordering approach:

\[ p_{\text{two-sided}} = \sum_{\text{tables with }P(T)\le P(T_{\text{obs}})} P(T) \]

where \(T\) denotes a possible table.

Other exact-test definitions are possible.

Practical recommendation: When reporting a Fisher two-sided p-value in a clinical analysis, identify the software or statistical method used if the exact-test definition could affect reproducibility.

Fisher's Test Is Conditional

A subtle but important point is that Fisher's exact test conditions on the marginal totals. This means the test is not simply asking whether two independently estimated binomial proportions differ without qualification.

Instead, it evaluates the distribution of one cell count conditional on the observed margins.

This conditional perspective is particularly natural in randomized experiments, where treatment-group sizes are fixed by design.

Fisher's Test and Randomized Clinical Trials

Suppose a randomized trial assigns exactly 10 patients to each treatment group. The treatment-group total is therefore fixed by design. If the total number of observed responders is also conditioned upon, the hypergeometric distribution describes how those responders could have been distributed between the two treatment groups under the null hypothesis.

This provides an intuitive connection between randomization and Fisher's exact test.

Clinical interpretation: Fisher's exact test asks whether the observed concentration of responses in one treatment group would be unusual if treatment assignment had no relationship with response, conditional on the margins.

R Implementation

In R, Fisher's exact test is performed using the built-in fisher.test() function.

First create the 2×2 table:

tab <- matrix(
  c(7, 3,
    1, 9),
  nrow = 2,
  byrow = TRUE
)

dimnames(tab) <- list(
  Treatment = c("Experimental", "Control"),
  Outcome = c("Response", "No Response")
)

tab

The resulting table is:

            Outcome
Treatment    Response No Response
Experimental        7           3
Control             1           9

Two-Sided Fisher's Exact Test in R

fisher.test(
  tab,
  alternative = "two.sided"
)

The resulting two-sided p-value is approximately:

p-value
0.01977

The odds ratio estimate is:

odds ratio
21

R also provides an exact confidence interval for the odds ratio.

One-Sided Fisher's Exact Test in R

If the prespecified alternative is that the experimental treatment has a higher response rate:

fisher.test(
  tab,
  alternative = "greater"
)

For this table, the one-sided p-value is approximately:

p-value
0.00983

The direction of the alternative depends on the ordering of the table. Here the experimental group is the first row, so greater corresponds to greater odds of response in the experimental group.

Always check the table orientation. The words greater and less are interpreted relative to the odds ratio defined by the table ordering. Reversing the rows or columns can reverse the directional interpretation.

Extracting the Odds Ratio and p-Value

result <- fisher.test(
  tab,
  alternative = "two.sided"
)

result$estimate
result$p.value
result$conf.int

This makes it easy to incorporate Fisher's test into an analysis pipeline.

Calculating the Hypergeometric Probability in R

The exact probability underlying Fisher's test can also be calculated using R's hypergeometric distribution functions.

For the worked example:

  • Total population: \(N=20\)
  • Total responders: \(K=8\)
  • Treatment-group size: \(n_T=10\)
  • Observed treatment responders: \(x=7\)

The exact probability is:

dhyper(
  7,
  m = 8,
  n = 12,
  k = 10
)

which gives approximately:

0.009472

This is the probability of exactly the observed \(X=7\) table.

Calculating the One-Sided Tail in R

The probability of observing 7 or more treatment responders is:

phyper(
  6,
  m = 8,
  n = 12,
  k = 10,
  lower.tail = FALSE
)

This gives approximately:

0.009829

which matches the one-sided Fisher exact p-value.

Building the Exact Distribution

It can be instructive to calculate all possible hypergeometric probabilities.

x <- 0:8

prob <- dhyper(
  x,
  m = 8,
  n = 12,
  k = 10
)

data.frame(
  treatment_responders = x,
  probability = prob
)

The probabilities sum to one:

sum(prob)
# 1

This is the complete conditional null distribution for the number of treatment responders given the margins.

Why the Exact Distribution Is Discrete

Unlike a normal distribution, the hypergeometric distribution can only take integer values. For the worked example:

\[ X=0,1,2,\ldots,8 \]

There is no possible value such as:

\[ X=7.35 \]

This discreteness is why exact p-values can behave differently from large-sample approximations.

Fisher's Exact Test With Very Small Samples

Consider an even smaller study:

Event No Event
Treatment 0 5
Control 4 1

Here, the sample size is only 10 and one cell is zero. An exact method is particularly natural.

The Fisher two-sided p-value for this table is approximately:

\[ p\approx0.0476 \]

The exact test can therefore be performed without relying on a large-sample chi-square approximation.

Fisher's Test and Rare Adverse Events

Fisher's exact test is also common when comparing rare safety events. For example:

Serious AE No Serious AE
Experimental 1 29
Control 5 25

Even though the overall sample contains 60 patients, the event counts are small. The sparse-event structure can make an exact analysis attractive, particularly when the primary question concerns a simple 2×2 comparison.

Safety analyses require additional context. A Fisher test for a rare adverse event does not replace clinical review of event severity, timing, exposure, multiple safety endpoints, or the overall safety profile.

Fisher's Test for Diagnostic Studies

The same framework applies to diagnostic accuracy studies. For example:

Disease No Disease
Test Positive 8 1
Test Negative 2 9

A Fisher exact test can assess association between test result and disease status when the sample is small. However, diagnostic studies usually require additional measures such as:

  • Sensitivity
  • Specificity
  • Positive predictive value
  • Negative predictive value
  • Likelihood ratios
  • Confidence intervals

The Fisher p-value should therefore be viewed as only one component of the analysis.

Fisher's Test Does Not Measure Clinical Importance

Suppose a very small trial produces a large response difference but a non-significant p-value. That does not necessarily mean the treatment difference is clinically unimportant.

It may simply mean the study does not contain enough information to establish the effect with the desired statistical certainty.

Conversely, in a very large study, a tiny treatment difference can produce a very small p-value.

Statistical significance is not clinical significance. Always examine the magnitude and uncertainty of the treatment effect rather than interpreting the Fisher p-value in isolation.

Fisher's Test vs. Barnard's Exact Test

Fisher's exact test is not the only exact method for a 2×2 table. Another approach is Barnard's exact test.

The conceptual distinction is important. Fisher's test conditions on both margins, whereas Barnard's test is an unconditional exact test and does not condition on the total number of events in the same way.

Feature Fisher Barnard
Exact method Yes Yes
Conditions on margins Yes No
Primary distribution Hypergeometric Unconditional binomial framework
Common clinical software support Very broad Less universal

Fisher's test remains extremely common because it is conceptually simple, well established, and widely implemented.

Fisher's Test vs. Chi-Square With Continuity Correction

Another common alternative for sparse 2×2 tables is the chi-square test with Yates' continuity correction. The correction attempts to improve the approximation by accounting for the discreteness of the data.

However, it remains an asymptotic method. Fisher's test instead calculates probabilities from the exact conditional distribution.

Common Mistake: Automatically Using Fisher for Every 2×2 Table

Fisher's exact test is useful, but it does not need to replace every chi-square analysis.

For large, well-populated tables, Pearson's chi-square test can be entirely appropriate and computationally simpler.

The important principle is:

Use an exact method when the exact small-sample distribution matters, not simply because a table happens to have two rows and two columns.

Common Mistake: Calling Fisher "Nonparametric"

Fisher's exact test is sometimes casually labeled a nonparametric test. That terminology is not particularly informative.

The more useful description is that Fisher's test is an exact conditional test for a 2×2 contingency table.

It does not require the normality assumption associated with many parametric methods, but the term "nonparametric" does not explain the actual probability model.

Common Mistake: Ignoring the Alternative Hypothesis

Suppose the treatment response table is:

Response No Response
Experimental 7 3
Control 1 9

If the question is: Is the experimental treatment better? then a one-sided alternative may be scientifically appropriate if prespecified.

If the question is: Are the treatment groups different? then a two-sided test is appropriate.

These are different hypotheses and can produce different p-values.

Common Mistake: Doubling the One-Sided p-Value

For the worked example:

\[ p_{\text{one-sided}}\approx0.00983 \]

Simply doubling this gives:

\[ 2(0.00983)=0.01966 \]

which happens to be very close to the commonly reported two-sided value for this example.

But this should not be treated as a general rule for Fisher's exact test.

Because the exact distribution is discrete and asymmetric, the two-sided p-value is determined by the specified exact-test ordering rule.

Common Mistake: Reporting Only the p-Value

A better clinical report might state:

"Response occurred in 7/10 patients (70%) in the experimental group and 1/10 patients (10%) in the control group. The odds ratio was 21.0, and Fisher's exact test gave a two-sided p-value of 0.0198."

This communicates:

  • The observed data
  • The magnitude of the difference
  • The effect estimate
  • The statistical evidence

Common Mistake: Confusing Odds With Probability

A 70% response probability corresponds to odds of:

\[ \frac{0.70}{1-0.70} = \frac{0.70}{0.30} \approx2.33 \]

It does not correspond to odds of 0.70.

Likewise, a 10% response probability corresponds to odds:

\[ \frac{0.10}{0.90} \approx0.111 \]

Therefore the odds ratio is:

\[ OR=\frac{2.33}{0.111}\approx21 \]

Common Mistake: Interpreting the Odds Ratio as a Risk Ratio

In the worked example:

\[ RR=7 \qquad\text{but}\qquad OR=21 \]

These are not interchangeable.

When the outcome is relatively common, the difference between the odds ratio and risk ratio can be substantial.

Common Mistake: Assuming a Significant Result Proves Causality

Fisher's test detects evidence of association. It does not by itself establish causality.

Causal interpretation depends on the study design. A randomized clinical trial provides a much stronger basis for causal inference than an observational comparison, assuming the trial is properly designed and conducted.

The test cannot repair the study design. Fisher's exact test can provide an exact p-value for the observed contingency table, but it cannot eliminate confounding, selection bias, measurement bias, or other design limitations.

Multiple Fisher Tests

Suppose a clinical trial performs Fisher's exact test for:

  • Overall response
  • Complete response
  • Disease control
  • Several safety events
  • Several biomarker-defined subgroups

If many hypotheses are tested, the probability of obtaining at least one small p-value by chance increases.

The use of Fisher's exact test does not automatically solve the multiplicity problem.

When multiple confirmatory hypotheses are tested, an appropriate multiplicity strategy should be prespecified.

Fisher's Test in Subgroup Analyses

Fisher's test is sometimes used within small subgroups. For example, a clinical trial might examine response separately among:

  • Biomarker-positive patients
  • Biomarker-negative patients
  • Prior-treatment subgroups
  • Age categories
  • Disease-stage categories

If a subgroup contains very few patients, Fisher's exact test may be useful for a simple 2×2 comparison.

However, subgroup analyses introduce additional issues:

  • Multiple testing
  • Low statistical power
  • Wide confidence intervals
  • Potential confounding
  • Interaction testing

A significant result in one subgroup and a non-significant result in another does not automatically demonstrate that the treatment effects differ between subgroups.

Fisher's Test Does Not Test Interaction

Suppose:

Subgroup A: treatment is significant.

Subgroup B: treatment is not significant.

It is tempting to conclude that the treatment works differently between the subgroups. That conclusion is not justified merely by comparing two p-values.

A formal interaction analysis is required to test whether the treatment effect differs between subgroups.

Clinical Trial Reporting Example

A concise results statement could be:

Example reporting language: Among the 20 randomized patients, objective response occurred in 7 of 10 patients (70%) receiving the experimental treatment and 1 of 10 patients (10%) receiving control. The estimated odds ratio was 21.0. Fisher's exact test yielded a two-sided p-value of approximately 0.0198.

For a confirmatory clinical report, the exact confidence interval for the effect estimate should also be reported, along with the prespecified analysis population and handling of missing data.

Missing Data and Fisher's Exact Test

Fisher's exact test requires a defined 2×2 analysis table. Clinical trials may contain:

  • Patients without post-baseline assessments
  • Withdrawals
  • Protocol deviations
  • Missing endpoint measurements
  • Patients who discontinue treatment early

The statistical analysis plan should specify how such patients are classified for the binary endpoint.

Possible approaches depend on the endpoint and estimand and may include prespecified nonresponder rules, exclusion under defined circumstances, multiple imputation, or other methods.

Do not let the statistical test determine the missing-data rule. The missing-data and estimand strategy should be defined independently and before examining the comparative outcome results.

Continuity Corrections Are Not Needed for Fisher's Test

Because Fisher's test is based directly on the exact discrete distribution, there is no need to apply a continuity correction such as Yates' correction to the Fisher calculation.

Continuity corrections are associated with approximating a discrete distribution using a continuous distribution such as the chi-square distribution.

Computational Interpretation

Fisher's exact test can be understood algorithmically. Given the observed table:

1
Read the four cell counts.
2
Calculate the row and column totals.
3
Determine the range of possible values for one cell.
4
Calculate the hypergeometric probability for every possible table.
5
Identify the observed table.
6
Select the appropriate exact tail or probability ordering.
7
Sum the relevant probabilities.
8
Report the p-value together with an appropriate effect estimate.

The Mathematical Core in One Formula

For a table with fixed margins, the probability of observing \(x\) treatment responders is:

\[ P(X=x) = \frac{ {K\choose x} {N-K\choose n_T-x} }{ {N\choose n_T} } \]

where:

  • \(N\) = total sample size
  • \(K\) = total number of successes
  • \(n_T\) = treatment-group sample size
  • \(x\) = number of successes in the treatment group

Everything else in Fisher's exact test follows from this distribution and the definition of the test's rejection region.

Worked Example: All Key Quantities

Quantity Value
Total sample size 20
Experimental group 10
Control group 10
Total responders 8
Experimental responders 7
Control responders 1
Experimental response rate 70%
Control response rate 10%
Risk difference 60 percentage points
Risk ratio 7.0
Odds ratio 21.0
Observed-table probability Approximately 0.00947
One-sided Fisher p-value Approximately 0.00983
Two-sided Fisher p-value Approximately 0.0198

When Fisher's Exact Test Is a Good Choice

Fisher's exact test is particularly attractive when:

  • The outcome is binary.
  • The exposure or treatment has two categories.
  • The resulting data form a 2×2 table.
  • The sample size is small.
  • One or more cells are sparse.
  • Expected counts are small.
  • A zero cell is present.
  • An exact conditional analysis is scientifically appropriate.

When Fisher's Exact Test May Not Be Enough

A 2×2 Fisher test is not automatically the best analysis for every clinical-trial question. More complex methods may be preferable when:

  • There are more than two treatment groups.
  • The outcome has more than two categories.
  • The endpoint is continuous.
  • The endpoint is time-to-event.
  • Covariate adjustment is required.
  • Repeated observations are available.
  • There are multiple strata that should be modeled.
  • The treatment effect must be adjusted for baseline prognostic factors.

For example, logistic regression may be more appropriate when adjustment for important baseline covariates is required.

Fisher's Exact Test and Logistic Regression

For a simple unadjusted 2×2 analysis, Fisher's exact test can be an excellent choice for sparse data. But if the analysis needs adjustment for age, disease severity, biomarker status, or another prognostic factor, logistic regression may provide a more appropriate framework.

The basic logistic regression model is:

\[ \log\left(\frac{p}{1-p}\right) = \beta_0+\beta_1X_1+\cdots+\beta_kX_k \]

The exponentiated treatment coefficient:

\[ e^{\beta_{\text{treatment}}} \]

is interpreted as an adjusted odds ratio under the specified model.

Rule of thumb: Fisher's exact test is a powerful tool for a simple sparse 2×2 comparison, but it is not a substitute for a multivariable model when the scientific question requires covariate adjustment.

Fisher's Test and Stratified Data

Suppose a clinical trial has several centers, and the treatment-response relationship must be evaluated while accounting for center. Simply pooling all patients into one 2×2 table may ignore important stratification.

Methods such as the Cochran-Mantel-Haenszel approach can be considered for stratified categorical data.

The appropriate method depends on the design and estimand.

Fisher's Test and Matched Data

If the data are paired or matched rather than independent, a standard 2×2 Fisher test may not be appropriate. For paired binary observations, McNemar's test is a commonly considered alternative.

This illustrates an important principle: the data-generating design matters as much as the observed cell counts.

A Practical Analysis Workflow

1
Define the binary endpoint and analysis population.
2
Construct the 2×2 contingency table.
3
Review the cell counts and assess sparsity.
4
Determine whether an exact test is appropriate.
5
Specify the one-sided or two-sided alternative.
6
Perform Fisher's exact test.
7
Calculate an appropriate effect estimate.
8
Calculate an appropriate confidence interval.
9
Interpret statistical and clinical significance separately.
10
Report the counts, percentages, effect estimate, confidence interval, and exact p-value.

What Should Be Reported?

A clear clinical-trial report should generally include:

  • The 2×2 cell counts
  • The response percentage in each group
  • The effect estimate
  • A confidence interval where appropriate
  • The exact p-value
  • Whether the test was one-sided or two-sided
  • The statistical method used
  • The analysis population
  • Any prespecified handling of missing data

For example:

Example: Response occurred in 7/10 patients (70%) in the experimental group and 1/10 patients (10%) in the control group. The odds ratio was 21.0. Fisher's exact test yielded a two-sided p-value of 0.0198.

Fisher's Exact Test in SAS

Fisher's exact test is also straightforward in SAS using PROC FREQ.

data response;
    input treatment $ response $ count;
    datalines;
Experimental Yes 7
Experimental No  3
Control      Yes 1
Control      No  9
;
run;

proc freq data=response;
    tables treatment*response / fisher;
    weight count;
run;

The FISHER option requests Fisher's exact test.

If the individual patient records are available rather than aggregated counts, the WEIGHT statement is unnecessary.

SAS With Individual Patient Records

data response;
    input treatment $ response $;
    datalines;
Experimental Yes
Experimental Yes
Experimental Yes
Experimental Yes
Experimental Yes
Experimental Yes
Experimental Yes
Experimental No
Experimental No
Experimental No
Control Yes
Control No
Control No
Control No
Control No
Control No
Control No
Control No
Control No
Control No
;
run;

proc freq data=response;
    tables treatment*response / fisher;
run;

This produces the 2×2 table together with the Fisher exact test.

R vs. SAS

Task R SAS
Build 2×2 table matrix() PROC FREQ
Fisher test fisher.test() / fisher
Odds ratio Returned by fisher.test() Available from appropriate FREQ output/options
Exact distribution dhyper() Handled by procedure

Interpretation of the Worked Example

The experimental treatment produced 7 responses among 10 patients, compared with only 1 response among 10 control patients.

The response-rate difference was:

\[ 70\%-10\%=60\% \]

The estimated odds ratio was:

\[ OR=21 \]

The two-sided Fisher exact p-value was approximately:

\[ p=0.0198 \]

Therefore, under the specified exact testing framework, the observed treatment allocation of responders would be relatively unusual under the null hypothesis of no association.

However, the study contains only 20 patients, so the estimated treatment effect should be interpreted with appropriate attention to statistical uncertainty.

The Most Important Concept

The central idea behind Fisher's exact test is simple: condition on the observed margins and calculate the exact probability of the possible 2×2 tables.

For a binary outcome and two groups, the hypergeometric distribution describes how the total successes could be distributed between the groups under the null hypothesis.

The p-value is then obtained by summing the probabilities of the observed table and the tables considered at least as extreme according to the selected alternative and exact-test definition.

This makes Fisher's exact test particularly useful for sparse clinical data.

Bottom line: Fisher's exact test is an exact conditional method for testing association in a 2×2 contingency table. It is especially useful when sample sizes or cell counts are small because it does not rely on the large-sample chi-square approximation. The test is based on the hypergeometric distribution and can be performed for either one-sided or two-sided alternatives. In clinical research, the Fisher p-value should be reported alongside the observed response rates, an appropriate effect estimate such as an odds ratio or risk ratio, and an appropriate measure of uncertainty. Fisher's test provides exact statistical evidence, but it does not replace careful study design, appropriate handling of missing data, multiplicity considerations, or clinical interpretation.

References

Fisher, R.A. (1922). On the interpretation of χ² from contingency tables, and the calculation of P. Journal of the Royal Statistical Society, 85(1), 87–94.
Fisher, R.A. (1934). Statistical Methods for Research Workers. Oliver and Boyd.
Agresti, A. (2013). Categorical Data Analysis, 3rd ed. Wiley.
Mehta, C.R. & Patel, N.R. (1983). A network algorithm for performing Fisher's exact test in r×c contingency tables. Journal of the American Statistical Association, 78(382), 427–434.
Mehta, C.R. & Patel, N.R. (1986). Algorithm 643: FEXACT, a FORTRAN subroutine for Fisher's exact test on unordered r×c contingency tables. ACM Transactions on Mathematical Software, 12(2), 154–161.
SAS Institute Inc. SAS/STAT User's Guide: The FREQ Procedure.
R Core Team. R: A Language and Environment for Statistical Computing.

Clinical Trials

See these methods in real clinical trials

See the method applied to published trial results, with the estimates, confidence intervals and interpretation explained.

VOICE
Independent statistical analysis of the VOICE phase 2 trial of tenofovir 1% gel, oral tenofovir disoproxil fumarate, and emtricitabine/tenofovir disoproxil fumarate for…
Phase 2 · n = 5,029
Partners PrEP
An independent statistical analysis of the Partners PrEP phase 3 trial, examining TDF and FTC/TDF for prevention of HIV-1 acquisition in HIV-1…
Phase 3 · n = 4,758
RE-MODEL
Complete statistical analysis of the RE-MODEL phase 3 trial of dabigatran etexilate versus enoxaparin for prevention of thrombosis after knee surgery, including…
Phase 3 · n = 2,101
RE-NOVATE
Independent statistical analysis of the RE-NOVATE phase 3 trial comparing dabigatran etexilate with enoxaparin for prevention of venous thromboembolism following total hip…
Phase 3 · n = 2,055
EVOLVE-2
Independent statistical analysis of the phase 3 EVOLVE-2 trial of galcanezumab for the prevention of episodic migraine, including trial design, registered endpoints,…
Phase 3 · n = 986
EVOLVE-1
Independent statistical analysis of the phase 3 EVOLVE-1 trial of galcanezumab for the prevention of episodic migraine, including randomized design, longitudinal mixed-effects…
Phase 3 · n = 862
See all 20 trials using Exact test (Barnard, exact Poisson, other) →