Odds Ratio & Relative Risk Calculator

Enter a 2×2 contingency table (Exposed/Unexposed × Outcome/No Outcome). Reports the Odds Ratio and Relative Risk with 95% confidence intervals from the log-transform method, plus a color-coded table and full step-by-step working.

2×2 contingency table
Outcome (Yes)Outcome (No)
Exposed
a
b
Unexposed
c
d

Odds Ratio & Relative Risk explained, step by step

Both ratios compare an outcome between exposed and unexposed groups, both equal 1 when there is no association — but they answer different questions and belong to different study designs. Each card below covers one piece the calculator uses.

1. The 2×2 table — where every letter comes from

All formulas below reference the four cells a, b, c, d of the 2×2 contingency table. a is exposed with outcome, b is exposed without, c is unexposed with outcome, d is unexposed without. Get these four numbers right and every ratio follows.

a = exposed·outcome   b
= exposed·no-outcome
c = unexposed·outcome   d
= unexposed·no-outcome
Example
Given
a=40
b=60
c=20
d=80
Substitute
row totals 100 / 100
Answer
table filled

2. Odds Ratio — the case-control / logistic-regression measure

The odds of the outcome in the exposed group are a/b; in the unexposed group they are c/d. Their ratio is OR = ad/bc. OR is the natural output of case-control studies (where risks can't be computed) and of logistic regression.

OR = (a · d) / (b · c)
Example
Given
a=40 b
=60 c
=20 d
=80
Substitute
(40·80)/(60·20)
Answer
OR ≈ 2.67

3. Relative Risk — the cohort / RCT measure

Risk in the exposed group is a/(a+b); in the unexposed group it is c/(c+d). Their ratio is RR — a direct multiplier on the outcome's probability. RR requires knowing the full exposed and unexposed populations, so it belongs to cohort studies and randomised trials.

RR = [ a / (a + b) ] / [ c / (c + d) ]
Example
Given
40/100 vs 20/100
Substitute
0.40 / 0.20
Answer
RR = 2.00

4. Confidence intervals — the log-transform (Woolf) method

Both ratios are skewed, so the CI is built on the log scale then exponentiated back. SE(ln OR) and SE(ln RR) have the closed forms below; multiply by z* (1.96 for 95%) and exponentiate to get the interval. If it excludes 1, the effect is significant at that level.

SE(ln OR) = √(1/a + 1/b + 1/c + 1/d)
CI = exp( ln(ratio) ± z* · SE )
z*1.645 / 1.96 / 2.576 for 90 / 95 / 99%
CI excludes 1 → significant
CI includes 1 → not significant
rare outcome → OR ≈ RR
Example
Given
ln OR = 0.981
SE = 0.323
Substitute
exp(0.981 ± 1.96·0.323)
Answer
[1.42, 5.02]

Features of this calculator

  • Standard epidemiological 2×2 layout — Exposed / Unexposed rows, Outcome / No Outcome columns, with row and column totals shown automatically
  • Both OR and RR reported side by side, so you can compare them and decide which fits your study design
  • 95% confidence intervals for both ratios via the log-transform (Woolf) method — the default in most textbooks and software
  • Selectable 90%, 95% or 99% confidence level, with the matching z* (1.645 / 1.96 / 2.576)
  • Color-coded a/b/c/d cells that match every formula in the working — so you can see exactly which cell is being used where
  • Haldane–Anscombe (+0.5) correction toggle for tables with a zero cell, and a clear message when a zero cell would otherwise blow up the math
  • Show/hide step-by-step working: cell identification, OR and RR formulas, log-CI derivation, and interval interpretation
  • Copy the result summary or download the whole panel as an image

Frequently asked questions

+Which is easier to interpret in plain English?

RR is easier — "3× more likely" reads directly as a risk multiplier. OR is a ratio of odds, not risks, and non-statisticians frequently mis-read it as if it were an RR.

+Do I need a hypothesis test in addition to the CI?

Not usually. A 95% CI that excludes 1 is equivalent to rejecting the null hypothesis of "no association" at the 5% level (two-tailed). The CI carries more information because it also shows the size and precision of the effect.

+What about very small samples?

The log-CI method assumes moderate-to-large counts. For very small samples or zero cells, prefer exact methods (Fisher's exact test, mid-p intervals). The Haldane–Anscombe correction here is a reasonable pragmatic fix but not a substitute for exact inference.

+Can I compute the risk difference too?

Yes — Risk Difference = risk_exposed − risk_unexposed. It's a useful absolute measure alongside the ratios, especially for public-health decisions where absolute impact matters more than relative multiplier.

+Why 1.96 and not 2?

1.96 is the two-tailed z* for 95% confidence under the standard normal distribution (the 97.5th percentile). "2" is a common back-of-envelope rounding that gives you a ~95.4% interval instead of 95.0%.

Related calculators