Odds Ratio Calculator

Enter a 2 × 2 table to get the odds ratio, relative risk, risk difference and NNT with 95% CIs.

For a 2 × 2 table with a and b events and non-events in the exposed group and c and d in the unexposed group, the odds ratio is OR = ad / bc and the relative risk is RR = [a/(a + b)] / [c/(c + d)]. Their 95% CIs are calculated on the log scale. The number needed to treat is 1 divided by the absolute risk difference.

Free, runs in your browser. Nothing you enter is uploaded.

Formula

OR = ad / bc,  SE ln OR = √(1/a + 1/b + 1/c + 1/d);   RR = [a/(a+b)] / [c/(c+d)],  SE ln RR = √(1/a − 1/(a+b) + 1/c − 1/(c+d));   NNT = 1 / |p₁ − p₂|

The OR interval uses Woolf's log method, the RR interval uses the Katz log method and the risk difference uses the Wald interval. When any cell is 0, 0.5 is added to every cell for the OR and RR (Haldane-Anscombe correction) and the result says so. The NNT interval is the inverse of the risk difference interval; when that interval crosses zero it runs from NNT (benefit) through infinity to NNH (harm), as Altman recommends.

Questions

How do you calculate an odds ratio from a 2 × 2 table?

Multiply the diagonal cells and divide: OR = (a × d) / (b × c), where a is exposed with the outcome, b exposed without, c unexposed with and d unexposed without. An OR of 1 means no association.

What is the difference between odds ratio and relative risk?

Relative risk compares probabilities, odds ratio compares odds. They are close when the outcome is rare (under about 10%) but the OR moves further from 1 as the outcome becomes common. Case-control studies can only estimate the OR; cohort studies and trials can report both.

How do I interpret a 95% confidence interval for an odds ratio?

If the interval excludes 1, the association is statistically significant at the 5% level. An OR of 2.5 (95% CI 1.2 to 5.1) means the odds of the outcome are about 2.5 times higher in the exposed group, with plausible values from 1.2 to 5.1.

How do you calculate the number needed to treat?

NNT = 1 / absolute risk reduction. If 28% of controls and 12% of treated patients have the event, the risk difference is 16 percentage points and NNT = 1 / 0.16 = 6.25, which is rounded up to 7.

What happens when a cell is zero?

The odds ratio and relative risk are undefined, so the calculator adds 0.5 to every cell before computing them (the Haldane-Anscombe correction) and states this under the results. Fisher's exact p-value uses the original counts.

References

More Statistics

All free tools · By Dr. Zubair Khalid, DVM, MS, PhD.