Relative Risk Calculator
Relative risk, odds ratio, risk difference and number needed to treat or harm from a 2 × 2 table, each with a confidence interval.
Result…
How it's calculated
RR = [a ÷ (a + b)] ÷ [c ÷ (c + d)], SE(ln RR) = √(1/a − 1/(a + b) + 1/c − 1/(c + d)) OR = ad ÷ bc, SE(ln OR) = √(1/a + 1/b + 1/c + 1/d) CI = e^(ln estimate ± z × SE) RD = p₁ − p₀, SE = √(p₁(1 − p₁) ÷ n₁ + p₀(1 − p₀) ÷ n₀) NNT or NNH = 1 ÷ |RD|
A 2 × 2 table sets an exposed (or treated) group against an unexposed (or control) group and counts who had the outcome. The relative risk compares the two risks as a ratio, the odds ratio compares the odds, and the risk difference is the absolute gap, whose reciprocal is the number needed to treat (or to harm): how many people must be exposed for one extra outcome. Relative measures sound bigger than absolute ones when the outcome is rare, so report both. When the outcome is rare the odds ratio is close to the relative risk; when it is common the odds ratio is further from 1. A zero cell makes the logs undefined, so the common Haldane–Anscombe correction adds 0.5 to each cell, and the calculator says when it has done so.
Your numbers, step by step
About the Relative Risk calculator
This relative risk calculator takes a 2 × 2 table, an exposed or treated group against an unexposed or control group, each split by whether the outcome happened, and gives the four measures used in trials, cohort studies and epidemiology: the relative risk, the odds ratio, the risk difference and the number needed to treat or harm. Each comes with a confidence interval at the level you choose: the log method for the two ratios and a Wald interval for the risk difference. The steps show both risks, every standard error and the z value, so you can check the working by hand. If any cell is zero, the calculator adds 0.5 to every cell for the ratios and says so in the steps and the note. When the risk difference interval crosses zero, the NNT interval is written the way Altman suggested, running through infinity.
How to use it
- Enter the four counts: “Exposed: outcome yes (a)”, “Exposed: outcome no (b)”, “Unexposed: outcome yes (c)” and “Unexposed: outcome no (d)”.
- Under “The outcome is”, say whether the outcome is unwanted (an illness, an event) or wanted (a recovery), so the calculator can call the result an NNT or an NNH.
- Choose the “Main result” you want to see first: relative risk, odds ratio, risk difference or NNT / NNH.
- Set the “Confidence level”, usually 95%.
- Read the estimate with its lower and upper limits, then the other measures, and look at the steps for the working.
Worked example
In a trial, 15 of 100 treated patients and 30 of 100 controls have the event. The risks are 15 ÷ 100 = 0.15 and 30 ÷ 100 = 0.3, so the relative risk is 0.15 ÷ 0.3 = 0.5 with a 95% interval of 0.2872 to 0.8704. The odds ratio is (15 × 70) ÷ (85 × 30) = 0.4118 (0.2053 to 0.8258). The risk difference is 0.15 − 0.3 = −0.15 (−0.2639 to −0.03614), so the number needed to treat is 1 ÷ 0.15 = 6.67, about 7 patients treated to prevent one event, with an interval of 3.79 to 27.67.
Updated
Questions people ask
How do I calculate relative risk from a 2 × 2 table?
Divide the risk in the exposed group, a ÷ (a + b), by the risk in the unexposed group, c ÷ (c + d). A relative risk of 1 means no difference, below 1 means the exposure goes with less of the outcome, and above 1 with more.
What is the difference between relative risk and odds ratio?
Relative risk compares probabilities, while the odds ratio compares odds, (a ÷ b) ÷ (c ÷ d). They are close when the outcome is rare, but when it is common the odds ratio lies further from 1. In a case-control study only the odds ratio can be estimated.
What is the formula for number needed to treat?
NNT = 1 ÷ |risk difference|, usually rounded up to a whole person. If the exposure makes an unwanted outcome more likely, the same number is the number needed to harm. For more on effect measures, see the effect size calculator.
What happens when one of the cells is zero?
The logs of the ratios are then undefined, so the calculator adds 0.5 to all four cells (the Haldane–Anscombe correction) before working out the relative risk, the odds ratio and their intervals. This moves both ratios a little towards 1, so treat those intervals as rough.
Is a relative risk of 0.5 a big effect?
Halving a risk sounds large, but its practical size depends on the starting risk: going from 30% to 15% is a big absolute change, and going from 0.2% to 0.1% is a small one. That is why the risk difference and NNT are shown next to the ratios.
What are the limits of these confidence intervals?
The log and Wald intervals are large-sample approximations, so with small counts exact or score intervals are more reliable, and none of them shows that the exposure caused the outcome. For medical decisions, talk to a doctor or a statistician who knows the study.