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.
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.
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.
Given a 2×2 table:
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.
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.
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.