InfyCalculator
📊

Relative Risk Calculator (Risk Ratio with Confidence Interval)

Calculate relative risk (the risk ratio) from a 2×2 table with its confidence interval, plus the odds ratio, absolute risk difference, NNT or NNH, chi-square and Fisher exact p-values, and the worked steps.

Enter the table as
Exposed — cases
Exposed — total
Exposed — non-cases
Unexposed — cases
Unexposed — total
Unexposed — non-cases
Confidence level
The outcome is
Zero-cell correction
Loading calculator…

How it works

RR = [a ÷ (a + b)] ÷ [c ÷ (c + d)] · SE(ln RR) = √(1/a − 1/(a+b) + 1/c − 1/(c+d)) · CI = exp(ln RR ± z × SE) · OR = ad ÷ bc, SE(ln OR) = √(1/a + 1/b + 1/c + 1/d) · Risk difference = p₁ − p₂ · NNT = 1 ÷ |p₁ − p₂| · χ² = N(ad − bc)² ÷ (n₁ n₂ m₁ m₂)

Relative risk compares how often an outcome happens in an exposed (or treated) group with how often it happens in an unexposed (or control) group. Each group’s risk is its cases divided by its total, and RR is the exposed risk divided by the unexposed risk: 1 means no difference, above 1 means the exposure goes with more of the outcome, below 1 means less (a protective effect). The confidence interval uses the standard log method (Katz; Altman 1991): the standard error is worked out for ln(RR), the interval is built on the log scale and then exponentiated, so it is not symmetric around RR. An interval that excludes 1 means the result is statistically significant at that level. Enter the cases and totals, or the four 2×2 cells directly, and pick 90%, 95%, 99% or 99.9% confidence. The calculator also gives the absolute picture — the risk difference in percentage points with its own interval and the number needed to treat (NNT) or harm (NNH), with the Altman interval that runs through infinity when the difference is not significant — plus the odds ratio (Woolf interval), the relative risk increase or reduction, attributable fractions, and three tests of association: Pearson chi-square, chi-square with Yates’ correction, and Fisher’s exact test for small samples. When a cell is zero, 0.5 is added to every cell for the ratio measures, as MedCalc and Cochrane do; you can switch that off or apply it always.

Worked example

In a cohort, 30 of 100 exposed people and 10 of 100 unexposed people develop the outcome. The risks are 30% and 10%, so RR = 0.30 ÷ 0.10 = 3. The standard error of ln(RR) is √(1/30 − 1/100 + 1/10 − 1/100) = 0.3367, and the 95% interval is exp(1.0986 ± 1.96 × 0.3367) = 1.551 to 5.803 — it excludes 1, so the tripling of risk is statistically significant. The risk difference is 20 percentage points (95% CI 9.26 to 30.74), giving a number needed to harm of 1 ÷ 0.20 = 5. The odds ratio is (30 × 90) ÷ (70 × 10) = 3.857 (95% CI 1.767 to 8.422); Pearson χ² = 12.5 (p = 0.000407) and the Fisher exact p is 0.00065.

Sources: MedCalc — relative risk calculator and method (Altman 1991) · Cochrane Handbook, chapter 6: choosing effect measures · Altman DG (1998), Confidence intervals for the number needed to treat, BMJ 317:1309

Frequently asked questions

What is the difference between relative risk and odds ratio?

Relative risk compares probabilities directly and is the natural measure in cohort studies and trials, where you follow groups forward. The odds ratio compares odds and is the only valid ratio in case-control studies, where you choose people by outcome. For rare outcomes the two are close; for common outcomes the OR is further from 1 than the RR (here 3.86 against 3.0).

How is the confidence interval for relative risk calculated?

With the log method: SE = √(1/a − 1/(a+b) + 1/c − 1/(c+d)), then exp(ln RR ± z × SE), with z = 1.96 for 95%. Working on the log scale keeps the interval above zero and makes it lopsided — wider above RR than below — which is correct for a ratio.

Why does absolute risk matter alongside relative risk?

A large relative risk can hide a tiny absolute change. Tripling a risk from 1 in a million to 3 in a million is an RR of 3 but almost no real-world impact. The risk difference and NNT show how many people are actually affected, so read them together.

What do NNT and NNH mean?

NNT is how many people need the treatment for one extra person to benefit; NNH is how many need the exposure for one extra person to be harmed. Both are 1 divided by the absolute risk difference and are usually rounded up. When the risk difference interval crosses zero, the NNT interval runs from benefit through infinity to harm.

Which p-value should I use — chi-square or Fisher?

With large counts they agree closely. When any expected cell count is below 5 the chi-square approximation is poor and Fisher’s exact test is preferred; the calculator warns you when that happens. The z test on ln(RR) matches the confidence interval: p < 0.05 exactly when the 95% interval excludes 1.

What if one of the cells is zero?

Then ln(RR) or ln(OR) has an infinite standard error. By default the calculator adds 0.5 to all four cells (the Haldane–Anscombe correction), as MedCalc and the Cochrane Handbook describe, and says so in a note. The raw group risks are still shown from the original counts.

Does a relative risk above 1 prove the exposure is harmful?

No. It shows an association in this data, not causation. Confounding, selection and chance all matter; the confidence interval and p-values address only chance.

Related calculators

For education — check assumptions (sample size, distribution) before using statistics in real decisions.