Odds Ratio Calculator

An odds ratio calculator returns the ratio of exposed-to-unexposed odds from a 2×2 contingency table along with a 95% Wald confidence interval computed on the log scale. This calculator also converts between odds ratio and risk ratio using the Zhang-Yu (1998) correction when outcome prevalence is non-rare, picks Fisher’s exact or χ² for the p-value automatically, and outputs a paste-ready APA or Vancouver sentence with the method footnote.

Calculated locally · nothing uploaded 0 requests sent

Every calculation runs in your browser. The live counter above shows the calculator has made zero network requests since page load.

What this calculator computes

A 2×2 odds ratio with a 95% Wald confidence interval on the log scale, exponentiated back to the ratio scale. The p-value comes from Fisher’s exact test when any expected cell count falls below five and from Pearson’s χ² with one degree of freedom otherwise; the result panel tells you which. When any of the four cells is zero, the Haldane–Anscombe 0.5 correction kicks in automatically and is flagged in the method footnote.

The second tab converts between odds ratio and risk ratio using the Zhang & Yu (1998) formula, which corrects the well-known overstatement of effect when an OR from a logistic regression or case-control study is interpreted as a relative risk for a non-rare outcome.

Loading calculator…

If you are running this calculation on a dozen studies for a meta-analysis or systematic review, Fynman handles the upstream search and screening so the studies hitting this calculator are already the ones that meet inclusion.

How to use it

Pick the mode at the top. Compute from 2×2 is the default and is what you want when you have raw counts. Enter the four cells of the contingency table: outcome-positive and outcome-negative counts for both the exposed and unexposed groups. The form accepts non-negative integers and revalidates as you type. Choose a confidence level (90, 95, or 99 percent), submit, and the result panel shows the OR, its CI, the p-value, and a method label that names exactly which test produced each number.

The annotated layout of the input grid mirrors the way 2×2 tables appear in textbooks and reviewer-style methods sections. Cell a is exposed-and-outcome-positive (cases among the exposed). Cell b is exposed-and-outcome-negative. Cell c is unexposed-and-outcome-positive. Cell d is unexposed-and-outcome-negative. The cross-product (a × d) / (b × c) gives the OR; the same four cells feed the standard error of the log OR and both candidate p-value tests.

Convert OR ↔ RR is the second tab. You only need a ratio value and a baseline prevalence (the outcome rate in the unexposed group). The CI fields on the input ratio are optional; if you provide them, the calculator returns a converted CI as well, applying the Zhang-Yu transformation to each bound. The direction radio at the top of the tab toggles between OR → RR (the common case) and RR → OR (useful when reproducing an analysis that reported only one scale).

Below the numeric result, the Paste-ready sentence panel renders the finding in either APA-7 or Vancouver/ICMJE style. The pill toggle switches between them; the copy button drops the sentence into your clipboard with one click.

Odds ratio vs. risk ratio, and when the converter matters

An odds ratio is the ratio of two odds. A risk ratio is the ratio of two probabilities. They are not the same number, and which one is appropriate depends on the study design and on how common the outcome is.

In case-control studies, the OR is the only ratio measure the data can directly estimate, because the investigator fixes the number of cases and controls rather than the number of exposed and unexposed people. In cohort and randomised designs both measures are available, and the field convention is that the RR is easier to interpret because it speaks the language of probabilities (a 50 percent increase in risk, not a 50 percent increase in odds).

When the outcome is rare (below roughly 10 percent in the unexposed group), the OR and RR are numerically close and many reports treat them interchangeably. Above that threshold the divergence becomes important. At 31 percent baseline prevalence, an OR of 2.0 corresponds to a Zhang-Yu-corrected RR of about 1.53: the OR overstates the relative effect by roughly 31 percent. Reviewers increasingly flag this. If your manuscript reports an OR from a logistic regression on a common outcome and the reviewer asks for an RR equivalent, the converter tab on this calculator is the fast path.

The converter uses Zhang J, Yu KF. What’s the relative risk? JAMA 1998;280:1690-1, which is the standard reference for the correction.

How the confidence interval is calculated

The 95% CI on the OR is built on the log scale. The standard error of the log OR for a 2×2 table is

SE[ln(OR)] = √(1/a + 1/b + 1/c + 1/d)

and the CI bounds are

exp( ln(OR) ± z × SE[ln(OR)] )

with z from the standard normal (1.96 for 95 percent, 1.6449 for 90, 2.5758 for 99). Working on the log scale is what produces the multiplicatively symmetric CI on the original ratio scale; an arithmetically symmetric Wald interval on the OR itself can put the lower bound below zero, which is nonsensical for a ratio.

When any of the four cells is zero, the standard error is undefined (division by zero). The calculator applies the Haldane–Anscombe correction (add 0.5 to all four cells), recomputes the OR and SE on the corrected counts, and labels the result so the convention is visible. This matches the default behaviour of epitools::oddsratio.wald() in R.

The p-value reporting follows the same auto-pick logic used by epi.2by2(). If any expected cell count is below five, the calculator runs Fisher’s exact two-sided test (summing probabilities of tables at least as extreme as the observed one under the hypergeometric null). Otherwise it uses Pearson’s χ² with one degree of freedom and no continuity correction, matching chisq.test(..., correct = FALSE).

Validated against epitools::oddsratio.wald() in R and Stata’s cs command on a 50-input test set. Matches both to four decimals.

Worked example

A case-control study reports 30 lung-cancer cases who smoked versus 10 cases who did not, with 20 smoking and 40 non-smoking controls.

1
2
3
                Outcome+   Outcome-
Exposed (smokers):   30        20
Unexposed:           10        40

Enter a = 30, b = 20, c = 10, d = 40 and a 95% confidence level. The calculator returns OR = 6.00, 95% CI [2.45, 14.68], χ² p < .001. The method label says “Wald CI on log(OR); χ² (df = 1) p-value.” The paste-ready sentence reads OR = 6.00, 95% CI [2.45, 14.68], p < .001 in APA-7 style and Odds ratio 6.00 (95% CI 2.45 to 14.68; P < 0.001) in Vancouver style.

If you then move to the converter tab and treat this as a cohort with a 20 percent baseline prevalence (the proportion of outcome-positives among the unexposed: 10 / (10 + 40)), the OR of 6.00 corresponds to an RR of 3.00 by Zhang-Yu, with the converted CI bounds moving inward correspondingly. The result panel notes that the conversion was applied because prevalence exceeds the 10 percent threshold.

Frequently asked questions

Schedule a demo

Frequently Asked Questions

Find answers to common questions about this topic.

Use the odds ratio for case-control designs, where the total number of exposed and unexposed people is sampled by outcome status and the risk ratio cannot be directly estimated. Use the risk ratio for cohort and randomised designs where person-time or risk denominators are known. When the outcome occurs in less than 10% of the unexposed group, OR and RR are numerically close. As prevalence rises the two diverge; at 30% baseline the OR can overstate the RR by more than 40%.
If any of the four cells is zero, the odds ratio is undefined or infinite. The calculator applies the Haldane–Anscombe 0.5 correction (add 0.5 to every cell) and notes this in the method label so reviewers can see what was done. The correction matches the default behaviour of epitools::oddsratio.wald() and Stata’s cs, woolf.
Yes. The Wald CI on log(OR) matches epitools::oddsratio.wald() in R and the Stata cs command (with woolf option) to four decimals on a 50-input validation set. The χ² p-value matches chisq.test(..., correct = FALSE). Fisher’s exact matches fisher.test() two-sided. Method labels on every result tell you which calculation was used.
The Wald CI is constructed symmetrically on the log scale, where the sampling distribution of log(OR) is approximately normal. When you exponentiate the bounds back to the original ratio scale the interval becomes multiplicatively symmetric (OR_lower × OR_upper ≈ OR²) rather than arithmetically symmetric. That asymmetry is correct and is what every standard package produces.
Yes, on the second tab. Enter the OR, the baseline outcome prevalence in the unexposed group, and (optionally) the CI bounds on the OR. The calculator applies the Zhang & Yu (1998) formula RR = OR / ((1 − p0) + p0 · OR) and returns the converted RR with its CI. The same tab supports the reverse direction (RR → OR), useful when reproducing analyses that report only one scale.
Nothing. The page loads its assets once and then runs entirely in your browser. The privacy badge has a live network counter showing zero requests after page load. Open DevTools and watch the Network tab if you want to verify it yourself.