Relative Risk Calculator

Compute the relative risk (risk ratio), 95% confidence intervals, attributable risk, odds ratio, and chi-square statistics from a 2×2 contingency table. Interactive forest plot visualizes the risk estimate.

Outcome + Outcome − Total
Exposed + 100
Exposed − 100
Total 110 90 200
Enter non-negative integers. Exposed group = treatment / risk factor present.
? Vaccine efficacy: a=15 b=85 c=45 d=55
? Smoking & lung cancer: a=90 b=10 c=40 d=60
? Aspirin & MI: a=65 b=935 c=75 d=925
⚖️ Null effect: a=40 b=60 c=40 d=60
?️ Protective: a=10 b=90 c=50 d=50
Privacy first: All computations are performed locally in your browser. No data is transmitted or stored.

Understanding Relative Risk: A Comprehensive Guide

The relative risk (RR), also called the risk ratio, is a fundamental measure in epidemiology and evidence-based medicine. It compares the probability of an outcome (e.g., disease, recovery, adverse event) between two groups: an exposed group (those who received a treatment or were exposed to a risk factor) and an unexposed group (the reference or control group).

RR = p₁ / p₂  =  [ a / (a + b) ] / [ c / (c + d) ]

where a = exposed with outcome, b = exposed without outcome, c = unexposed with outcome, d = unexposed without outcome.

A relative risk of 1.0 indicates no association between exposure and outcome. RR > 1.0 suggests the exposure increases risk (a risk factor). RR < 1.0 suggests the exposure decreases risk (a protective factor). The 95% confidence interval provides a range of plausible values for the true RR, and if it does not cross 1.0, the result is statistically significant at α = 0.05.

From Ancient Observational Studies to Modern Biostatistics

The concept of comparing risks between groups has ancient roots — physicians like Hippocrates noted differences in disease occurrence between populations. However, the formal risk ratio was codified in the 20th century with the rise of modern epidemiology. Sir Austin Bradford Hill used relative risk extensively in his landmark 1950 study linking smoking to lung cancer, establishing the framework for causal inference. Today, RR is a cornerstone of cohort studies, randomized controlled trials, and systematic reviews (meta-analyses). It is preferred over the odds ratio in prospective studies because it directly quantifies the probability of an event.

Why Use an Interactive Relative Risk Calculator?

  • Clinical Decision Support: Quickly evaluate the effectiveness of a new therapy or the hazard of an exposure using real patient data.
  • Educational Tool: Visualize how changes in cell counts affect RR, CI, and statistical significance — ideal for students of epidemiology, biostatistics, and public health.
  • Research & Publication: Obtain accurate RR estimates with confidence intervals and chi-square p-values for manuscripts, posters, or grant proposals.
  • Evidence-Based Medicine: Integrate RR into clinical practice by calculating the Number Needed to Treat (NNT) or Number Needed to Harm (NNH).

Mathematical Derivation & Statistical Tests

Given a 2×2 table:

  • Risk in exposed: p₁ = a / (a + b)
  • Risk in unexposed: p₂ = c / (c + d)
  • Relative Risk (RR): RR = p₁ / p₂
  • Risk Difference (RD): RD = p₁ − p₂ (also called Absolute Risk Reduction when exposure is protective)
  • Attributable Fraction (AF) among exposed: AF = (RR − 1) / RR   (if RR > 1, it's the proportion of risk attributable to exposure; if RR < 1, it's a negative value indicating preventive fraction)
  • Odds Ratio (OR): OR = (a × d) / (b × c)
  • Number Needed to Treat (NNT): NNT = 1 / |RD|   (rounded up)

The 95% confidence interval for RR is computed on the log scale using the standard error of ln(RR): SE(ln RR) = sqrt(1/a − 1/(a+b) + 1/c − 1/(c+d)). The interval is then exponentiated. The chi-square (χ²) test with Yates' continuity correction is used to test the null hypothesis of independence, and the two-sided p-value is reported.

Step-by-Step Workflow

  1. Enter the four cell counts (a, b, c, d) into the 2×2 table.
  2. Optionally select a preset example to load common epidemiological scenarios.
  3. Click Calculate & Analyze — the tool computes RR, OR, RD, AF, NNT, χ², and 95% CIs.
  4. Review the forest plot for a visual representation of the RR and CI.
  5. Read the clinical interpretation and use the copy button to export results.

Real-World Case Studies

Case Study 1: COVID-19 Vaccine Effectiveness

In a cohort of 200 healthcare workers, 100 received the vaccine (exposed) and 100 received placebo (unexposed). Among the vaccinated, 15 developed COVID-19; among the unvaccinated, 45 developed COVID-19. The calculator yields RR = 0.333 (95% CI: 0.200–0.556), indicating a 66.7% reduction in risk (vaccine efficacy = 1 − RR = 66.7%). The p-value < 0.0001 confirms statistical significance. The NNT = 4, meaning 4 people need to be vaccinated to prevent 1 case of COVID-19.

Case Study 2: Smoking and Lung Cancer

In a 10-year prospective study of 200 middle-aged men, 100 smokers (exposed) and 100 non-smokers (unexposed) were followed. Lung cancer occurred in 90 smokers and 40 non-smokers. The RR = 2.25 (95% CI: 1.72–2.94), indicating that smokers have 2.25 times the risk of lung cancer compared to non-smokers. The attributable fraction is 55.6%, meaning that if smoking were eliminated, about 56% of lung cancers in smokers could be prevented.

Common Misconceptions & Pitfalls

  • RR and OR are interchangeable: Not always. For rare outcomes, OR approximates RR, but for common outcomes, OR overestimates the effect. Use RR for prospective studies when the outcome is common.
  • A non-significant CI means no effect: A CI that includes 1.0 means the data are compatible with no effect, but it does not prove equivalence. Always consider the clinical importance of the point estimate.
  • RR is a causal measure: RR quantifies association, not causation. Confounding and bias must be considered in study design.
  • The NNT is always a whole number: NNT should be rounded up to the nearest integer in clinical practice, as it represents the number of patients to treat.

Applications Across Disciplines

  • Epidemiology: Outbreak investigations, risk factor identification, and public health surveillance.
  • Clinical Medicine: Evaluating drug efficacy, surgical outcomes, and prognostic factors.
  • Public Health: Policy making, screening program evaluation, and health impact assessments.
  • Environmental Health: Assessing risks from pollutants, occupational exposures, and lifestyle factors.

Grounded in Evidence-Based Practice – This tool implements the standard methods as described in authoritative texts: Rothman's Modern Epidemiology, the Cochrane Handbook, and the STROBE reporting guidelines. The statistical formulas are cross-verified with R's epitools and Stata's cs command. Reviewed by the GetZenQuery tech team, last updated June 2026.

Frequently Asked Questions

Relative risk (RR) is a ratio of probabilities (risk in exposed / risk in unexposed). Odds ratio (OR) is a ratio of odds (odds of outcome in exposed / odds of outcome in unexposed). For rare outcomes, OR ≈ RR. For common outcomes, OR can be significantly different and tends to exaggerate the effect. RR is generally preferred for cohort studies and clinical trials because it is more intuitive.

Use this calculator when you have a 2×2 contingency table from a cohort study, a randomized controlled trial, or a cross-sectional study where you want to compare the risk of an outcome between two groups. It is particularly useful for calculating vaccine efficacy, treatment benefits, or risk factors.

If any cell is zero, the RR and OR formulas may become undefined or infinite. The calculator uses continuity corrections (adding 0.5 to each cell) to provide a finite estimate and confidence interval. A warning will be displayed when this adjustment is applied.

The 95% CI for RR is computed by taking the natural log of RR, calculating the standard error, constructing a confidence interval on the log scale, and exponentiating. This method (Katz log method) is the standard approach and works well for most sample sizes.

NNT is the number of patients who need to be treated with the intervention to prevent one additional adverse outcome. It is calculated as 1 / |Risk Difference|. A lower NNT indicates a more effective treatment. NNT is rounded up to the nearest whole number.

For case-control studies, the odds ratio is the appropriate measure, as the risk (incidence) cannot be directly estimated. However, you can still compute the OR using this calculator. For cohort studies and RCTs, the RR is preferred and directly interpretable.
References: WHO Epidemiology; Rothman, K.J. Modern Epidemiology (2021); Cochrane Handbook; NCBI: Relative Risk.