calculator.onl
Categories50

Fisher exact test for a 2×2 table

Calculate one-sided and probability-ordered two-sided Fisher exact p-values and the sample odds ratio for integer counts.

A worked example

Keep the table fixed and switch tails. Which bars count toward the p-value?

p0.1026p ≤0.9953p ≥0.0862p₂0.1026
Count in the first row and first column of the contingency table. a (1,1): 0…5000

Count in the first row and second column. b (1,2): 0…5000

Count in the second row and first column. c (2,1): 0…5000

Count in the second row and second column. d (2,2): 0…5000

Mode: Two-sided / Less / Greater

Updates as you type

Use a dot or comma for decimals. No thousands separators.

YOUR RESULT

p

0.1026

Calculated from your inputs

OR = ad/bc12
p ≤0.9953
p ≥0.0862
p₂0.1026
N6
The numbers, at a glance

Calculations run in your browser.
UNDERSTAND THE RESULT

A little context. A clearer answer.

↑ Back to calculator

When this calculator is useful

Enumerate all admissible upper-left counts with the observed row and column totals. Compute normalized hypergeometric log probabilities to avoid factorial overflow. Sum the appropriate tail or probability-ordered set. Very small p-values use scientific or logarithmic notation. For a related calculation, try Hypergeometric probability calculator.

What to enter

InputWhat it meansExample value
a (1,1)Count in the first row and first column of the contingency table. a (1,1): 0…5000 6
b (1,2)Count in the first row and second column. b (1,2): 0…5000 2
c (2,1)Count in the second row and first column. c (2,1): 0…5000 1
d (2,2)Count in the second row and second column. d (2,2): 0…5000 4
ModeMode: Two-sided / Less / GreaterTwo-sided

How the calculation works

  1. Change the inputs to explore your own scenario. a (1,1): 0…5000 ; b (1,2): 0…5000 ; c (2,1): 0…5000 ; d (2,2): 0…5000 ; Mode: Two-sided / Less / Greater.
  2. P(X=x)=C(a+c,x)C(b+d,a+b−x)/C(n,a+b); p₂=Σ{P(x):P(x)≤P(a)}
  3. Independent observations in a 2×2 count table, conditional on fixed margins. Two-sided means summing tables no more probable than the observed table; it is not automatically twice a one-sided p-value. Sample odds ratio is ad/bc; it can be undefined or infinite. No confidence interval or causal conclusion.
The formulaP(X=x)=C(a+c,x)C(b+d,a+b−x)/C(n,a+b); p₂=Σ{P(x):P(x)≤P(a)}

A worked example

For [[6,2],[1,4]], sample OR=12; two-sided p=0.1025641025641, greater p=0.0862470862471 and less p=0.995337995338.

Example you can load

What to enter
Result for this example · p0.1026

This is a fixed example; changing the form above does not change these numbers.

Assumptions & limits

Independent observations in a 2×2 count table, conditional on fixed margins. Two-sided means summing tables no more probable than the observed table; it is not automatically twice a one-sided p-value. Sample odds ratio is ad/bc; it can be undefined or infinite. No confidence interval or causal conclusion.

Frequently asked questions

What counts can I enter?

Nonnegative integer counts, not percentages, weights or paired measurements. At least one observation is required; each cell is limited to 5000.

Why is two-sided p different from twice one tail?

The supported definition includes all fixed-margin tables whose probability is no greater than the observed table’s probability. Discrete asymmetric distributions need not give twice a tail.

Which odds ratio is shown?

The sample cross-product ratio ad/bc, without adding a continuity correction. It is not the conditional maximum-likelihood estimate.