Enter the four counts of a 2×2 table: a = exposed & outcome, b = exposed & no outcome, c = unexposed & outcome, d = unexposed & no outcome.
OR = ad/bc; RR = (a/(a+b))/(c/(c+d)); 95% CI = exp(ln ± 1.96·SE); Haldane–Anscombe +0.5 correction for zero cells.
About this tool
The Odds Ratio & Relative Risk Calculator turns a 2×2 contingency table into the core measures of association used in epidemiology and clinical research. Enter the four cell counts — exposed cases (a), exposed non-cases (b), unexposed cases (c) and unexposed non-cases (d) — and it returns the odds ratio, relative risk and their confidence intervals as you type, all in your browser.
The odds ratio is OR = (a·d)/(b·c) and the relative risk is RR = (a/(a+b))/(c/(c+d)). Confidence intervals use the log transform, where the standard error of ln(OR) is √(1/a + 1/b + 1/c + 1/d); the 95% interval is exp(ln(OR) ± 1.96·SE), and RR is handled the same way with its own standard error. The tool also gives the absolute risk difference and the number needed to treat, NNT = 1/|risk difference|, plus a two-sided p-value from the normal approximation z = ln(OR)/SE.
When any cell is zero the odds ratio and its variance are undefined, so a Haldane–Anscombe correction adds 0.5 to every cell and the result is flagged. An OR or RR of 1 means no association; above 1 the exposure is associated with higher odds or risk of the outcome, below 1 with lower.
Frequently asked questions
What is the difference between the odds ratio and relative risk?
Relative risk compares the probability of the outcome between groups (a/(a+b) vs c/(c+d)); the odds ratio compares the odds (a·d/b·c). For rare outcomes they are close, but for common outcomes the odds ratio is further from 1 and should not be read as a risk ratio.
How is the 95% confidence interval calculated?
On the log scale, which is roughly symmetric. For the odds ratio, SE(ln OR) = √(1/a+1/b+1/c+1/d) and the interval is exp(ln(OR) ± 1.96·SE). If the interval excludes 1, the association is significant at the 5% level.
What happens if a cell is zero?
A zero cell makes the odds ratio 0 or infinite and its standard error undefined. The tool applies the Haldane–Anscombe correction, adding 0.5 to all four cells so the estimate and interval stay finite, and tells you it did so.
What does the p-value test?
It tests the null hypothesis that the odds ratio equals 1 (no association), using the normal approximation z = ln(OR)/SE(ln OR) and a two-sided tail. A p below 0.05 matches a 95% confidence interval that does not include 1.
More tools