The formula
2×2 table: a = exposed with outcome, b = exposed without, c = unexposed with outcome, d = unexposed without
Risk (exposed) = a ÷ (a + b); risk (unexposed) = c ÷ (c + d)
Relative risk RR = [a ÷ (a + b)] ÷ [c ÷ (c + d)]
Odds ratio OR = (a × d) ÷ (b × c)
95% CI = exp(ln(x) ± 1.96 × SE)
SE ln(OR) = √(1/a + 1/b + 1/c + 1/d)
SE ln(RR) = √(1/a − 1/(a+b) + 1/c − 1/(c+d))
Risk difference = risk exposed − risk unexposed; NNT = 1 ÷ |risk difference|
Worked example
- In a trial, 15 of 100 treated patients and 30 of 100 controls have a heart attack.
- Risk with treatment = 15 ÷ 100 = 15%; risk in controls = 30 ÷ 100 = 30%.
- Relative risk = 0.15 ÷ 0.30 = 0.50 (95% CI 0.29 to 0.87): treatment halves the risk.
- Odds ratio = (15 × 70) ÷ (85 × 30) = 1,050 ÷ 2,550 = 0.41 (95% CI 0.21 to 0.83).
- The absolute risk difference is −15 percentage points, so the number needed to treat is 1 ÷ 0.15 = 6.7, rounded up to 7.
- The p-value is 0.012, so the difference is statistically significant at the 5% level.
Relative risk
Relative risk (RR), also called the risk ratio, compares the probability of an outcome in an exposed or treated group with the probability in an unexposed or control group. An RR of 1 means no difference, below 1 means lower risk in the exposed group, and above 1 means higher risk. In the example, an RR of 0.5 means treated patients had half the risk of controls, a 50% relative risk reduction. RR is intuitive and is the preferred measure for cohort studies and randomised trials, where you follow groups forward in time and can measure the risk directly.
Odds ratio
The odds ratio (OR) compares odds rather than probabilities. Odds are the number of people with the outcome divided by those without it: 15 to 85 in the treated group. ORs are used in case-control studies, where researchers choose people because they already have the outcome and so can't calculate risks, and in logistic regression. When the outcome is rare, below about 10%, the OR and RR are close. When it's common, the OR exaggerates the effect: it's further from 1 than the RR, as the example shows (0.41 against 0.50). Reading an OR as if it were a relative risk is one of the most common mistakes in reporting research.
Confidence intervals and p-values
The 95% confidence interval shows the range of values compatible with the data. If it doesn't include 1, the result is statistically significant at the 5% level. The intervals here use the standard log (Woolf) method, and the p-value comes from a z-test on the log odds ratio. With small counts, exact methods such as Fisher's exact test are more reliable. If any cell is zero, the calculator adds 0.5 to every cell, known as the Haldane–Anscombe correction, so that ratios and intervals can be calculated.
Absolute risk and NNT
Relative measures can make effects sound bigger than they are. A treatment that cuts risk from 2% to 1% has an RR of 0.5, the same as one that cuts it from 30% to 15%, but its absolute benefit is fifteen times smaller. The risk difference (absolute risk reduction) shows the actual change in percentage points, and the number needed to treat (NNT) turns it into a practical figure: how many people must be treated for one to benefit. When the exposure increases risk, the same calculation gives the number needed to harm (NNH). Always look at absolute figures when weighing up treatments or health risks.
Relative risk in the news
Health headlines often report relative risks without the baseline. "Eating X raises cancer risk by 20%" sounds alarming, but if the lifetime risk goes from 5% to 6%, that's one extra case per 100 people. When you read about a study, look for the absolute risks in each group, the confidence interval, and whether the study was a randomised trial or an observational study. Observational studies can show associations, but confounding factors, such as income, smoking or other habits, may explain part or all of the effect.
Setting up your table
Put the exposed or treated group in the first row and the unexposed or control group in the second, with the outcome of interest (such as disease or death) in the first column. Swapping rows inverts the ratios (an RR of 0.5 becomes 2.0), so check that the direction matches your question. For test accuracy rather than group comparisons, use our sensitivity and specificity calculator, and for percentages and changes, the percentage change calculator.