Odds Ratio & Relative Risk Calculator
Enter a 2×2 study table and get the relative risk, odds ratio, absolute and relative risk reduction and the number needed to treat or harm — each with a 95% confidence interval. Runs entirely in your browser, no signup, formulas and sources cited below.
How it works
A 2×2 contingency table summarises a study with two groups (exposed or treated vs unexposed or control) and a binary outcome (event or no event). Label the four cells a, b, c and d:
- a = exposed with the event, b = exposed without it
- c = unexposed with the event, d = unexposed without it
From these four numbers the calculator derives every measure of association using the formulas in Altman's Practical Statistics for Medical Research (1991):
- Risks. Risk in the exposed group is a/(a+b); risk in the unexposed group is c/(c+d). These are the incidence proportions.
- Relative Risk (RR) = riskexposed ÷ riskunexposed. Its 95% CI uses the Katz method:
ln(RR) ± z·√(1/a − 1/(a+b) + 1/c − 1/(c+d)), then exponentiated. - Odds Ratio (OR)= (a·d)/(b·c), per Bland & Altman (BMJ 2000). Its 95% CI uses the Woolf/logit method:
ln(OR) ± z·√(1/a + 1/b + 1/c + 1/d), then exponentiated. - Absolute risk change (ARR/ARI) = the difference between the two risks. Relative risk change (RRR/RRI) = |1 − RR|, shown as a percentage.
- Number Needed to Treat / Harm = 1 ÷ |absolute risk change|, rounded up (Altman, BMJ 1998). Its CI is found by inverting the confidence interval of the absolute risk difference.
The z multiplier is the two-sided normal critical value for the chosen confidence level: 1.645 for 90%, 1.960 for 95% and 2.576 for 99%. A result is statistically significant when its confidence interval excludes 1 (for RR and OR) or excludes 0 (for the absolute risk difference). If any cell is zero, a Haldane–Anscombe correction adds 0.5 to all four cells before the logarithm-based steps, because ln(0) is undefined. As an internal cross-check, the calculator also computes the odds ratio a second way — as the ratio of the two group odds, (a/b) ÷ (c/d) — and confirms it equals the cross-product result.
Worked examples
Frequently asked questions
Sources & references
- Bland JM, Altman DG — “The odds ratio.” BMJ 2000;320:1468
- Altman DG — “Confidence intervals for the number needed to treat.” BMJ 1998;317:1309
- Centre for Evidence-Based Medicine (CEBM), University of Oxford — EBM calculators
The formulas on this page were last cross-checked against the cited sources on 2026-06-23. The relative risk and odds ratio confidence intervals follow the Katz and Woolf log-based methods; the NNT interval follows Altman's 1998 method.
Related tools
Comments & feedback
Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.
Found a bug, edge case, or want to suggest an improvement?
Email me at [email protected] — most fixes ship within 24 hours.