Statistics & probability

2×2 table: risk ratio, odds ratio and Fisher exact test

Analyse a 2×2 table of exposure and outcome counts with risk ratio, odds ratio and exact p-values.

2×2 table: risk ratio, odds ratio and Fisher exact test
Esc to restore

Your inputs

Statistical association only. It does not show cause, and it cannot adjust for confounding.

Results update as you type. Larger files run when you press Update result.

Your result

Your result will appear here.

More actions

Your inputs stay in this browser. Nothing is uploaded, and nothing is saved unless you choose “Save result”.

A clear answer. Here’s how.

Risk difference, risk ratio (Katz log interval) and odds ratio (Woolf logit interval) are computed from the four counts; a zero cell adds 0.5 to every cell for the ratio estimates. Pearson chi-square is N(ad − bc)² ÷ (r₁r₂c₁c₂) on one degree of freedom, with a Yates-corrected version. Fisher’s exact p sums the hypergeometric probability of every table with the same margins that is no more likely than the observed table. The number needed to treat is 1 ÷ |risk difference|, rounded up.

See a worked example

Worked example

A fixed demonstration, separate from the values you enter above.

a: exposed, outcome occurred
20
b: exposed, no outcome
80
c: unexposed, outcome occurred
10
d: unexposed, no outcome
90
Confidence level
95%

Example result

Risk in the exposed group (a ÷ (a+b))
20.00%
Risk in the unexposed group (c ÷ (c+d))
10.00%
Risk difference
10.00% (0.20% to 19.80%)
Risk ratio
2 (0.986563 to 4.05448)
Odds ratio
2.25 (0.994295 to 5.09155)
Number needed to treat or harm
10
Pearson chi-square (df 1)
3.92157, p = 0.0476704
Chi-square with Yates correction
3.17647, p = 0.0747059
Fisher exact test (two-sided)
p = 0.0734276

Layout: a = exposed with outcome, b = exposed without, c = unexposed with, d = unexposed without. Intervals are 95%: Wald for the difference (clipped to ±100%), Katz log for the ratio, Woolf logit for the odds ratio. Fisher’s p sums every table at least as unlikely as the observed one. Association is not causation, and the layout assumes one row per group.