Understanding the relative risk calculator — concept and principle
This calculator compares the risk of an outcome between an exposed and an unexposed group from a 2 × 2 table. It gives the relative risk (RR), odds ratio (OR), risk difference, their confidence intervals, and the number needed to treat or harm. Use it for cohort studies, trials and reading medical research.
How it is calculated
Table: exposed a (outcome) and b (no outcome); unexposed c and d.
- Risks: p₁ = a/(a + b), p₂ = c/(c + d).
- RR = p₁ ÷ p₂; OR = ad ÷ bc; RD = p₁ − p₂.
- SE(ln RR) = √(1/a + 1/c − 1/(a + b) − 1/(c + d)); SE(ln OR) = √(1/a + 1/b + 1/c + 1/d). Interval = exp(ln estimate ± z·SE).
- SE(RD) = √(p₁(1 − p₁)/n₁ + p₂(1 − p₂)/n₂).
- NNT/NNH = 1 ÷ |RD|, rounded up.
z = 1.645, 1.960 or 2.576 for 90, 95 or 99%. If any cell is 0, 0.5 is added to every cell for the ratios.
The principle
Risk is the share of a group that has the outcome. Dividing two risks says how many times more likely the outcome is in one group, which is easy to interpret in cohort studies and trials. The odds ratio compares odds instead and is the measure available in case–control studies, where the groups are chosen by outcome. Ratios are skewed, so their intervals are built on the log scale, where the sampling distribution is close to normal, and then converted back. The risk difference shows the absolute effect, which drives the number needed to treat or harm.
Worked example
Default inputs: a = 30, b = 70, c = 15, d = 85, 95% confidence.
- Risks: 30/100 = 30% exposed, 15/100 = 15% unexposed.
- RR = 0.30 ÷ 0.15 = 2, a 100% relative increase.
- SE(ln RR) = √(1/30 + 1/15 − 1/100 − 1/100) = √0.08 ≈ 0.2828; interval = exp(ln 2 ± 1.96 × 0.2828) = 1.149 to 3.482.
- OR = (30 × 85) ÷ (70 × 15) = 2,550 ÷ 1,050 ≈ 2.429, interval 1.211 to 4.870.
- RD = 15 points, interval 3.61 to 26.39; NNH = 1 ÷ 0.15 = 6.67, rounded up to 7.
How to read the result
RR = 1 means no difference; above 1 means higher risk with exposure, below 1 lower. If the interval excludes 1, the difference is statistically significant at that level. The OR is close to the RR only when the outcome is rare; here, with a 30% risk, the OR (2.43) exaggerates the RR (2). An NNH of 7 means that, on average, for every 7 people exposed, one extra person has the outcome.
Common mistakes
- Reporting the OR as if it were the RR when the outcome is common.
- Using RR from a case–control study, where it cannot be estimated.
- Quoting only the relative change ("risk doubled") without the absolute difference.
Frequently asked questions
What is the difference between relative risk and odds ratio?
RR compares probabilities; OR compares odds. They are similar only for rare outcomes.
What does a confidence interval of 1.149 to 3.482 mean?
The data are consistent with a true RR anywhere in that range at 95% confidence; it does not include 1.
When is NNT used instead of NNH?
NNT when the exposure lowers risk (a benefit), NNH when it raises risk (a harm).
Sources: Altman, D. G., Practical Statistics for Medical Research (1991) · MedCalc Software manual, "Relative risk, risk difference and odds ratio"