Skip to content
Statistics

Relative Risk Calculator

Enter the four cell counts from a 2x2 contingency table to get the relative risk (risk ratio), its confidence interval, p-value, number needed to treat, odds ratio, and attributable fraction. Every step is shown so you can verify the arithmetic.

Your details

Cell a: people in the exposed group who experienced the outcome.
cases
Cell b: people in the exposed group who did not experience the outcome.
cases
Cell c: people in the unexposed group who experienced the outcome.
cases
Cell d: people in the unexposed group who did not experience the outcome.
cases
Confidence level for the RR interval. 95% is the clinical standard.
Relative risk (RR)Increased risk
2
Risk in exposed30%
Risk in unexposed15%
CI lower bound1.149
CI upper bound3.482
P-value (two-tailed)0.0143
Absolute risk difference (ARR)15%
NNT / NNH6.7
Odds ratio (OR)2.429
Attributable fraction (exposed)50%
Risk (exposed)30%
Risk (unexposed)15%

The exposed group is 100% more likely to experience the outcome (RR = 2).

  • Risk in the exposed group is 30% versus 15% in the unexposed group, an absolute difference of 15 percentage points.
  • The 95% confidence interval for RR is (1.149, 3.482). The interval excludes 1, suggesting a statistically significant association.
  • Two-tailed p-value: 0.0143, which is below the conventional 0.05 threshold.
  • Number Needed to Harm (NNH): approximately 7 people, the number who must be exposed (or treated) for one additional outcome to occur (or be prevented).

Next stepAssociation is not causation. Confounding, bias and chance can all shift a risk ratio. Pair this with a confidence interval and a careful assessment of study design.

Formula

RR=a/(a+b)c/(c+d),SE{lnRR}=1a+1c1a+b1c+d,CI=elnRR±zSERR = \dfrac{a/(a+b)}{c/(c+d)}, \quad SE\{\ln RR\} = \sqrt{\dfrac{1}{a}+\dfrac{1}{c}-\dfrac{1}{a+b}-\dfrac{1}{c+d}}, \quad CI = e^{\ln RR \pm z \cdot SE}

Worked example

With a = 30, b = 70, c = 15, d = 85: risk in exposed = 30/100 = 0.30, risk in unexposed = 15/100 = 0.15, RR = 2.00. SE = sqrt(1/30 + 1/15 - 1/100 - 1/100) = 0.2981. 95% CI = exp(ln(2) +/- 1.96 x 0.2981) = (1.12, 3.58). ARR = 15%, NNT = 6.7. OR = (30 x 85) / (70 x 15) = 2.43. Attributable fraction = (2-1)/2 = 50%.

What relative risk measures

Relative risk, also called the risk ratio, compares the probability of an outcome occurring in an exposed group with the probability in an unexposed group. It is built from a 2x2 contingency table whose four cells count the exposed individuals with and without the event (a and b) and the unexposed individuals with and without the event (c and d). The risk in each group is the number of events divided by the group total, and the relative risk is the exposed risk divided by the unexposed risk. It is the natural effect measure for cohort studies and randomized controlled trials, where you follow defined groups forward in time and directly observe how often the event happens.

Confidence interval and p-value

A point estimate of the risk ratio tells you the direction and size of the association, but not how precisely it is measured. The confidence interval (CI) captures that uncertainty: if the 95% CI runs from 1.12 to 3.58, you can say with 95% confidence that the true RR lies somewhere in that range. When the interval excludes 1 the association is statistically significant at the chosen level. The p-value (computed here as a two-tailed test using z = ln(RR) / SE) gives the probability of observing a ratio this large or larger by chance alone if the null hypothesis RR = 1 were true. Both the CI and p-value are calculated using the log-normal approximation: SE of ln(RR) = sqrt(1/a + 1/c - 1/(a+b) - 1/(c+d)), which is the standard Katz et al. (1978) formula used in most epidemiology textbooks and clinical tools such as MedCalc.

NNT and NNH: translating ratios into counts

The Number Needed to Treat (NNT) or Number Needed to Harm (NNH) converts the absolute risk difference (ARR) into a count that is easier to grasp clinically. NNT = 1 / |ARR|. If an intervention reduces the event rate from 15% to 10%, the ARR is 5 percentage points and you need to treat 20 patients (1 / 0.05) to prevent one additional event. A lower NNT means a more effective intervention; a lower NNH means a more dangerous exposure. Unlike the RR, the NNT depends on the baseline risk and will differ across populations even when the RR is the same.

Attributable fraction and odds ratio

The attributable fraction for the exposed (AF) is (RR - 1) / RR. It estimates what proportion of cases in the exposed group is attributable to the exposure, assuming the association is causal. An RR of 2 gives an AF of 50%, meaning half the cases in the exposed group would not have occurred without the exposure. The odds ratio (OR) uses (a x d) / (b x c) instead of true risks. It is the correct measure for case-control studies. When the outcome is rare (below about 10%) the OR closely approximates the RR, but for common outcomes it diverges, often making the effect appear larger than the RR suggests.

Reading the number responsibly

A relative risk summarizes an association in your data; it does not prove that the exposure causes the outcome. A large ratio applied to a tiny baseline risk can still represent a very small real-world change, while a modest ratio on a common outcome can affect many people. Confounding variables, selection bias, measurement error and ordinary sampling variation can all shift the ratio away from the truth. These calculations are educational estimates: in clinical, epidemiological or public-health settings, decisions about risk and treatment should be made with a qualified professional who can weigh the full study context, the confidence interval, and external evidence.

The 2x2 contingency table layout

GroupEvent (yes)Event (no)TotalRisk
Exposedaba + ba / (a + b)
Unexposedcdc + dc / (c + d)
Totala + cb + dn

Relative risk divides the event rate in the exposed row by the event rate in the unexposed row.

Frequently asked questions

What does a relative risk of 2 mean?

A relative risk of 2 means the exposed group is twice as likely to experience the outcome as the unexposed group, a 100% relative increase in risk. If the unexposed risk is 5%, an RR of 2 corresponds to a 10% risk in the exposed group. Always read the absolute risks too: doubling a very small baseline still leaves the outcome rare.

What is the difference between relative risk and odds ratio?

Relative risk divides the event rate in the exposed group by the event rate in the unexposed group, so it requires true denominators from a cohort study or trial. The odds ratio divides the odds of the event in each group and is the appropriate measure for case-control studies. When the outcome is rare the two measures are close, but for common outcomes the odds ratio diverges from the RR and can be misread as a larger effect. Use RR when you have cohort or trial data; use OR for case-control or logistic-regression output.

Why is the relative risk undefined when the unexposed group has no events?

Relative risk is the exposed risk divided by the unexposed risk. If no one in the unexposed group has the event, that denominator is zero and the ratio is mathematically undefined. Researchers often handle this with a continuity correction, adding 0.5 to each cell. This calculator returns no value in that case to avoid a misleading number.

How is the confidence interval for RR calculated?

The standard log-normal method (Katz et al., 1978) is used. Compute the standard error of the natural log of RR: SE = sqrt(1/a + 1/c - 1/(a+b) - 1/(c+d)). Then the 95% CI is exp(ln(RR) +/- 1.96 x SE). This requires at least one event in each group (a > 0 and c > 0) for the logarithm to be defined.

What is the Number Needed to Treat (NNT) and how is it related to relative risk?

NNT = 1 / |ARR|, where ARR is the absolute risk reduction (or increase). Unlike relative risk, NNT is expressed in the same units as the baseline risk. Two studies can report identical RRs but very different NNTs if their baseline risks differ. For example, an RR of 0.5 applied to a 20% baseline gives ARR = 10%, NNT = 10; the same RR applied to a 2% baseline gives ARR = 1%, NNT = 100.

What does attributable fraction mean?

The attributable fraction for the exposed group is (RR - 1) / RR. It estimates the proportion of cases among exposed people that would not have occurred if the exposure were absent, assuming the association is causal. An RR of 4 gives AF = 75%, meaning three-quarters of the exposed cases are attributed to the exposure. A protective exposure (RR < 1) gives a negative AF, representing the fraction of cases prevented.

Sources

Written by Dr. Hannah Brandt, PhD Statistician · Munich, Germany

Applied statistician translating rigorous probability theory into clear, accurate tools for researchers and practitioners.

Search 3,500+ calculators

Loading search…