Odds Ratio Calculator

Enter the four counts of a 2x2 table: exposed and unexposed groups, each split into those with and without the outcome. You get the odds ratio, its 95% confidence interval and a p-value.

Updated

Embed this calculator

Paste this code into your page. The calculator runs inside the frame and links back to the full version.

Keep the credit link in place. Do not resell the calculator.

Formula

  • Odds ratio: OR = (a x d) / (b x c)
  • Standard error: SE = sqrt(1/a + 1/b + 1/c + 1/d) on the log scale
  • 95% CI: exp(ln(OR) +/- 1.959964 x SE)
  • z and p: z = ln(OR) / SE, p = 2 x (1 - Phi(|z|))
  • Zero cells: add 0.5 to every cell (Haldane-Anscombe)

Worked example

Table a=20, b=80, c=10, d=90. OR = (20 x 90) / (80 x 10) = 2.25. SE = sqrt(1/20 + 1/80 + 1/10 + 1/90) = 0.4167. The 95% CI is 0.9943 to 5.0915, z = 1.9462 and p = 0.0516, so just short of significance at 5%.

Frequently asked questions

How do you calculate an odds ratio?

Divide the odds of the outcome in the exposed group, a/b, by the odds in the unexposed group, c/d, which simplifies to (a x d) / (b x c). For 20, 80 / 10, 90 that is (20 x 90) / (80 x 10) = 2.25.

How is the 95% confidence interval found?

The log method works on ln(OR) with standard error sqrt(1/a + 1/b + 1/c + 1/d), then exponentiates ln(OR) +/- 1.96 x SE. For 20, 80 / 10, 90 SE = 0.4167, giving 0.9943 to 5.0915. Because the interval includes 1, the result is not significant at 5%.

What does an odds ratio of 1, above 1 or below 1 mean?

An odds ratio of 1 means equal odds in both groups. Above 1 means higher odds of the outcome in the exposed group, below 1 lower odds. 30, 10 / 10, 30 gives 9, so the exposed odds are nine times higher.

What if one of the cells is zero?

A zero cell makes the odds ratio zero or undefined, so the Haldane-Anscombe correction adds 0.5 to every cell before calculating. The result says when this was applied. A whole row or column of zeros cannot be analysed.