AI Glossary / Statistics and probability / Intermediate

Fisher exact test

Definition

The Fisher exact test assesses association in a contingency table using a probability distribution conditional on the table's margins. In the familiar two-by-two case, it tests a null odds ratio of one through a hypergeometric distribution. It is especially useful when small counts make a large-sample approximation questionable. Exact refers to the reference calculation under the stated assumptions, not to certainty about the conclusion, an absence of sampling variation or proof that an observed association is causal.

What it means

A two-by-two table records counts for two categorical variables, such as group and yes-or-no outcome. Under the null hypothesis and conditioning on the row and column totals, some arrangements of the counts are more probable than others. Fisher's test measures how incompatible the observed arrangement is with that conditional model. The margins can be fixed by design or conditioned on during inference; they need not always have been known in advance. The test's p-value and an estimated odds ratio answer different questions and should not be confused.

How it works

Specify the table orientation and whether the alternative is one-sided or two-sided. With total N, a fixed number K of column-one outcomes and row-one size n, the top-left count A has probability choose(K,a) choose(N-K,n-a)/choose(N,n) under the conditional null. Sum the appropriate probabilities to obtain the p-value. A common two-sided convention includes all feasible tables whose null probability is no greater than that of the observed table. Other exact two-sided conventions exist, so software settings matter. Independent observational units and the sampling or randomization model must fit the analysis; paired outcomes require a different treatment.

Three practical examples

  • Small experimental comparison: assess association between assigned group and a binary outcome when observations are independent.
  • Quality investigation: examine a sparse table of component type and recorded defect status.
  • Software review: verify the table orientation and two-sided convention behind a reported exact p-value.

Think of it this way

Think of rearranging a fixed collection of outcome labels across two groups while keeping the totals unchanged. The test asks how often an arrangement at least as incompatible with the null would occur under that conditional rule. It does not rearrange the real data to make the observed result disappear.

Worked example

Consider a hypothetical table with group A containing four successes and one failure, and group B containing one success and four failures. Both row totals are five, and there are five successes overall. Conditional on these margins, the possible success counts in A are zero through five, with probabilities proportional to 1, 25, 100, 100, 25 and 1, all divided by 252. The observed count four has probability 25/252. Under the probability-ordering two-sided convention, counts zero, one, four and five are included, giving (1 + 25 + 25 + 1)/252 = 13/63, approximately 0.20635. A prespecified upper-tail test gives (25 + 1)/252, approximately 0.10317. The sample odds ratio is (4 x 4)/(1 x 1) = 16, showing that a large point estimate can coexist with considerable uncertainty in a tiny sample.

Illustrative case study

Fictional case: Cedar Interface Testing reviews a small pilot with a binary completion outcome. Analysts display the actual counts, an effect estimate and an exact test rather than presenting a percentage difference alone. They confirm that each participant contributes one independent outcome and that the hypothesis direction was set before inspecting results. A larger follow-up is considered because the pilot is imprecise. This invented case illustrates transparent small-sample reporting and does not claim that non-rejection demonstrates equivalence or that a large odds ratio guarantees a useful effect.

Common misconceptions and mistakes

Do not input percentages where the procedure requires integer counts. Do not interpret the p-value as the probability that the null hypothesis is true. Two-sided exact p-values are not universally twice the smaller one-sided value, even though that happens in the symmetric worked example. Swapping rows or columns changes the direction of an odds ratio and one-sided alternative. Exact conditional tests can be conservative because attainable p-values are discrete. Repeated observations, clusters or matched pairs violate a simple independent-table analysis unless the design is handled appropriately.

Business use

Businesses should use the test to answer a clearly specified association question, accompanied by counts and an interpretable effect measure. Check whether the data arose from random assignment or observational collection before using causal language. Report the alternative and two-sided convention, especially when comparing software outputs. A result from a sparse table can be informative while remaining highly uncertain. Avoid selecting the test or direction solely because it yields a smaller p-value, and consider multiplicity when many tables are examined.

People also ask

Is Fisher's test only allowed when expected counts are below five?

No. Small counts motivate it, but that threshold is not a requirement for validity.

Are the margins always fixed in advance?

No; the conditional analysis can condition on observed margins.

Is the reported odds ratio the p-value?

No. The odds ratio estimates association, while the p-value measures incompatibility with the null reference model.

Check your understanding

Why does the worked two-sided calculation include count one as well as four?

Answer: Under the null and these margins, both arrangements have the same probability, so both qualify under the specified probability-ordering convention.

Related terms

  • Contingency table
  • Hypergeometric distribution
  • Odds ratio
  • Exact test
  • Chi-square test
  • conditional inference
  • fixed margins

Learn next

compare conditional and unconditional tests for two independent proportions, then examine how an odds-ratio confidence interval complements an exact p-value.

  • Odds ratio
  • Confidence interval
  • P-value

More in Statistics and probability

  • First order interaction - A first order interaction is an interaction between two variables: the relationship between one variable and an outcome depends on the level of the other.
  • First-order reliability method - The first-order reliability method, or FORM, estimates a threshold-event probability by approximating a limit-state boundary with a tangent hyperplane at a...
  • First-order second-moment method - The first-order second-moment method, often abbreviated FOSM, approximates the mean and variance of a model output using a first-order Taylor expansion and...
  • Fisher's inequality - Fisher's inequality is a necessary condition for a nontrivial balanced incomplete block design: the number of blocks b must be at least the number of...
  • Fisher's least significant difference - Fisher's least significant difference is a threshold and associated procedure for comparing two means using an error variance pooled from an...
  • Fisher's Least Significant Difference Test (LSD) - Fisher's Least Significant Difference Test, abbreviated LSD, is a pairwise mean-comparison procedure using a common error estimate from an...

Sources

Sources: SciPy, fisher_exact, conditional distribution and two-sided convention: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.fisher_exact.html ; SciPy, versioned two-by-two documentation and odds-ratio interpretation: https://cache-docs.scipy.org/doc/scipy-1.14.1/reference/generated/scipy.stats.fisher_exact.html .

Previous: First-order second-moment method Next: Fisher's inequality

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer