Health & Fitness
Relative Risk and Odds Ratio Calculator (2×2 Table with 95% CI)
Epidemiology and clinical research often compare how often an outcome occurs in two groups, such as people who smoke and people who do not, or patients who receive a treatment and those who receive a placebo. The data fit naturally into a two-by-two table: the number of exposed people with and without the outcome, and the number of unexposed people with and without it. From such a table, three standard measures of association can be calculated. The relative risk, or risk ratio, is the risk of the outcome in the exposed group divided by the risk in the unexposed group; a value of 2 means the exposed are twice as likely to experience the outcome. The odds ratio compares the odds of the outcome rather than the risk, and it is the natural measure in case-control studies, where participants are chosen because they do or do not have the outcome, so risks cannot be calculated directly. When the outcome is rare, the odds ratio is close to the relative risk. The risk difference is the absolute difference in risk, which matters for public health and individual decisions. This calculator computes all three, together with 95 percent confidence intervals for the relative risk and odds ratio using the standard log methods. With 20 of 100 exposed and 10 of 100 unexposed people having the outcome, the relative risk is 2.0, with a 95 percent confidence interval from about 0.99 to 4.06, the odds ratio is 2.25, with an interval from about 0.99 to 5.09, and the risk difference is 10 percentage points. Both intervals include 1, so although the point estimates suggest doubled risk, the data are also compatible with no difference at the 95 percent level.
How to use this calculator
- Enter the number of exposed people with the outcome.
- Enter the number of exposed people without it.
- Enter the same two counts for the unexposed group.
- Read the relative risk, odds ratio and risk difference.
- Check whether the confidence intervals include 1.
Interpreting measures of association
A relative risk or odds ratio above 1 indicates higher risk or odds in the exposed group, below 1 lower risk, and exactly 1 no association. The confidence interval shows the precision of the estimate; wide intervals reflect small numbers of events. An interval that excludes 1 corresponds to statistical significance at the 5 percent level.
Association does not prove causation. Confounding factors, bias in how participants were selected or measured, and chance can all produce associations. Randomised trials, careful study design and adjustment for confounders in analysis help address these issues.
Small numbers and zero cells
The log-based confidence intervals used here are approximations that work well when each cell has a reasonable number of observations. When counts are very small, exact methods give more reliable intervals.
If any cell is zero, the formulas break down. Statisticians sometimes add 0.5 to every cell, a continuity correction, or use exact or other methods; the calculator asks for counts greater than zero.
Formula & method
Risk in exposed = a ÷ (a + b); risk in unexposed = c ÷ (c + d)Relative risk RR = risk exposed ÷ risk unexposed; odds ratio OR = (a × d) ÷ (b × c)95% CI: exp(ln RR ± 1.96 × √(1/a − 1/(a+b) + 1/c − 1/(c+d)))95% CI for OR: exp(ln OR ± 1.96 × √(1/a + 1/b + 1/c + 1/d))Risk₁ = a/(a+b); risk₀ = c/(c+d). RR = risk₁/risk₀; OR = ad/bc. 95% CI = exp(ln estimate ± 1.96 × SE), SE(ln RR) = √(1/a − 1/(a+b) + 1/c − 1/(c+d)), SE(ln OR) = √(1/a + 1/b + 1/c + 1/d).
Worked example
A cohort comparison
- Risk exposed = 20/100 = 20%; risk unexposed = 10/100 = 10%.
- RR = 2.0; SE(ln RR) = √0.13 = 0.3606; 95% CI = 0.987 to 4.055.
- OR = (20 × 90)/(80 × 10) = 2.25; 95% CI = 0.994 to 5.092.
Answer: The exposed group has twice the risk, but the interval includes 1.
Frequently asked questions
What is relative risk?
The risk of an outcome in the exposed group divided by the risk in the unexposed group.
What is an odds ratio?
The ratio of the odds of the outcome in two groups; used in case-control studies.
When are RR and OR similar?
When the outcome is rare, typically under about 10%.
What does a CI including 1 mean?
The data are compatible with no difference at the 95% level.
What is the risk difference?
The absolute difference between the two risks, in percentage points.
Can I use this for a case-control study?
Use the odds ratio; relative risk is not valid when groups are selected by outcome.