Odds Ratio and Relative Risk Calculator

From a 2×2 table, get the odds ratio, relative risk and risk difference with confidence intervals (log methods), and handle zero cells. Educational use.

Counts of people. Exposed means the group with the risk factor or treatment.
With a zero cell the ratios or their standard errors cannot be calculated directly. The risk difference always uses your original counts.

Results

Odds ratio (OR)
5.2105
OR 95% confidence interval (Woolf)
3.8669 to 7.021
Relative risk (RR, risk ratio)
5.00
RR 95% confidence interval (Katz)
3.7418 to 6.6814
Risk difference (exposed − unexposed)
0.04
Risk difference 95% confidence interval
0.030203 to 0.049797
Risk in the exposed group, a ÷ (a + b)
0.05
Risk in the unexposed group, c ÷ (c + d)
0.01
Does the OR interval include 1?
No: the interval is entirely above 1 (higher odds in the exposed group).

Estimate only. This tool is for informational and educational purposes. Results depend on your inputs and simplifying assumptions, and are not a substitute for professional engineering, design or financial advice. Always verify with a qualified professional and applicable codes before purchasing, building or making decisions.

How it’s calculated

A 2×2 table compares an outcome across two groups. Fill in how many people in the exposed group did (a) and did not (b) have the outcome, and the same for the unexposed group (c and d). This calculator then gives three standard measures of association with confidence intervals.

OutcomeNo outcome
Exposedab
Not exposedcd
risk (exposed) = a ÷ (a + b) risk (unexposed) = c ÷ (c + d) odds ratio OR = (a · d) ÷ (b · c) relative risk RR = [a ÷ (a + b)] ÷ [c ÷ (c + d)] risk difference RD = a ÷ (a + b) − c ÷ (c + d) Woolf CI for OR: exp( ln OR ± z · √(1/a + 1/b + 1/c + 1/d) ) Katz CI for RR: exp( ln RR ± z · √(1/a − 1/(a+b) + 1/c − 1/(c+d)) ) RD CI: RD ± z · √( r₁(1−r₁)/n₁ + r₀(1−r₀)/n₀ ), kept within −1 to 1

Here z is 1.96 for 95% confidence (1.645 for 90%, 2.576 for 99%). The intervals are built on the log scale and then converted back, which is why they are not symmetric around the estimate.

Worked example (CDC, Principles of Epidemiology, Lesson 3): a = 100, b = 1,900, c = 80, d = 7,920. The risk in the exposed is 100 ÷ 2,000 = 0.05 and in the unexposed 80 ÷ 8,000 = 0.01, so RR = 5.0 and RD = 0.04. OR = (100 × 7,920) ÷ (1,900 × 80) = 792,000 ÷ 152,000 = 5.2. For the 95% intervals, SE(ln OR) = √(0.01 + 0.000526 + 0.0125 + 0.000126) = 0.1522, giving 3.87 to 7.02, and SE(ln RR) = √(0.01 − 0.0005 + 0.0125 − 0.000125) = 0.1479, giving 3.74 to 6.68.

When the outcome is rare, the OR is close to the RR. When it is common, the OR is farther from 1 than the RR. Case-control studies can only estimate the OR, not the risks. A zero cell makes the OR or RR 0 or undefined, so you can add 0.5 to each cell (the Haldane-Anscombe correction); the results are then approximate.

These are statistical associations in the data you enter. They do not show cause and effect, and this page is for learning, not for medical decisions.

Frequently asked questions

What is the difference between odds ratio and relative risk?

Relative risk compares probabilities (risk in the exposed ÷ risk in the unexposed). The odds ratio compares odds. They are similar when the outcome is rare, but the OR exaggerates the effect when the outcome is common.

How do I read the confidence interval?

If the interval for an OR or RR includes 1, the data are consistent with no association at that confidence level. For a risk difference, check whether the interval includes 0.

Which cell is which?

Rows are the exposure (exposed, unexposed) and columns are the outcome (yes, no). Swapping rows or columns changes the ratios, usually to their reciprocals, so decide which group is your reference before entering the data.

What do I do if a cell is zero?

The ratio may be 0 or undefined and the standard errors blow up. This calculator can add 0.5 to every cell (the Haldane-Anscombe correction) and labels the result as corrected. With very small counts, an exact method is better.

Embed this calculator

Add this free calculator to your own website. Copy the code below into your page’s HTML:

Need this calculator branded, changed or built around your own prices?See custom business solutions →

Sources

Formulas are taken from the free public references above. Results are provided “as is” for informational and educational purposes only. See our disclaimer.

Added · Last updated · How we check our calculators

Spotted a mistake or missing option? Report a problem· Suggest a calculator