Odds Ratio and Relative Risk Calculator
Calculate the odds ratio, relative risk, risk difference and number needed to treat from a 2 × 2 table, with 95% confidence intervals.
Statistical results depend on the assumptions stated in the formula. Check that your data meet them before drawing conclusions.
How to use this calculator
Enter the four counts of a 2 × 2 table: people exposed to a factor (or given a treatment) with and without the outcome, and people not exposed with and without it. The calculator gives the odds ratio (used in case-control studies), the relative risk (used in cohort studies and trials), the risk difference and the number needed to treat or harm.
Formula
With a = exposed cases, b = exposed non-cases, c = unexposed cases, d = unexposed non-cases: odds ratio = (a × d) ÷ (b × c); relative risk = [a ÷ (a + b)] ÷ [c ÷ (c + d)]. Confidence intervals: exp(ln OR ± z√(1/a + 1/b + 1/c + 1/d)) and exp(ln RR ± z√(1/a − 1/(a + b) + 1/c − 1/(c + d))). NNT = 1 ÷ |risk difference|. If any cell is 0, 0.5 is added to every cell.
Calculator credits
Calculator developmentJulia Edwards
Editorial supervisionSamad Aslam Khan
Expert reviewSaeedM.Phil Statistics, Data Scientist
Published byThe Calculatorz
Last updated
Read how we research, test, review and correct our calculators in our editorial policy.
Frequently asked questions
What is the difference between odds ratio and relative risk?
Relative risk compares probabilities; the odds ratio compares odds. They are similar when the outcome is rare (under about 10%), but the odds ratio is further from 1 when the outcome is common.
When do I use the odds ratio?
In case-control studies, where risks cannot be calculated directly, and in logistic regression.
What does a relative risk of 2 mean?
The exposed group is twice as likely to have the outcome as the unexposed group.
What if the confidence interval includes 1?
The data are consistent with no association at that confidence level.
What is the number needed to treat?
How many people must receive a treatment for one extra person to benefit (or, for a harmful exposure, the number needed to harm).
Why add 0.5 to empty cells?
A zero count makes the ratios undefined or infinite. The Haldane–Anscombe correction adds 0.5 to every cell so an estimate can be made.
References & methodology sources
These sources support the calculator’s formula, definitions, thresholds, units or result interpretation.
- Szumilas, M. (2010). Explaining odds ratios. Journal of the Canadian Academy of Child and Adolescent Psychiatry, 19(3), 227–229. View source
- Illowsky, B., & Dean, S. (2023). Introductory statistics 2e. OpenStax. View source
- Agresti, A., & Coull, B. A. (1998). Approximate is better than 'exact' for interval estimation of binomial proportions. The American Statistician, 52(2), 119–126. View source
- Croarkin, C., & Tobias, P. (Eds.). (2012). NIST/SEMATECH e-handbook of statistical methods. National Institute of Standards and Technology. View source