induwara.lk
induwara.lkHealth · Biostatistics

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.

By Induwara AshinsanaUpdated Jun 23, 2026
2×2 study tableOR · RR · NNT
Woolf & Katz CIs
Exposed / treatment group
Unexposed / control group
Examples
GroupEventNo eventTotal
Exposed1585100
Unexposed595100
Total20180200
Relative Risk (RR)
3.00
95% CI: 1.13 to 7.94
Significant
Odds Ratio (OR)
3.35
95% CI: 1.17 to 9.62
Significant
Absolute Risk Increase
10%
Relative Risk Increase: 200%
Number Needed to Harm
10
95% CI: 6 to 56
Risk in exposed group15%15 / 100
Risk in unexposed group5%5 / 100

Exposure is associated with increased risk (RR = 3.00× the unexposed risk); the 95% CI excludes 1, so the association is statistically significant.

Cross-check: the odds ratio computed as a cross-product (a·d / b·c) and as the ratio of group odds ((a/b) / (c/d)) agree at 3.35.

Sources cited: Bland & Altman, BMJ 2000;320:1468 (odds ratio); Altman, Practical Statistics for Medical Research 1991 (Woolf/Katz CIs); Altman, BMJ 1998;317:1309 (NNT CI). All arithmetic runs in your browser — nothing is uploaded.

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):

  1. Risks. Risk in the exposed group is a/(a+b); risk in the unexposed group is c/(c+d). These are the incidence proportions.
  2. 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.
  3. 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.
  4. Absolute risk change (ARR/ARI) = the difference between the two risks. Relative risk change (RRR/RRI) = |1 − RR|, shown as a percentage.
  5. 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

Cohort study — harmful exposure

15 of 100 exposed developed the outcome vs 5 of 100 unexposed (a=15, b=85, c=5, d=95).

  1. Risk exposed = 15/100 = 0.150; risk unexposed = 5/100 = 0.050
  2. RR = 0.150 / 0.050 = 3.00
  3. OR = (15 × 95) / (85 × 5) = 1425 / 425 = 3.35
  4. RR 95% CI (Katz): exp(ln 3 ± 1.96·√0.2467) = 1.13 to 7.94
  5. OR 95% CI (Woolf): exp(ln 3.35 ± 1.96·√0.2890) = 1.17 to 9.62
  6. ARI = 0.150 − 0.050 = 0.100 → NNH = 1/0.100 = 10
  7. Both CIs exclude 1 → statistically significant at p < 0.05

Randomised trial — beneficial treatment (NNT)

Treatment: 20 events of 200; control: 40 events of 200 (a=20, b=180, c=40, d=160).

  1. Risk treated = 20/200 = 0.100; risk control = 40/200 = 0.200
  2. RR = 0.100 / 0.200 = 0.50
  3. OR = (20 × 160) / (180 × 40) = 3200 / 7200 = 0.44
  4. RRR = |1 − 0.50| = 50%
  5. ARR = 0.200 − 0.100 = 0.100 → NNT = 1/0.100 = 10
  6. RR 95% CI (Katz): exp(ln 0.5 ± 1.96·√0.065) = 0.30 to 0.82 (excludes 1)

Zero cell — continuity correction

No events in the exposed group: 0 of 10 exposed vs 5 of 10 unexposed (a=0, b=10, c=5, d=5).

  1. A zero cell makes ln(OR) and ln(RR) undefined
  2. Add 0.5 to every cell → 0.5, 10.5, 5.5, 5.5 (Haldane–Anscombe)
  3. OR = (0.5 × 5.5) / (10.5 × 5.5) = 0.048
  4. RR (corrected) = (0.5/11) / (5.5/11) = 0.091
  5. ARR uses observed counts: risk 0.000 vs 0.500 → ARR 0.500, NNT 2

Frequently asked questions

Sources & references

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

Rate this tool
Be the first to rate

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.