Home › Calculators › Odds Ratio and Relative Risk Calculator
Odds Ratio and Relative Risk Calculator
Enter the four counts of a 2 × 2 table (exposed or not, outcome or not) to get the odds ratio and relative risk with confidence intervals, the risk difference and number needed to treat, and p-values from the chi-square, z and Fisher exact tests.
Last updated:
Exposed / treatment group
Unexposed / control group
Enter your values to see the result.
Advertisement
Advertisement
How to use the Odds Ratio and Relative Risk Calculator
Enter cell a: exposed (or treated) subjects with the outcome, and b: exposed without it.
Enter c and d: unexposed (or control) subjects with and without the outcome.
Choose the confidence level (95% is standard).
Read the odds ratio and relative risk; if the CI excludes 1 the association is significant.
Check the p-values, using Fisher's exact test for small counts, and copy the results.
2 × 2 table layout and formulas
Outcome yes
Outcome no
Exposed / treatment
a
b
Unexposed / control
c
d
Measure
Formula
Confidence interval
Odds ratio
OR = ad ÷ bc
exp(ln OR ± z√(1/a + 1/b + 1/c + 1/d))
Relative risk
RR = [a/(a+b)] ÷ [c/(c+d)]
exp(ln RR ± z√(1/a − 1/(a+b) + 1/c − 1/(c+d)))
Risk difference
RD = a/(a+b) − c/(c+d)
RD ± z√(p₁(1−p₁)/n₁ + p₂(1−p₂)/n₂)
NNT / NNH
1 ÷ |RD|, rounded up
Chi-square
N(ad − bc)² ÷ [(a+b)(c+d)(a+c)(b+d)]
df = 1
z is 1.645, 1.960 or 2.576 for 90%, 95% and 99% confidence.
Interpreting OR and RR
OR or RR = 1: no association between exposure and outcome.
Above 1: the outcome is more likely in the exposed group (RR = 2 means twice the risk).
Below 1: the exposure is protective (RR = 0.6 means a 40% lower risk).
Which to report: cohort studies and trials can report RR directly; case-control studies fix the number of cases, so only the OR is valid. Logistic regression also produces odds ratios.
Frequently asked questions
How do you calculate an odds ratio?
With a 2 × 2 table where a and b are the exposed subjects with and without the outcome and c and d the unexposed ones, OR = (a × d) ÷ (b × c). It compares the odds of the outcome in the exposed group (a/b) with the odds in the unexposed group (c/d).
What is the difference between an odds ratio and relative risk?
Relative risk compares probabilities: RR = [a ÷ (a + b)] ÷ [c ÷ (c + d)]. The odds ratio compares odds. When the outcome is rare (under about 10%) they are similar; for common outcomes the OR is further from 1 than the RR. Case-control studies can only estimate the OR.
How is the 95% confidence interval calculated?
On the log scale: ln(OR) ± 1.96 × √(1/a + 1/b + 1/c + 1/d) for the odds ratio (Woolf's method) and ln(RR) ± 1.96 × √(1/a − 1/(a+b) + 1/c − 1/(c+d)) for the relative risk, then exponentiated back.
What does it mean if the confidence interval includes 1?
An OR or RR of 1 means no association. If the interval contains 1, the data are compatible with no effect at that confidence level, and the p-value will be above the matching α.
What if one of the cells is zero?
The odds ratio becomes 0 or infinite and its standard error is undefined. A common fix, used here when the option is on, is the Haldane–Anscombe correction: add 0.5 to every cell. Fisher's exact test works without any correction.
When should I use Fisher's exact test?
When the sample is small, typically when any expected cell count is below 5. The chi-square test relies on a large-sample approximation; Fisher's test computes the exact probability from the hypergeometric distribution.
What is the number needed to treat?
NNT = 1 ÷ |risk difference|, rounded up. It is the number of people who must receive the treatment (or avoid the exposure) for one additional person to benefit. When the exposure increases risk it is called the number needed to harm.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.