Odds Ratio Calculator

Figran

Enter a 2×2 table to get the odds ratio, relative risk and NNT with confidence intervals and exact tests.

  • OR, RR, risk difference and NNT
  • Fisher exact and chi-square
  • Exact CIs for small or zero cells

Data

Total
11,037
11,034
Total37821,69322,071
Options
Figure
OR = 0.58

95% CI 0.47 to 0.71 · RR 0.58 · NNTB 111 · Chi-square p < 0.0001

Event riskAspirin1.3%Placebo2.2%0%2.5%5%Event risk (%)EffectOR0.58 (0.47–0.71)RR0.58 (0.47–0.72)0.250.501.0Ratio (log scale)

Results

MeasureEstimateConfidence intervalMethod
Odds ratio0.580.47 to 0.71Woolf
Conditional exact OR0.580.46 to 0.71Exact (conditional)
Relative risk0.580.47 to 0.72Katz
Relative risk reduction41.9%28.5% to 52.7%Katz
Risk difference−0.91 percentage points−1.25 to −0.57Newcombe
Number needed to treatNNTB 111NNTB 80 to 1771 / |RD|
Event risk: Aspirin1.3%1.1% to 1.5%Wilson
Event risk: Placebo2.2%1.9% to 2.5%Wilson

Tests

Minimum expected count: 188.97

TestStatisticDegrees of freedomp value
Fisher: two-sided——p < 0.0001
Chi-square26.91p < 0.0001
Chi-square (Yates)26.41p < 0.0001

Observed / expected

NameHeart attackNo heart attackTotal
Aspirin139 / 189.0310,898 / 10,847.9711,037
Placebo239 / 188.9710,795 / 10,845.0311,034
Total37821,69322,071

Report

Results

Heart attack occurred in Aspirin (139 of 11,037, 1.3%) and in Placebo (239 of 11,034, 2.2%). OR 0.58 (95% CI 0.47 to 0.71); RR 0.58 (95% CI 0.47 to 0.72); Chi-square p < .0001. Risk difference −0.91 percentage points, 95% CI −1.25 to −0.57; NNTB 111 (NNTB 80 to 177).

Methods

Odds ratios with 95% confidence intervals were calculated using the Woolf method. Relative risks used Katz intervals and risk differences used Newcombe intervals. Groups were compared using the chi-square test.

Odds ratio calculator examples

Explore real studies and common 2×2 analyses.

Event riskAspirin1.3%Placebo2.2%0%2.5%5%EffectOR0.58 (0.47–0.71)RR0.58 (0.47–0.72)0.250.501.0

Relative risk and NNT: aspirin and heart attack

A randomized trial comparing heart attacks in aspirin and placebo groups.

Source: Physicians’ Health Study, NEJM 1989 · 22,071 participants

Exposed proportionCases99.7%Controls95.8%0%100%EffectOR14.0 (3.50–122)1.025

Case–control odds ratio: smoking and lung cancer

Compare smoking exposure in men with and without lung cancer.

Source: Doll and Hill, BMJ 1950 · 649 cases and 649 controls

Event riskSmoker40.5%Non-smoker25.2%0%100%EffectOR2.02 (1.08–3.78)RR1.61 (1.06–2.44)1.02.05.0

Odds ratio vs relative risk: smoking and low birth weight

A common outcome shows why OR and RR can differ.

Source: MASS birthwt data · 189 births

Event riskVaccine0.00%Placebo0.21%0%0.5%EffectOR0 (0–0.13)RR0.02 (0.000998–0.27)0.000501.0

Zero events: severe COVID-19 in a vaccine trial

No severe cases occurred in the vaccine group.

Source: Baden et al., NEJM 2021 · 28,207 participants

Event riskFirst group75.0%Second group25.0%0%100%EffectOR9.00 (0.37–221)RR3.00 (0.50–18.0)1.025

Fisher’s exact test: the lady tasting tea

A small table illustrates Fisher’s exact test.

Source: Fisher, The Design of Experiments, 1935 · 8 cups

Event riskRofecoxib0.49%Naproxen0.10%0%0.5%1%EffectOR5.00 (1.71–14.6)RR4.98 (1.70–14.6)1.010

Number needed to harm: rofecoxib and heart attack

Uses the corrected count of 20 heart attacks in the rofecoxib group.

Source: Bombardier et al., NEJM 2000; Curfman et al., NEJM 2005 · 8,076 participants

White5.76Black3.30Other1.25Crude2.02Mantel–Haenszel3.090.251.02.510

Mantel–Haenszel odds ratio: birth weight by race

Compare crude and adjusted odds ratios across three strata.

Source: MASS birthwt data · 3 strata

A0.35B0.80C1.13D0.92E1.22F0.83Crude1.84Mantel–Haenszel0.900.200.501.02.0

Simpson’s paradox: Berkeley graduate admissions

Compare crude and department-adjusted odds ratios.

Source: Bickel et al., Science 1975 · 6 departments

How to calculate an odds ratio

Enter your counts, choose a method and export the results.

  1. 1Choose a design

    Select cohort or trial, or case–control.

  2. 2Enter counts

    Fill the 2×2 table or enter events and totals.

  3. 3Review the results

    Compare the estimates, intervals and tests.

  4. 4Export

    Download a figure or copy a report.

Odds ratio, relative risk or NNT?

Choose an estimate that fits the way the data were collected.

DesignMeasuresDefault intervalNotes
Case–controlOR onlyWoolfSampling fixes case and control totals.
Cohort or trialOR, RR, RD, NNTWoolf, Katz, NewcombeRisk estimates require defined groups and follow-up.
Cross-sectionalOR, RRWoolf, KatzRR is a prevalence ratio.

When the odds ratio overstates the relative risk

When an outcome is common, an odds ratio can lie farther from 1 than the risk ratio. In the birth-weight example, OR is 2.02 and RR is 1.61.

Fisher’s exact test or chi-square?

Auto selects Fisher when any expected count is below 5, and Pearson chi-square otherwise. The selected test is named with the result.

Zero cells

Adding 0.5 to all four cells supports Woolf and Katz intervals. Fisher and conditional exact intervals use the original counts.

Adjusting for a confounder

Use strata to compare a crude odds ratio with a Mantel–Haenszel estimate. The Breslow–Day test examines variation among strata.

References: Zhang & Yu (1998) · Cochran (1954) · Haldane (1956) · Mantel & Haenszel (1959) · Breslow & Day (1980)

Odds ratio formulas and confidence intervals

For a table with cells a, b, c and d, the estimators are:

Odds ratio

OR = (a × d) / (b × c)

OR = 139 × 10,795 / (10,898 × 239) = 0.58

SE(log OR) = √(1/a + 1/b + 1/c + 1/d)

Relative risk

RR = [a / (a + b)] / [c / (c + d)]

SE(log RR) = √[1/a − 1/(a + b) + 1/c − 1/(c + d)]

Risk difference

RD = a / (a + b) − c / (c + d)

NNT = 1 / |RD|

Newcombe combines Wilson intervals for the two risks; NNT is the reciprocal of the absolute risk difference.

Tests

χ² = Σ (O − E)² / E

P(a) = C(a + b, a) C(c + d, c) / C(n, a + c)

Mantel–Haenszel odds ratio

ORMH = Σ(aᵢdᵢ/nᵢ) / Σ(bᵢcᵢ/nᵢ)

References: Woolf (1955) · Katz et al. (1978) · Newcombe (1998) · Altman (1998) · Fisher (1935) · Robins, Breslow & Greenland (1986)

Odds ratio calculator FAQ

How do I calculate an odds ratio from a 2×2 table?

Multiply a by d and divide by b times c. A Woolf confidence interval uses the logarithm of the odds ratio.

What is the difference between an odds ratio and relative risk?

Relative risk compares probabilities; an odds ratio compares odds. For common outcomes, the odds ratio is often farther from 1.

How do I interpret an odds ratio and its 95% CI?

An OR above 1 indicates higher odds in the first group; an OR below 1 indicates lower odds. A wide interval indicates substantial uncertainty. To convert an odds ratio to Cohen’s d, use the effect size calculator.

When should I use Fisher’s exact test instead of chi-square?

Fisher’s test is useful for small expected counts. Auto selects it when any expected count is below 5.

What if one cell is zero?

A 0.5 correction can support Woolf and Katz intervals; exact methods use the original counts. If neither group has events, OR and RR are not estimable.

How is the number needed to treat calculated?

NNT is the reciprocal of the absolute risk difference, rounded up. A confidence interval crossing zero extends through infinity between benefit and harm.

Can I adjust the odds ratio for a confounder?

Yes. Enter strata to calculate a Mantel–Haenszel odds ratio; multiple covariates require a regression model.

Which 2×2 tables does this calculator not handle?

Diagnostic tables use sensitivity and specificity; pooling studies uses a forest plot; survival times use a Kaplan–Meier analysis. Paired data need McNemar’s test, tables larger than 2×2 need r×c methods, and prospective sample size needs power analysis. Related tools: sensitivity and specificity calculator · forest plot generator · Kaplan–Meier curve generator · power analysis calculator.

Do the results match R, MedCalc, OpenEpi, SPSS and Stata?

Methods and defaults differ across statistical packages. The conditional exact interval inverts Fisher’s noncentral hypergeometric distribution using high-precision root solving; R fisher.test uses a default solver tolerance, so results can differ in later significant digits. Counts stay in your browser. Woolf uses a large-sample approximation; exact intervals are useful with small or zero cells, while mid-p intervals are less conservative.

Analyse your 2×2 table

Calculate effect measures, confidence intervals and tests in your browser.

Calculate an odds ratio