BiostatKit Tiếng Việt

BiostatKit / Risk & odds / Odds ratio

Odds Ratio Calculator

Enter a 2x2 table and get the odds ratio, its 95% confidence interval and p-value, a sentence you can paste into your manuscript, and the R code that reproduces every number.

Your data never leaves your browser. No sign-up, no ads.

Your 2x2 table

Counts of people, not percentages.

Outcome
present
Outcome
absent
Total
Exposedor treated
100
Unexposedor control
100
Total
30
170
200

Result

Unadjusted odds ratio, exposed vs unexposed.

Sentence for your manuscript

Written in AMA style from your numbers. Check it against your own study design before you submit.

Reporting checklist

  • STROBE 2007 (observational studies): state the statistical methods (item 12) and give unadjusted estimates with their confidence interval (item 16a).
  • CONSORT 2010 (trials): report the effect size and its precision (item 17a); for a binary outcome, also give absolute effect sizes (item 17b). The table above shows both risks.

Methods wording. The odds ratio and its 95% CI (Woolf logit method) were computed with BiostatKit [1]; the association was tested with the Pearson chi-square or Fisher exact test.
[1] BiostatKit. Odds ratio calculator. Accessed [date]. [URL]

Reproduce it in R

The script is filled in with your numbers. Paste it into R or RStudio and compare.

R 4.x · base R only

    

This calculator was checked against SciPy and statsmodels on 2 reference cases and matched to 4 significant digits. See the verification log.

How to read an odds ratio

What it is

The odds ratio (OR) compares the odds of the outcome in the exposed group with the odds in the unexposed group. OR = 1 means no association, OR above 1 means higher odds with exposure, OR below 1 means lower odds.

How this page computes it

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

The 95% CI is built on the log scale (Woolf): exp( ln OR ± 1.96 x SE ) with SE = sqrt(1/a + 1/b + 1/c + 1/d).

The p-value is shown two ways: Pearson chi-square without continuity correction, and Fisher exact (two-sided, sum of tables no more likely than the observed one). When any expected count is below 5, trust Fisher. Near the boundary the Woolf CI and the chi-square test can disagree slightly (the CI includes 1 while P is just under .05); report both and say which test you used.

Assumptions

  • Participants are independent (no matched pairs; use McNemar for paired data).
  • Exposure and outcome are both binary and defined before looking at the data.
  • The OR is unadjusted. Adjust for confounders with logistic regression.

Common mistakes

  • Reading an OR as a risk ratio. They are close only when the outcome is rare (under about 10%).
  • Calling a CI that includes 1 "no effect". It says the data are compatible with no effect and with a range of effects.
  • Entering percentages instead of counts.

Note on fisher.test in R

R's fisher.test() returns the conditional maximum-likelihood OR, which can differ slightly from (a x d)/(b x c). The script above uses the sample OR and Woolf CI so it matches this page, and uses fisher.test() only for the p-value.

Frequently asked questions

When should I use an odds ratio instead of a risk ratio?

Use the OR for case-control studies and for logistic regression, where risks cannot be estimated directly. For cohort studies and trials with a common outcome, the risk ratio is easier to interpret.

What does a zero cell do?

The OR is undefined (division by zero) or infinite. This tool adds 0.5 to every cell and says so. Report that choice in your methods.

Chi-square or Fisher exact: which p-value do I report?

Report Fisher exact when any expected cell count is under 5 or the total is small. Otherwise either is acceptable; say which one you used.

Is my data stored or sent anywhere?

No. All calculations run in your browser tab. Nothing is uploaded, and the page works offline once loaded.

Related calculators: Relative risk calculator · NNT calculator