Odds ratio calculator

This odds ratio calculator measures the association between an exposure and an outcome from a 2 × 2 table. Enter the four counts to get the odds ratio and the relative risk with 95% confidence intervals, the risk difference and the number needed to treat or harm.

Your numbers are calculated in your browser and are not sent or stored.

Odds ratio calculatorOr describe it in Studio →
Outcome: yesOutcome: no
Exposed / treated
Unexposed / control

Enter counts of people, not percentages. For a case-control study only the odds ratio is meaningful; ignore the risk-based rows.

Odds ratio

2.25

95% CI 0.99 to 5.09
z = 1.95, p = 0.0516

Relative risk

2.00

95% CI 0.99 to 4.05
p = 0.0545

The confidence interval of the odds ratio includes 1: the data are compatible with no association.

Risk, exposed
20.0%
Risk, unexposed
10.0%
Risk difference
10.0% (95% CI 0.2% to 19.8%)
Number needed to harm
10

To report

OR = 2.25 (95% CI 0.99–5.09, p = 0.0516); RR = 2.00 (95% CI 0.99–4.05)

Check your result: with a common outcome the odds ratio should be further from 1 than the relative risk (2.25 against 2.00 in the example), and the p value should be below 0.05 exactly when the 95% CI excludes 1. Here the CI of 0.99 to 5.09 just includes 1 and p = 0.052.
odds ratio in the worked example
2.25
odds ratio in the worked example
its 95% confidence interval
0.99 to 5.09
its 95% confidence interval
its p value
0.052
its p value
added to every cell when one is zero
0.5
added to every cell when one is zero
  • Odds ratio and relative risk
  • 95% confidence intervals and p values
  • Risk difference and NNT
  • Handles zero cells
  • Runs in your browser, free

01

How to calculate an odds ratio

Outcome: yesOutcome: no
Exposed / treatedab
Unexposed / controlcd

odds ratio = (a × d) ÷ (b × c)
relative risk = [a ÷ (a + b)] ÷ [c ÷ (c + d)]
risk difference = a ÷ (a + b) − c ÷ (c + d), NNT = 1 ÷ |risk difference|

abcdoutcome: yesoutcome: nogroup 1group 2risk in group 1 = a ÷ (a + b)
The four cells of a 2 × 2 table. Rows are the two groups you compare; columns are the two outcomes. Every measure on this page is a way of combining a, b, c and d. Check which way round your table is before reading the result: swapping rows or columns inverts ratios.

02

Worked example

Of 100 exposed people 20 develop the outcome; of 100 unexposed people 10 do.

MeasureCalculationResult95% CI
Odds ratio(20 × 90) ÷ (80 × 10)2.250.99 to 5.09
Relative risk0.20 ÷ 0.102.000.99 to 4.05
Risk difference0.20 − 0.1010.0%0.2% to 19.8%
Number needed to harm1 ÷ 0.1010

Both ratio intervals just include 1, so this difference falls short of significance at the 5% level even though the risk doubled.

03

Confidence intervals

SE(ln OR) = √(1/a + 1/b + 1/c + 1/d)
SE(ln RR) = √(1/a − 1/(a + b) + 1/c − 1/(c + d))
95% CI = exp( ln(ratio) ± 1.96 × SE )

The intervals are computed on the log scale, which is why they are not symmetric around the ratio. The p value comes from the same standard error: z = ln(ratio) ÷ SE, read against the normal distribution. In the example z = 1.95 and p = 0.052 for the odds ratio. An interval that excludes 1 means the association is statistically significant at the 5% level.

04

Odds ratio or relative risk?

  • Cohort studies and trials follow groups forward, so risks are known: report the relative risk and the risk difference.
  • Case-control studies fix the number of cases and controls, so risks cannot be estimated: only the odds ratio is valid.
  • When the outcome is rare (under about 10%), the odds ratio is close to the relative risk. When it is common, the odds ratio is further from 1 than the relative risk: in the example, 2.25 against 2.00.

05

Zero cells and small counts

A zero in the table makes a ratio zero or infinite. The calculator then adds 0.5 to every cell (the Haldane–Anscombe correction) and says so. With counts that small the normal approximation behind the interval is weak; use the Fisher’s exact test calculator for the p value. For larger tables, see the chi-square calculator.

06

Common mistakes with odds ratios

  • Reading an odds ratio as a relative risk when the outcome is common. With 50 of 100 exposed and 25 of 100 unexposed, the odds ratio is 3.0 but the risk only doubles (relative risk 2.0).
  • A symmetric interval on the ratio scale. 2.25 ± 1.96 × SE of the ratio gives 0.41 to 4.09; the correct interval, computed on the log scale, is 0.99 to 5.09.
  • Swapping the rows without saying so. Putting the unexposed group first gives 1 ÷ 2.25 = 0.444, the same association read the other way round.
  • Ignoring a zero cell. With 0 of 100 exposed and 10 of 100 unexposed the raw odds ratio is 0; the calculator adds 0.5 to every cell and reports 0.043, and Fisher’s exact test should give the p value.

Trust

How this page is checked

  • The calculation runs on code with automated tests against worked reference values. Every number in the examples on this page was produced by that same code, not typed by hand.
  • The formulas and conventions used are stated on the page, so you can reproduce the result yourself or compare it with your own software.
  • Last reviewed by the Sciloom team, Zebra Nine Studio Inc. It is a tool for research and teaching, not a substitute for a statistician, a validated lab method or medical advice.

Cite this page

Sciloom. (2026). Odds ratio calculator. Zebra Nine Studio Inc. https://sciloom.si/odds-ratio-calculator

Read the full methodology · Who makes Sciloom

Frequently asked questions

What does an odds ratio of 2 mean?

The odds of the outcome are twice as high in the exposed group as in the unexposed group. It does not mean the risk is doubled unless the outcome is rare.

What does it mean if the confidence interval includes 1?

A ratio of 1 means no association. If the 95% interval includes 1, the result is not statistically significant at the 5% level.

What is the difference between odds ratio and relative risk?

Relative risk compares probabilities (20% vs 10% is 2.0). The odds ratio compares odds (0.25 vs 0.111 is 2.25). They agree closely only for rare outcomes.

What is the number needed to treat?

One divided by the absolute risk difference: the number of people who must receive the treatment for one extra person to benefit (or, for a harmful exposure, to be harmed).

Small counts? Fisher’s exact test gives an exact p value for the same table.
Free to start, no sign-up.
Back to the tool ↑

More research tools