Statistics and research

Fisher’s exact test calculator

Exact test for a 2×2 table: two-sided and one-sided p-values, the conditional maximum likelihood odds ratio and its exact confidence interval.

Runs in your browser. What you enter stays on this page and is not uploaded.

Results

p-value0.4857Odds ratio (conditional MLE)6.4083
Hypothesis
two-sided, odds ratio ≠ 1
p-value
0.4857
Two-sided p (sum of tables no more probable than observed)
0.4857
One-sided p, lower (P(X ≤ a))
0.9857
One-sided p, upper (P(X ≥ a))
0.2429
Probability of the observed table
0.22857143
Sample odds ratio ad / bc
9
Conditional maximum likelihood odds ratio
6.4083197
95% exact confidence interval
0.211736 to 626.244
Conclusion
Rows and columns are not shown to be associated (not significant at the 5% level).
Tables with the same margins (hypergeometric probabilities)
a (row 1, column 1)ProbabilityCounts toward two-sided p
00.014285714yes
10.22857143yes
20.51428571no
30.22857143yes
40.014285714yes

As R fisher.test: the two-sided p-value adds the probabilities of all tables with the same margins that are no more likely than the one observed; the odds ratio is the conditional maximum likelihood estimate.

Method and limits

How to use it

Enter the four counts of a 2×2 table: a and b in row 1, c and d in row 2. Use it instead of the chi-square test when expected counts are small, or whenever an exact p-value is wanted.

Formulas

  • With all margins fixed, a follows the hypergeometric distribution: P(a) = C(a + b, a) C(c + d, c) / C(n, a + c).
  • Two-sided p = sum of the probabilities of all tables with the same margins that are no more likely than the observed one (with R’s relative tolerance 1e-7). One-sided p-values sum one tail.
  • Odds ratio: the conditional maximum likelihood estimate from the noncentral hypergeometric distribution, and an exact interval by inverting its tails — R’s fisher.test method, solved here to a tighter tolerance than R’s uniroot (results agree with R to about 4 significant digits).

Assumptions and limits

  • Independent observations, each in one cell; the test is conditional on both margins.
  • Two-sided p-values from different software can differ slightly because definitions of “more extreme” differ; this tool uses R’s.
  • Larger tables are not supported here; use the chi-square test.

Worked example

Fisher’s tea-tasting experiment: a lady identified 3 of 4 cups correctly (table 3, 1, 1, 3). The probability of this table is 16/70 = 0.229; the two-sided p = 0.486 and the one-sided p = 0.243. The conditional odds ratio is 6.41.

References

Related tools

Share this page

Remind me to visit Contifield

Adds a repeating reminder to your calendar, titled “Contifield Reminder: Visit www.contifield.com”.