Relative Risk Calculator

Enter a 2×2 cohort table to get the relative risk (risk ratio) with its confidence interval, the risk difference, the relative risk reduction or increase, the number needed to treat or to harm, and the chi-square and Fisher exact p-values.

Relative risk needs data from a cohort study or a trial, where the groups were followed to see who had the event. For case-control data use the odds ratio calculator; for the difference between the two measures see relative risk vs odds ratio. For very small groups compare the Fisher exact test. Educational only, not medical advice.

Paste a 2×2 table of counts, one row per line, the counts separated by tabs, commas or spaces:

What relative risk measures

Relative risk (RR), also called the risk ratio, compares how likely an event is in two groups. If 50 of 70 exposed people and 30 of 130 unexposed people have the event, the risks are 0.7143 and 0.2308, and RR = 0.7143 / 0.2308 = 3.0952: the exposed group has about three times the risk. RR = 1 means the risks are equal, RR > 1 means a higher risk in the first (exposed) group and RR < 1 a lower risk.

It is the natural measure for cohort studies and randomised trials, where the groups are followed to see who has the event, so each group's risk is observed. Case-control studies fix the number of cases and controls in advance, so risks cannot be estimated from them and they report the odds ratio instead. In a cross-sectional survey the same ratio is called the prevalence ratio.

How to use the relative risk calculator

  1. Enter the counts. Row 1 is the exposed (or treated) group and row 2 the unexposed (or control) group; column 1 counts the subjects with the event and column 2 those without it. You can rename the rows and columns, or paste a table.
  2. Choose the confidence level and the interval for the risk difference: the Newcombe score interval (recommended) or the Wald interval.
  3. Press Calculate Relative Risk. The results follow every later change to the table.
  4. Load example enters 50 of 70 exposed and 30 of 130 unexposed, Clear empties the table and Copy link to this calculation shares your table, labels and settings.

Relative risk formulas

Risk₁ = a / (a + b), Risk₂ = c / (c + d)

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

SE(ln RR) = √( b / (a(a + b)) + d / (c(c + d)) )

CI for RR = exp( ln RR ± z × SE(ln RR) ), z = 1.96 for 95%

Risk difference = Risk₁ − Risk₂

Relative risk reduction = 1 − RR

NNT = 1 / |risk difference|

The counts are a and b (the first group with and without the event) and c and d (the second group). The interval for RR is computed on the log scale (Katz et al. 1978), because ln RR is much closer to normal than RR itself, so the interval is not symmetric around RR. It needs at least one event in each group.

The interval for the risk difference is Newcombe's hybrid score interval (method 10 in Newcombe 1998) or the Wald interval. The score interval keeps its coverage better for small counts and for risks near 0 or 1, and it always stays between −1 and 1. The interval for the number needed to treat is made of the reciprocals of the limits of the risk-difference interval (Altman 1998). When that interval includes 0 the number needed is unbounded, and the interval is shown as one limit on the benefit side and one on the harm side.

Worked example: 50 of 70 exposed, 30 of 130 unexposed

Press Load example to enter this table: a = 50, b = 20, c = 30, d = 100.

Working

Risk (exposed) = 50 / 70 = 0.7143 and risk (unexposed) = 30 / 130 = 0.2308.

RR = 0.7143 / 0.2308 = 3.0952 and ln(RR) = 1.1299.

SE = √( 20 / (50 × 70) + 100 / (30 × 130) ) = √0.031355 = 0.1771.

95% CI = exp( 1.1299 ± 1.96 × 0.1771 ) = 2.1876 to 4.3795.

Risk difference = 0.7143 − 0.2308 = 0.4835, with a Newcombe 95% interval of 0.3439 to 0.5960 (Wald 0.3553 to 0.6118). NNH = 1 / 0.4835 = 2.0682, with a Newcombe interval of 1.6778 to 2.9080.

The relative risk increase is 3.0952 − 1 = 209.52% (118.76% to 337.95%). The chi-square p-value is 2.7852e-11 and the Fisher exact p-value 3.1353e-11.

The interval 2.1876 to 4.3795 does not include 1, so the exposed group has a significantly higher risk. Because both groups are large the two p-values agree. The same relative risk and interval come out of SciPy's relative_risk and of statsmodels' Table2x2.riskratio_confint.

Worked example: a protective treatment

Suppose 10 of 100 treated patients and 30 of 100 controls have the event. Enter 10, 90 in the first row and 30, 70 in the second: the risks are 0.10 and 0.30, so RR = 0.3333 with a 95% interval of 0.1723 to 0.6448. The relative risk reduction is 1 − 0.3333 = 66.67% (35.52% to 82.77%).

The risk difference is −0.20, a Newcombe 95% interval of −0.3058 to −0.0900: 20 fewer events per 100 patients. The number needed to treat is 1 / 0.20 = 5, with a Newcombe interval of 3.2702 to 11.1109: treat 5 patients to prevent one event. The chi-square p-value is 0.000407 and the Fisher exact p-value 0.00065.

The relative reduction does not depend on the baseline risk but the absolute one does. If the same RR of one third applied to a baseline risk of 3%, the risk would fall to 1%, the risk difference would be 2 percentage points and the NNT would be 50. Always report the absolute numbers next to the relative ones.

Relative risk, odds ratio and risk difference compared

MeasureFormulaIt answersUse it for
Relative risk[a / (a + b)] / [c / (c + d)]How many times as likely is the event?Cohort studies and trials; the prevalence ratio of cross-sectional data
Odds ratio(a × d) / (b × c)How many times as large are the odds of the event?Case-control studies and logistic regression; close to RR when the event is rare
Risk differencerisk₁ − risk₂How many more events per subject?The absolute size of an effect
NNT or NNH1 / |risk difference|How many subjects must be treated (or exposed) for one event more or less?Clinical and policy decisions

The odds ratio of the table above is 8.3333, far from the relative risk of 3.0952, because the event is common: it occurs in 71% and 23% of the two groups. When the event is rare the two agree. With 120 events among 10,000 exposed and 90 among 10,000 unexposed subjects, RR = 1.3333 and OR = 1.3374. Use the odds ratio calculator for the odds, and read relative risk vs odds ratio for when each is appropriate.

How to read the result

  • Relative risk and its interval. RR = 1 means no association. If the interval excludes 1, the difference in risk is statistically significant at the level 100% minus the confidence level; if it includes 1 the data are compatible with no difference. The interval also shows how imprecise the estimate is.
  • Relative and absolute measures. An RR of 2 can mean 2% against 1% or 40% against 20%. The risk difference and the NNT say how much the event count changes, and they depend on the baseline risk.
  • Reduction or increase. The relative risk reduction is 1 − RR. When the risk is higher in the first group the calculator reports the relative risk increase, RR − 1, instead.
  • Number needed to treat or to harm. The NNT is the reciprocal of the absolute risk reduction, and it is conventionally rounded up to the next whole number. It is a number needed to harm (NNH) when the exposure raises the risk. An interval that runs through infinity means the data allow both benefit and harm.
  • The two p-values. The chi-square p-value is an approximation that needs every expected count to be at least 5. The Fisher exact p-value has no such condition, so prefer it for small tables. The calculator warns when an expected count is below 5.
  • Empty cells. With no events in the unexposed group RR is infinite, and with no events in the exposed group it is 0; in both cases the log interval cannot be computed. The odds ratio calculator offers the Haldane-Anscombe correction for such tables.

Relative risk in Excel, R, Python and SPSS

SoftwareHow to get it
ExcelWith a, b, c, d in A2:D2: =(A2/(A2+B2))/(C2/(C2+D2)) for RR. If E2 holds RR, the limits of the 95% interval are =EXP(LN(E2)-1.96*SQRT(B2/(A2*(A2+B2))+D2/(C2*(C2+D2)))) and =EXP(LN(E2)+1.96*SQRT(B2/(A2*(A2+B2))+D2/(C2*(C2+D2))))
Rlibrary(epitools); riskratio(matrix(c(50, 20, 30, 100), nrow = 2, byrow = TRUE), rev = "both"). epitools expects the reference (unexposed) row first and the non-event column first, so rev = "both" turns this layout around; the Wald interval it prints is the log interval used here
Pythonfrom scipy.stats.contingency import relative_risk; result = relative_risk(50, 70, 30, 130); result.relative_risk and result.confidence_interval(0.95). statsmodels: Table2x2(np.array([[50, 20], [30, 100]])).riskratio and .riskratio_confint()
SPSSAnalyze > Descriptive Statistics > Crosstabs, then Statistics > Risk. The Risk Estimate table lists the odds ratio and, under For cohort, the relative risk with its 95% confidence interval; check which row and column SPSS treats as the exposed group and the event

Frequently Asked Questions

What is relative risk?

Relative risk, or the risk ratio, is the risk of an event in the exposed group divided by the risk in the unexposed group: RR = [a / (a + b)] / [c / (c + d)] for a table with a, b in the exposed row and c, d in the unexposed row. It says how many times as likely the event is in the first group.

How do I calculate relative risk?

Divide the number of events by the group size in each group to get the two risks, then divide the first risk by the second. With 50 events among 70 exposed subjects and 30 among 130 unexposed, the risks are 0.7143 and 0.2308 and RR = 3.0952.

How do I interpret a relative risk?

RR = 1 means the risk is the same in both groups, RR above 1 means a higher risk in the first group and RR below 1 a lower one. RR = 3.0952 means the first group has about 3.1 times the risk, 209.52% higher, and RR = 0.3333 means a risk two thirds lower. Read the confidence interval with it: an interval that includes 1 is compatible with no effect.

What does a relative risk of 1 mean?

It means no association: the event is equally likely in both groups. A confidence interval that includes 1 means the data cannot rule out that the true relative risk is 1.

What is a good or a significant relative risk?

There is no universal cutoff. The result is statistically significant at the chosen level when the confidence interval excludes 1, and it matters in practice when the absolute change is large enough to act on. A small relative risk such as 1.2 can be important for a common event and irrelevant for a very rare one.

What is the difference between relative risk and odds ratio?

Relative risk compares probabilities, the odds ratio compares odds, p / (1 − p). They are close when the event is rare and diverge as it becomes common: the same table gives RR = 3.0952 but OR = 8.3333 when the event occurs in 71% and 23% of the groups. Relative risk needs cohort data, the odds ratio also works for case-control data.

How do I calculate the relative risk reduction, absolute risk reduction and NNT?

The relative risk reduction is 1 − RR, the absolute risk reduction is the risk in the control group minus the risk in the treated group, and the number needed to treat is 1 divided by the absolute risk reduction. With risks of 0.10 and 0.30, RR = 0.3333, RRR = 66.67%, ARR = 0.20 and NNT = 5. The calculator shows the risk difference, which is the negative of the ARR.

How is the number needed to treat rounded?

By convention it is rounded up to the next whole number, so an NNT of 2.07 is reported as 3. It is a number needed to harm when the exposure raises the risk. When the confidence interval of the risk difference includes 0 the interval for the NNT runs through infinity, which the calculator shows as a benefit limit and a harm limit.

Can I calculate relative risk for a case-control study?

No. A case-control study fixes the number of cases and controls, so the risk of the event in each exposure group cannot be estimated. Use the odds ratio; when the event is rare in the population it approximates the relative risk.

What if one group has no events?

With no events in the unexposed group the relative risk is infinite, and with no events in the exposed group it is 0; the log interval needs at least one event in each group, so no interval is shown. Report the counts, use the risk difference and the Fisher exact test, or use the Haldane-Anscombe correction in the odds ratio calculator.

Why is the confidence interval not symmetric around the relative risk?

The interval is computed for ln(RR), which is approximately normal, and then transformed back with the exponential function. The upper limit is therefore further from RR than the lower limit: 3.0952 has the interval 2.1876 to 4.3795.

Should I use the chi-square or the Fisher exact p-value?

The chi-square p-value is an approximation that is reliable when every expected count is at least 5. The Fisher exact p-value is exact for any 2×2 table, so it is the safer choice for small tables, and the two agree for large ones. The calculator warns when an expected count is below 5.

Is relative risk the same as a hazard ratio?

No. Relative risk compares the proportion of subjects with the event over a fixed follow-up, while the hazard ratio compares event rates over time and comes from survival analysis such as a Cox model. Relative risk ignores when the events happened.

How do I calculate relative risk in Excel?

With the counts a, b, c, d in cells A2 to D2, type =(A2/(A2+B2))/(C2/(C2+D2)). For the 95% interval take the exponential of LN(RR) ± 1.96 × SQRT(B2/(A2*(A2+B2))+D2/(C2*(C2+D2))). The calculator does this in one step and adds the risk difference and the NNT.

Why does another calculator give a different interval?

Check the layout first: swapping the two rows gives the reciprocal, 1 / 3.0952 = 0.3231. The interval for RR here is the log (Katz) interval, the one used by SciPy, statsmodels and the Wald method of R's epitools; other tools may use exact or bootstrap intervals. The risk-difference interval differs between the Wald and Newcombe options.

Embed This Calculator

Add this free calculator to your course page or LMS.

Adjust the height value to fit your page.