Odds ratio calculator: enter a 2×2 table to get the odds ratio with its 95% confidence interval and P value, and the risk ratio alongside it for trials and cohorts. Below the calculator: the odds ratio formula, how to interpret an odds ratio, and a worked example from the Magpie trial.
Results
EvidencePulse
Check the evidence behind your numbers
Ask EvidencePulse what the trials show. It answers from the published evidence, with references you can open.
Your question
Opens EvidencePulse with this question filled in.
What is an odds ratio?
Odds compare the chance that something happens with the chance that it doesn't: odds = p ÷ (1 − p). A probability of 20% is odds of 0.25, or 1 to 4. A probability of 50% is odds of 1.
The odds ratio (OR) divides the odds of an outcome in one group by the odds in another, usually the exposed or treated group over the unexposed or control group.
- OR = 1: the odds are the same in both groups.
- OR above 1: the outcome has higher odds with the exposure.
- OR below 1: the outcome has lower odds with the exposure.
Odds ratios are the natural measure of case-control studies and of logistic regression, and many meta-analyses of binary outcomes pool them.
The odds ratio formula
Put the counts in a 2×2 table, with the outcome in the columns:
| Outcome | No outcome | |
|---|---|---|
| Exposed | a | b |
| Not exposed | c | d |
The odds of the outcome are a ÷ b in the exposed row and c ÷ d in the unexposed row, so:
OR = (a ÷ b) ÷ (c ÷ d) = (a × d) ÷ (b × c)
Confidence interval (Woolf's method). Work on the log scale. The standard error of ln(OR) is √(1/a + 1/b + 1/c + 1/d), and the 95% interval is exp(ln OR − 1.96 × SE) to exp(ln OR + 1.96 × SE). For a 90% or 99% interval, replace 1.96 with 1.645 or 2.576.
Zero cells. When a cell is zero, the calculator adds 0.5 to every cell (the Haldane-Anscombe correction) and says so. With small counts, it also reports Fisher's exact P value.
Worked example: magnesium sulfate in the Magpie trial
The Magpie trial randomized 10,141 women with pre-eclampsia in 33 countries to magnesium sulfate or placebo. Eclampsia occurred in 40 of about 5,055 women given magnesium and 96 of about 5,055 given placebo.
| Eclampsia | No eclampsia | |
|---|---|---|
| Magnesium sulfate | 40 | 5,015 |
| Placebo | 96 | 4,959 |
- OR = (40 × 4,959) ÷ (5,015 × 96) = 198,360 ÷ 481,440 = 0.41 (95% CI 0.28 to 0.60).
- The risk ratio is 0.79% ÷ 1.90% = 0.42 (95% CI 0.29 to 0.60), the published 58% lower risk.
The two measures agree because eclampsia was rare: under 2% even with placebo.
A common outcome is different. In the same trial, side effects (most often flushing) were reported by 1,201 of 4,999 women given magnesium (24.0%) and 228 of 4,993 given placebo (4.6%):
- the risk ratio is 24.0% ÷ 4.6% = 5.3;
- the odds ratio is (1,201 ÷ 3,798) ÷ (228 ÷ 4,765) = 6.6.
Reporting the odds ratio as "6.6 times the risk" would overstate the effect by about a quarter. The calculator's "OR to RR" tab converts one into the other: an odds ratio of 6.6 with a 4.6% risk in the comparison group is a risk ratio of 5.3.
Our summary of the trial: The Magpie trial: Magnesium lowers eclampsia risk.
Reading an odds ratio from a case-control study
A nested case-control study we covered compared 2,303 people who had an opioid overdose with 9,212 matched controls. A prior opioid prescription to a family member was linked to overdose: adjusted OR 2.89 (95% CI 2.59 to 3.23).
Overdose is rare, so this odds ratio is close to a risk ratio: about 2.9 times the risk. The study design couldn't give that risk directly (our summary).
How to interpret an odds ratio
- Say "odds". An odds ratio of 2 means the odds are doubled. It means "twice as likely" only when the outcome is rare.
- Check how common the outcome is. - Below about 10% in the comparison group, the odds ratio and the risk ratio are close. - Above that, the odds ratio sits further from 1 than the risk ratio. - To convert, use RR = OR ÷ (1 − p₀ + p₀ × OR), where p₀ is the risk in the comparison group.
- Read the interval, not just the estimate. An interval that includes 1 means the data are compatible with no association at that confidence level.
- Know whether it is adjusted. An odds ratio from logistic regression is adjusted for the other variables in the model. A crude odds ratio from a 2×2 table isn't.
Odds ratio or relative risk?
- Case-control study: use the odds ratio. The researchers chose how many cases and controls to study, so the risk of the outcome can't be estimated. The odds ratio can, and it has the same value whether you compare the odds of exposure or the odds of disease.
- Trial or cohort: report the risk ratio and the absolute difference. They are easier to read, and the number needed to treat follows from the absolute difference.
Common mistakes
- Calling an odds ratio a risk ratio. With a common outcome it exaggerates the effect, as the side-effect example shows.
- Putting the table the wrong way round. a must be "exposed with the outcome" and d "unexposed without it". Swapping the rows turns OR into 1 ÷ OR.
- Quoting a ratio without the baseline. An odds ratio of 2 for an outcome that affects 1 in 10,000 people is a tiny absolute change. Use the relative risk tool for absolute differences.
- Ignoring zero cells. With a zero in the table, the odds ratio is 0 or infinite. Use a correction or an exact method, and say which.
- Comparing odds ratios across models. Adding a strong predictor to a model changes the odds ratio even when there is no confounding (non-collapsibility). Adjusted and crude odds ratios, or odds ratios from different models, aren't directly comparable.
References
- Bland JM, Altman DG. Statistics notes: the odds ratio. BMJ. 2000;320:1468.
- Woolf B. On estimating the relation between blood group and disease. Ann Hum Genet. 1955;19:251-3.
- Zhang J, Yu KF. What's the relative risk? A method of correcting the odds ratio in cohort studies of common outcomes. JAMA. 1998;280:1690-1.
- Magpie Trial Collaborative Group. Do women with pre-eclampsia, and their babies, benefit from magnesium sulphate? The Magpie Trial: a randomised placebo-controlled trial. Lancet. 2002;359:1877-90.
- Khan NF, Bateman BT, Landon JE, Gagne JJ. Association of opioid overdose with opioid prescriptions to family members. JAMA Intern Med. 2019;179:1186-92.
- Cummings P. The relative merits of risk ratios and odds ratios. Arch Pediatr Adolesc Med. 2009;163:438-45.
Check a health claim with HypeCheck
Saw a headline promising a 50% lower risk? Paste the article or the claim, and HypeCheck rates it against the study behind it.
Check a claimThe 2MM Daily Brief
Free every weekday: the most important new studies, summarized by physicians in two minutes each.
Your subscription opens securely in a new tab.
Questions and answers
What is an odds ratio?
An odds ratio compares the odds of an outcome in two groups: the odds in the exposed or treated group divided by the odds in the comparison group. An odds ratio of 1 means no difference, above 1 means higher odds with the exposure, and below 1 means lower odds.
What is the formula for the odds ratio?
With a 2×2 table of a and b (exposed, with and without the outcome) and c and d (unexposed, with and without), the odds ratio is (a × d) ÷ (b × c). Its 95% confidence interval is exp(ln OR ± 1.96 × √(1/a + 1/b + 1/c + 1/d)).
How do I interpret an odds ratio of 2 or of 0.5?
An odds ratio of 2 means the odds of the outcome are twice as high in the exposed group. An odds ratio of 0.5 means they are half as high, 50% lower odds. Both read as "twice" or "half the risk" only when the outcome is rare.
What is the difference between an odds ratio and a relative risk?
A relative risk divides two probabilities, and an odds ratio divides two odds. When the outcome is rare they are almost equal. When it is common, the odds ratio is further from 1. Case-control studies can give only the odds ratio.
When does the odds ratio approximate the relative risk?
When the outcome is rare in the comparison group, roughly under 10%. In the Magpie trial eclampsia affected 1.9% with placebo, and the odds ratio of 0.41 was close to the risk ratio of 0.42.
What does it mean if the confidence interval for an odds ratio includes 1?
The data are compatible with no association at that confidence level. For a 95% interval, it usually goes with a two-sided P value above 0.05.
Can an odds ratio be negative?
No. An odds ratio runs from 0 to infinity. Its logarithm, used for the confidence interval and in meta-analysis, can be negative.
How do I calculate an odds ratio for a case-control study?
Count exposed and unexposed people among the cases and among the controls. Cases go in the "outcome" column and controls in the "no outcome" column. The odds ratio is (exposed cases × unexposed controls) ÷ (unexposed cases × exposed controls). Choose "Case-control" in the calculator to label the table that way.
For education and research. These calculators do not give medical advice; check results against the original paper before relying on them.






