You post about health? Post once at Tublish.com, and it goes to Instagram, Facebook, YouTube, TikTok, Threads, LinkedIn, Discord, Telegram, Bluesky, Mastodon and WordPress. You post about health? Post once at Tublish.com, and it goes to Instagram, Facebook, YouTube, TikTok, Threads, LinkedIn, Discord, Telegram, Bluesky, Mastodon and WordPress.

Relative Risk and Odds Ratio Calculator

Relative risk, odds ratio, risk difference and NNT from a 2×2 table of counts, each with a 95% confidence interval and a zero-cell correction.

Relative Risk (RR)

The 2×2 Contingency Table

In epidemiology, we compare outcomes between exposed and unexposed groups using a 2×2 table:

Outcome (+) No Outcome (−)
Exposed a b
Unexposed c d

Key Measures

Relative Risk (RR): the ratio of risks between the two groups:
RR = [a ÷ (a + b)] ÷ [c ÷ (c + d)]

  • RR = 1: No difference in risk
  • RR > 1: Exposure increases risk
  • RR < 1: Exposure is protective (like a treatment)

Odds Ratio (OR): the ratio of odds:
OR = (a × d) ÷ (b × c)

The OR approximates the RR when the outcome is rare (under about 10% in both groups).
For a common outcome the OR sits further from 1 than the RR, in whichever direction the effect runs. A harmful exposure looks more harmful as an odds ratio, and a protective one looks more protective. Reporting an odds ratio as if it were a relative risk is one of the commonest ways a study’s effect gets exaggerated in the press.

Absolute Risk Reduction (ARR): the absolute difference in risk:
ARR = Risk in Unexposed − Risk in Exposed (when treatment reduces risk)
When the exposure raises risk, the same difference is the absolute risk increase (ARI).

Number Needed to Treat (NNT): how many people need treatment to prevent one additional case:
NNT = 1 ÷ ARR, rounded up to a whole person

A lower NNT means more effective treatment. An NNT of 1 is perfect (every treated patient benefits).
An NNT of 20 means 20 people must be treated to prevent 1 event. When the exposure causes harm, 1 ÷ ARI is the Number Needed to Harm (NNH).

Confidence intervals

A ratio from a small study can be wildly uncertain, so the calculator gives 95% confidence intervals using the usual large-sample formulas, worked on the log scale:
SE of ln(RR) = √(1/a − 1/(a+b) + 1/c − 1/(c+d))
SE of ln(OR) = √(1/a + 1/b + 1/c + 1/d)
95% CI = exp(ln(ratio) ± 1.96 × SE)

If the interval includes 1, the study cannot tell its result apart from no effect at the 95% level, however impressive the point estimate looks. The NNT interval follows Altman’s 1998 method, the reciprocal of the risk difference’s interval. When that interval crosses zero, the NNT interval runs from a benefit, through infinity, to a harm, which sounds odd but is the honest answer.

Zero cells

A zero in the table is a real result, not a mistake, but it breaks the ratios. The calculator then applies the Haldane-Anscombe correction (adding 0.5 to every cell) to the ratios and their intervals, and says so. When both groups have zero events, or both have nothing but events, there is no ratio to estimate at all.

Example

A clinical trial: 200 exposed, 200 unexposed.

  • Exposed: 40 had the outcome (a=40, b=160)
  • Unexposed: 20 had the outcome (c=20, d=180)

RR = (40/200) ÷ (20/200) = 0.20 ÷ 0.10 = 2.0, 95% CI 1.21 to 3.30 (exposure doubles the risk)
OR = (40 × 180) ÷ (160 × 20) = 7200 ÷ 3200 = 2.25, 95% CI 1.26 to 4.01
The absolute risk increase is 10 points, so one extra person has the outcome for every 10 exposed.

The odds ratio of 2.25 is larger than the relative risk of 2.0 because a 20% outcome is not rare. If a headline said “2.25 times the risk”, it would be quoting the odds ratio as if it were the relative risk.

If you have event rates rather than counts, the NNT calculator works from percentages instead.


How we build and check this calculator

This calculator runs entirely in your browser, so the numbers you enter stay on your device. The math behind it is written by hand and tested against worked examples and standard references before the page goes live.

SuperGlobalCalculator is independently built and maintained. See how we build and verify our calculators.


A FREE website for what you create, plus a link-in-bio page, at myname.tublish.com. No credit card needed. A FREE website for what you create, plus a link-in-bio page, at myname.tublish.com. No credit card needed.

Embed This Calculator

Copy the code below and paste it into your website or blog.
The calculator will work directly on your page.