Home › Statistics & Probability Calculators › Odds Ratio Calculator (2×2 Table, 95% CI)
Odds Ratio and Relative Risk Calculator
Enter the four cells of a 2×2 table (exposed or treated in the first row, unexposed or control in the second; outcome yes in the first column) and this odds ratio calculator returns the odds ratio with its confidence interval, the relative risk with its interval, the risk difference and the number needed to treat or harm.
The odds ratio is (a × d) ÷ (b × c). Its confidence interval is computed on the log scale with the Woolf standard error √(1/a + 1/b + 1/c + 1/d) and then back-transformed, which is why it is not symmetric around the estimate. An interval that excludes 1 means a significant association at that level. The relative risk compares the proportions with the outcome directly, [a/(a + b)] ÷ [c/(c + d)], with a Katz log-scale interval.
Odds ratios are the natural measure for case-control studies and logistic regression; relative risks are easier to explain for cohort studies and trials. When the outcome is rare the two are close. If any cell is zero, 0.5 is added to every cell for the odds ratio (the Haldane-Anscombe correction). For small tables, also check significance with Fisher’s exact test.
Result and step-by-step solution
95% CI 0.9943 to 5.0915; relative risk = 2 (0.9866 to 4.0545).
| Outcome yes | Outcome no | Total | Risk | |
|---|---|---|---|---|
| Exposed | 20 | 80 | 100 | 0.2 |
| Unexposed | 10 | 90 | 100 | 0.1 |
- Odds ratioOR = (a × d) ÷ (b × c) = 2.25
- Standard error of ln(OR)SE = √(1/a + 1/b + 1/c + 1/d) = 0.41667; ln(OR) = 0.81093
- Confidence interval (Woolf)exp(ln OR ± z × SE) = 0.9943 to 5.0915
- Test of OR = 1z = ln(OR) ÷ SE = 1.9462, p = 0.0516 (not significant at 0.05)
- Relative riskRR = [a/(a + b)] ÷ [c/(c + d)] = 0.2 ÷ 0.1 = 2; CI (Katz log method) 0.9866 to 4.0545
| Risk difference | 0.1 |
|---|---|
| Number needed to treat / harm | 10 |
Frequently asked questions
- How do you calculate an odds ratio?
- From a 2×2 table with cells a, b (exposed) and c, d (unexposed): OR = (a × d) ÷ (b × c). With 20/80 and 10/90, OR = (20 × 90) ÷ (80 × 10) = 2.25.
- 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 twice as high unless the outcome is rare.
- What is the difference between odds ratio and relative risk?
- Relative risk compares probabilities (risks); the odds ratio compares odds, p ÷ (1 − p). The OR is always further from 1 than the RR.
- How do I know if an odds ratio is significant?
- If its 95% confidence interval does not include 1, it is significant at the 5% level. The z-test p-value shown gives the same answer.
Last reviewed: October 7, 2026. Calculations run in your browser and were validated against SciPy.
