Odds Ratio Calculator
Enter the four counts of a 2 × 2 table to get the odds ratio with its confidence interval and p-value. The same table also gives the relative risk, the risk difference, the number needed to treat and Fisher’s exact p, so you can report whichever measure your study design and journal call for.
Odds ratio
95% CI 0.21 to 0.83
The odds of the event in row 1 are 0.41 times the odds in row 2. The interval excludes 1.
- Odds ratio
- 0.412
- 95% CI 0.205 to 0.826
- Relative risk
- 0.500
- 95% CI 0.287 to 0.870
- Risk difference (row 1 − row 2)
- −15.00 points
- 95% CI −26.15 to −3.41
- NNT to benefit
- 6.67
- 95% CI 3.8 to 29.3
- Relative risk reduction
- 50.0%
- 95% CI 13.0% to 71.3%
- Risk in each row
- 15.0% vs 30.0%
- p (log odds ratio, z test)
- 0.0124
- p (Pearson χ²)
- 0.0111
- χ² = 6.452, df 1
- p (Fisher’s exact)
- 0.0171
- The outcome is common (over 10%), so the odds ratio is noticeably further from 1 than the relative risk. Do not describe this odds ratio as a risk ratio.
Report it like this
The risk was 15.0% (15/100) in Treatment and 30.0% (30/100) in Control; OR = 0.41, 95% CI 0.21 to 0.83, p = .012.
How to use the calculator
Set the table up so that the first row is the exposed or treated group and the first column is the outcome you are counting:
| Event | No event | |
|---|---|---|
| Exposed / treatment | a | b |
| Unexposed / control | c | d |
For a case-control study, put cases and controls in the rows and exposed and not exposed in the columns: the odds ratio is the same either way round, which is why it is the measure for case-control designs. Swapping the two rows (or the two columns) turns the odds ratio into its reciprocal.
Odds ratio formula and confidence interval
OR = (a/b) / (c/d) = ad / bc
The confidence interval is calculated on the log scale (Woolf 1955) and then exponentiated:
SE(ln OR) = √(1/a + 1/b + 1/c + 1/d), CI = exp(ln OR ± 1.96 × SE)
The p-value tests whether the log odds ratio differs from 0 (z = ln OR / SE). If any cell is zero, the odds ratio is 0 or infinite, so the calculator adds 0.5 to every cell first (the Haldane–Anscombe correction) and says so.
Relative risk = [a/(a + b)] / [c/(c + d)], with SE(ln RR) = √(1/a − 1/(a + b) + 1/c − 1/(c + d)) (Katz 1978). Risk difference = a/(a + b) − c/(c + d), with the Newcombe score interval. NNT = 1 / |risk difference|; when the interval for the risk difference crosses zero, the NNT interval runs through infinity (Altman 1998).
Worked example
In a trial, 15 of 100 patients on treatment and 30 of 100 on control had the event (the default table).
- Odds of the event: 15/85 = 0.176 with treatment and 30/70 = 0.429 with control.
- OR = (15 × 70) / (85 × 30) = 0.41; SE(ln OR) = √(1/15 + 1/85 + 1/30 + 1/70) = 0.355; 95% CI 0.21 to 0.83; p = .012.
- Relative risk = 0.15 / 0.30 = 0.50 (95% CI 0.29 to 0.87): treatment halves the risk.
- Risk difference = −15.0 percentage points (95% CI −26.1 to −3.4), so NNT = 1/0.15 = 6.7, rounded up to 7 (95% CI 3.8 to 29.3).
- Fisher’s exact p = .017; Pearson χ²(1) = 6.45, p = .011.
In the case-control example, 40 of 100 cases and 20 of 100 controls were exposed: OR = (40 × 80) / (60 × 20) = 2.67, 95% CI 1.42 to 5.02.
Odds ratio or relative risk?
- Case-control studies: report the odds ratio. Risks cannot be estimated because the investigator chose how many cases and controls to include.
- Cohort studies and trials: the relative risk and risk difference are easier to understand. Logistic regression gives odds ratios, so adjusted results are often odds ratios anyway.
- Rare outcomes (under about 10%): the odds ratio and relative risk are close. With common outcomes the odds ratio is further from 1 than the relative risk, and describing it as “times the risk” overstates the effect. The calculator warns you when this happens.
See the relative risk calculator and the NNT calculator for those measures on their own, with their own explanations. To pool odds ratios across studies, use the forest plot maker.
How to report an odds ratio
Give the counts or percentages in each group, the odds ratio to two decimals, its confidence interval and the p-value:
The event occurred in 15 of 100 patients (15.0%) with treatment and 30 of 100 (30.0%) with control (odds ratio 0.41, 95% CI 0.21 to 0.83, p = .012).
Say which group is the reference (the denominator). An odds ratio below 1 means lower odds in the first row; above 1 means higher odds. If the confidence interval includes 1, the association is not statistically significant at that level.
Questions
- How do I calculate an odds ratio?
- Arrange the counts in a 2 × 2 table with the exposed group in the first row and the event in the first column. The odds ratio is (a × d) ÷ (b × c). For 15 events and 85 non-events with treatment against 30 and 70 with control, the odds ratio is (15 × 70) ÷ (85 × 30) = 0.41.
- How do I calculate the 95% confidence interval for an odds ratio?
- Take the natural log of the odds ratio, compute its standard error as √(1/a + 1/b + 1/c + 1/d), add and subtract 1.96 standard errors, and exponentiate both limits. For the example above, ln(0.41) ± 1.96 × 0.355 gives a 95% CI of 0.21 to 0.83.
- What does an odds ratio of 2 mean?
- The odds of the outcome in the exposed group are twice the odds in the unexposed group. It does not mean the risk is doubled unless the outcome is rare; with a common outcome, an odds ratio of 2 corresponds to a smaller increase in risk.
- What is the difference between an odds ratio and a relative risk?
- The relative risk compares probabilities (events divided by everyone in the group); the odds ratio compares odds (events divided by non-events). For rare outcomes they are nearly equal. For common outcomes the odds ratio is further from 1. Case-control studies can only estimate the odds ratio.
- What if one cell of my 2 × 2 table is zero?
- The odds ratio is then 0 or infinite and the usual standard error cannot be computed. The calculator adds 0.5 to every cell (the Haldane–Anscombe correction) to give a finite estimate and interval, and shows Fisher’s exact p-value, which needs no correction.
- Is the odds ratio significant if the confidence interval includes 1?
- No. An odds ratio of 1 means no association, so an interval that includes 1 means the data are compatible with no association at that confidence level, and the p-value will be above the matching significance level (0.05 for a 95% interval).
Sources
- Woolf B. On estimating the relation between blood group and disease. Ann Hum Genet 1955;19(4):251–253. doi:10.1111/j.1469-1809.1955.tb01348.x
- Katz D, Baptista J, Azen SP, Pike MC. Obtaining confidence intervals for the risk ratio in cohort studies. Biometrics 1978;34(3):469–474. doi:10.2307/2530610
- Altman DG. Confidence intervals for the number needed to treat. BMJ 1998;317(7168):1309–1312. doi:10.1136/bmj.317.7168.1309
- Szumilas M. Explaining odds ratios. J Can Acad Child Adolesc Psychiatry 2010;19(3):227–229. PMCID: PMC2938757
- 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(19):1690–1691. doi:10.1001/jama.280.19.1690
Calculations run in your browser; nothing you enter is sent or stored. Results are checked against SciPy and statsmodels in our test suite. Last updated 22 November 2026.