Toolvito

Works on this device

Odds Ratio Calculator

Find the odds ratio of two groups from a 2×2 table, with its confidence interval and the working. You can also turn a logistic regression coefficient into an odds ratio, or combine several strata into one adjusted odds ratio. This page is for learning and for checking arithmetic. It is not medical advice.

Enter your values

Type the four cells of the table, or the people with the outcome and the size of each group. You get the odds ratio, its interval by Woolf’s method and the other risk measures of the same table.

Your values

Choose the second way when you know how many people were in each group and how many of them had the outcome.

People in group 1 with the outcome. In a case-control study: the exposed cases.

In a case-control study: the exposed controls.

People in group 2 with the outcome. In a case-control study: the cases that were not exposed.

In a case-control study: the controls that were not exposed.

The level of the interval. 95% is the most common.

Off by default. Without it a ratio with a 0 in the table is 0 or infinite, and no interval can be worked out.

Your values are worked out in this browser. They are not sent to a server.

Your result will show here

Fill in the values, then choose Calculate.

How to use this calculator

  1. Choose Odds ratio from a 2×2 table, the mode for a regression coefficient, or the mode for strata.
  2. For a table, type the four cells: group 1 (exposed or treated) with and without the outcome, and group 2 (not exposed or control) with and without it. You can type the people with the outcome and the size of each group instead.
  3. Choose the confidence level. Tick the 0.5 correction only if a cell is 0 and you want an interval.
  4. Choose Calculate. You get the odds ratio, the lower and upper limits, the working, and the same table in the other risk measures.

The formulas

  • Odds of a group = people with the outcome ÷ people without it.
  • Odds ratio = odds in group 1 ÷ odds in group 2 = (a × d) ÷ (b × c).
  • Woolf (log) interval: exp(ln OR ± z × SE), with SE = √(1/a + 1/b + 1/c + 1/d). z is 1.96 for 95%, 1.645 for 90% and 2.576 for 99%.
  • Haldane–Anscombe correction (an option, off by default): when a cell is 0, add 0.5 to all four cells before working out the odds ratio and its interval.
  • From a logistic regression coefficient β: odds ratio = exp(β), interval exp(β ± z × SE).
  • Mantel–Haenszel odds ratio over strata = Σ(a × d ÷ n) ÷ Σ(b × c ÷ n). Its interval uses the variance of Robins, Breslow and Greenland (1986).

Worked example

Group 1: 30 people with the outcome and 270 without. Group 2: 60 with and 240 without. The odds are 30 ÷ 270 = 0.1111 and 60 ÷ 240 = 0.25.

Odds ratio = (30 × 240) ÷ (270 × 60) = 7,200 ÷ 16,200 = 0.4444. SE = √(1/30 + 1/270 + 1/60 + 1/240) = 0.2406. The 95% interval is exp(−0.8109 ± 1.96 × 0.2406) = 0.2774 to 0.7122. The whole interval is below 1, so at this level the odds of the outcome are lower in group 1.

Odds ratio or risk ratio?

The odds ratio compares odds, and the risk ratio compares risks (the share of a group with the outcome). In the example the risks are 10% and 20%, so the risk ratio is 0.5, while the odds ratio is 0.4444. When the outcome is rare in both groups the two are close. When it is common, the odds ratio is further from 1 than the risk ratio.

In a case-control study the people were chosen because they had the outcome or not. There only the odds ratio has a meaning; risks cannot be read from the table.

Other measures from the same table

The result shows the same table in each measure. Each one has its own calculator with more detail, and they all give the same numbers for the same table: the Relative Risk Calculator, the Absolute Risk Reduction Calculator, the Relative Risk Reduction Calculator and the Number Needed to Treat Calculator.

Limits you should know

  • The Woolf interval is an approximation for large samples. For small tables an exact (Fisher) interval can be different. This tool does not give exact intervals.
  • The tool does not fit a logistic regression. It turns a coefficient that your statistics program printed into an odds ratio.
  • The Mantel–Haenszel odds ratio adjusts for one grouping variable only. The tool does not test whether the strata differ (the Breslow–Day test).
  • An odds ratio describes an association in the data. It does not show that the exposure caused the outcome.
  • This page is for learning and for checking arithmetic. It is not medical advice. Talk about results that concern your own health or treatment with a clinician.

Related tools