Home / Science / Health and medicine / Epidemiology / Odds ratio and risk ratio calculatorTool #466

Odds ratio and relative risk calculator with 95 % CI, Fisher exact, Mantel-Haenszel and Breslow-Day

Odds ratio and risk ratio from a 2 × 2 table with Woolf, exact and mid-p intervals, chi-square and Fisher exact tests, or several strata pooled by Mantel-Haenszel with the Breslow-Day test and a forest plot. Case-control or cohort.

Keep it one tap away for everyday use.

Bookmark Odds ratio and risk ratio calculator?

Press Ctrl + D now. Your browser opens its own bookmark box, where you choose the name and folder.

  1. 2×2 tables
  2. OR and RR
  3. Forest plot
Nothing is uploadedWorks offline once open

Your study

For study and teaching, not medical advice. Check with a qualified professional.

CasesControls
Exposed
Unexposed

Example numbers are made up.

What it does

The odds ratio (OR) and the risk ratio (RR, also called relative risk) say how strongly an exposure is linked to a disease or outcome. This calculator works them out from a 2 × 2 table, with every interval and test that epidemiology courses and journals ask for, and it can pool several tables, for example one per age group, by the Mantel-Haenszel method to remove confounding.

For one table it gives:

  • the odds ratio with Woolf’s log interval, the exact conditional interval and the mid-p interval;
  • for a cohort or trial, the risk in each group, the risk ratio and the risk difference;
  • Pearson’s chi-square (with and without Yates’ correction), Fisher’s exact test and the mid-p exact test.

For several strata it gives the Mantel-Haenszel OR (and RR for cohorts) with intervals, the crude value for comparison, the Mantel-Haenszel chi-square test, the Breslow-Day test of equal odds ratios (with Tarone’s correction), each stratum’s own ratio and a forest plot.

For study and teaching, not medical advice. Check with a qualified professional.

How to use it

  1. Choose One table or Strata.
  2. Pick the study design. In a case-control study people were chosen because they had the disease or not, so only the odds ratio is valid. In a cohort or trial groups were chosen by exposure, so the risk ratio can be worked out too.
  3. Type the counts: exposed and unexposed rows, cases (ill) and controls (well) columns. For strata, paste one row per stratum: name, exposed cases, exposed non-cases, unexposed cases, unexposed non-cases, or open a CSV or Excel file.
  4. Choose the confidence level, and for strata whether the Mantel-Haenszel test uses a continuity correction.
  5. Download the results as CSV, the forest plot as PNG, or a report as an image, PDF or Word file.

The formulas

With exposed cases a, exposed non-cases b, unexposed cases c and unexposed non-cases d: OR = ad/bc with limits exp(ln OR ± z√(1/a + 1/b + 1/c + 1/d)) (Woolf). RR = [a/(a + b)]/[c/(c + d)] with SE(ln RR) = √(1/a − 1/(a + b) + 1/c − 1/(c + d)). The exact odds ratio is the conditional maximum likelihood estimate from the noncentral hypergeometric distribution, and its limits are where each tail probability equals α/2; mid-p limits count half the probability of the table seen. The MH OR is Σ(ad/n)/Σ(bc/n), with the Robins-Breslow-Greenland variance; the MH RR is Σ(a(c + d)/n)/Σ(c(a + b)/n), with the Greenland-Robins variance.

Worked example

The made-up case-control study has 40 exposed and 20 unexposed cases, against 60 exposed and 80 unexposed controls. The page shows OR 2.67 (1.42 to 5.02); the exact estimate is 2.65 (1.36 to 5.31) and the mid-p interval 1.42 to 5.07. Pearson’s chi-square is 9.524 (p = 0.002) and Fisher’s exact p is 0.003. Switch to Cohort or trial and the RR is 2 (1.26 to 3.17).

The made-up strata example (three age groups) gives a Mantel-Haenszel OR 2.84 (1.69 to 4.76) against a crude OR of 2.67. Breslow-Day is 0.130 on 2 df (p = 0.937), so the strata agree, and the MH chi-square is 16.055 (p < 0.001).

Tips

  • When any expected count is below 5, report Fisher’s exact test or the mid-p test and the exact interval. The page warns you.
  • If the crude and adjusted ratios differ by more than about 10 %, the stratifying factor is a likely confounder.
  • If Breslow-Day is significant, the effect differs between strata (effect modification): report each stratum rather than one pooled number.

Frequently asked questions

Why do the exact and Woolf odds ratios differ? The exact one is the conditional maximum likelihood estimate, as R’s fisher.test gives. It is close to ad/bc in large samples.

What if a cell is zero? The OR is then 0 or infinite and Woolf’s interval does not exist, but the exact interval still does. Strata with zeros still count in the Mantel-Haenszel estimate.

Is my data stored? No. Everything is worked out in your browser and nothing is sent anywhere.

Where the numbers come from

  • Formulas: Woolf (1955, Ann Hum Genet 19:251); Katz et al. (1978, Biometrics 34:469); Fisher (1935, J R Stat Soc); Cornfield (1956) and Rothman, Greenland and Lash, Modern Epidemiology, 3rd ed. (textbook) for exact and mid-p odds ratio limits; Mantel and Haenszel (1959, J Natl Cancer Inst 22:719); Robins, Breslow and Greenland (1986, Biometrics 42:311); Greenland and Robins (1985, Biometrics 41:55); Breslow and Day (1980, IARC Sci Publ 32); Tarone (1985, Biometrika 72:91).
  • Example numbers are made up for teaching.

Standard scientific values, such as constants, atomic weights and melting points, are facts found in every textbook; we name where ours were checked. If you are an author or publisher and want a value, a credit or a table changed or removed, tell us and we will act quickly.

Last updated 2026-11-09.

Related tools

Diagnostic test calculator #461 Sensitivity, specificity, predictive values, likelihood ratios and accuracy from a 2 × 2 table, with exact or Wilson 95 % intervals. Turn a pre-test probability into a post-test probability and see it on a Fagan nomogram. Rates and age standardisation #463 Incidence rates, cumulative incidence and prevalence with confidence intervals, directly age-standardised rates with Fay-Feuer gamma intervals, and indirect standardisation: expected events and the SMR with exact Poisson limits. Paste data by age group or open a file. Epidemic curve and attack rates #464 Draw an outbreak epidemic curve from onset dates (or dates and counts) in bars of hours, days or weeks, with the peak, median onset and incubation from a shared exposure. Add a food-history table for attack rates, attack-rate ratios with intervals and Fisher's exact p. PNG and CSV downloads. NNT calculator #465 Number needed to treat or harm from events in a treated and a control group, with the absolute risk reduction, relative risk, relative risk reduction and odds ratio, all with 95 % intervals. Shows the NNT interval the Altman way when it crosses zero. Reliability and agreement #40 Check a questionnaire scale with Cronbach's alpha and item statistics, or rater agreement with Cohen's kappa (weighted too), Fleiss' kappa and all six intraclass correlations with 95 % intervals. Matches R's psych package. Sample size and power calculator #32 How many subjects, samples or survey responses do you need? Sample size for comparing two means, paired data, two proportions, or a survey's margin of error, with power curves. Matches R and G*Power. Uncertainty propagation calculator #25 Type your formula and your measurements with their uncertainties, or paste repeated readings. Get the result with its uncertainty, which input matters most, and a Monte Carlo check.