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

  1. Enter cell a: exposed (or treated) subjects with the outcome, and b: exposed without it.
  2. Enter c and d: unexposed (or control) subjects with and without the outcome.
  3. Choose the confidence level (95% is standard).
  4. Read the odds ratio and relative risk; if the CI excludes 1 the association is significant.
  5. Check the p-values, using Fisher's exact test for small counts, and copy the results.

2 × 2 table layout and formulas

Outcome yesOutcome no
Exposed / treatmentab
Unexposed / controlcd
MeasureFormulaConfidence interval
Odds ratioOR = ad ÷ bcexp(ln OR ± z√(1/a + 1/b + 1/c + 1/d))
Relative riskRR = [a/(a+b)] ÷ [c/(c+d)]exp(ln RR ± z√(1/a − 1/(a+b) + 1/c − 1/(c+d)))
Risk differenceRD = a/(a+b) − c/(c+d)RD ± z√(p₁(1−p₁)/n₁ + p₂(1−p₂)/n₂)
NNT / NNH1 ÷ |RD|, rounded up
Chi-squareN(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.

Related tools

Chi-Square CalculatorChi-square goodness-of-fit and independence tests with p-value and expected counts.P-Value CalculatorOne- or two-tailed p-values from z, t, chi-square or F statistics, with critical values.Bayes Theorem CalculatorPosterior P(A|B) from P(A), P(B|A) and P(B|not A), with a probability tree and table.Probability CalculatorFind and, or, not, conditional and at-least-once probabilities from P(A) and P(B).Weighted Average CalculatorCalculate a weighted mean from values and weights, step by step.Average CalculatorMean, weighted average, median, sum, min and max of any list.Standard Deviation CalculatorStandard deviation, variance, mean, median, mode and quartiles.A/B Test Significance CalculatorCheck if your A/B test result is statistically significant.Z-Score CalculatorZ-score from a value, mean and SD, plus percentile and p-value; or the value from z.Permutation and Combination CalculatorCalculate nPr and nCr, with or without repetition, as exact big numbers.Mean Median Mode CalculatorFind the mean, median, mode, range, min, max, sum and count of a list of numbers.Confidence Interval CalculatorConfidence interval and margin of error for a mean or a proportion, with steps.Sample Size CalculatorHow many survey responses you need for a given confidence level and margin of error.Percentile CalculatorValue at any percentile, percentile rank of a score, quartiles, IQR and outliers.Correlation Coefficient CalculatorPearson r and Spearman rank correlation with significance and interpretation.Average Order Value CalculatorAverage order value from revenue and orders, plus the revenue impact of raising AOV.Binomial Distribution CalculatorBinomial probabilities P(X = k), at most, at least or between, with mean, variance and chart.Normal Distribution CalculatorNormal probabilities P(X < x), between two values and inverse percentiles, on a shaded bell curve.Poisson Distribution CalculatorPoisson probabilities for a rate λ: exactly k, at most, at least or between, with a chart.T-Test CalculatorOne-sample, two-sample (Welch/pooled) and paired t-tests with p-value and CI.Variance CalculatorSample and population variance and standard deviation with a step-by-step deviations table.Five Number Summary CalculatorMin, Q1, median, Q3, max, IQR and fences of a data set, with a box plot.Outlier CalculatorFind outliers with 1.5×/3× IQR fences, z-scores or modified z-scores; get the cleaned data.Geometric Mean CalculatorGeometric, harmonic, arithmetic and quadratic means compared, or average growth from % changes.Expected Value CalculatorExpected value, variance and standard deviation from outcomes and their probabilities.One-Way ANOVA CalculatorOne-way ANOVA for 2-10 groups: SS, df, MS, F statistic, p-value, effect size and full table.Box Plot MakerPaste data to draw box-and-whisker plots with quartiles, IQR and outliers. Download PNG or SVG.Coefficient of Variation CalculatorCV % from a dataset (sample or population) with mean, SD and a two-dataset comparison.Critical Value CalculatorCritical values of z, t, chi-square and F for any alpha, tails and degrees of freedom.Dice Probability CalculatorOdds of rolling a sum (exactly, at least, at most) with any dice, plus the full distribution.Effect Size Calculator (Cohen's d)Cohen's d, Hedges' g and Glass's delta from two means, SDs and sample sizes, with CI.Frequency Table GeneratorMake a frequency, relative and cumulative frequency table from numbers or categories.Histogram MakerPaste numbers, choose bins and get a histogram, frequency table and PNG download.Margin of Error CalculatorSurvey margin of error from sample size, confidence and proportion, with population correction.Moving Average CalculatorSimple, exponential and weighted moving averages of a data series, with table and line chart.Standard Error CalculatorStandard error of the mean from data or SD and n, plus SE of a proportion, with CIs.Descriptive Statistics CalculatorPaste data and get mean, median, mode, quartiles, SD, skewness, kurtosis and a histogram.Empirical Rule Calculator68-95-99.7 rule ranges from a mean and standard deviation, with a shaded bell curve.Permutations GeneratorList all permutations of letters, words or items, with k-permutations and repeats, and export them.Statistical Power CalculatorPower or required sample size for t-tests, proportions and correlations, with a power curve.T Distribution CalculatorStudent's t probabilities and critical values for any df, with the area shaded on the curve.T-Table (Student's t Distribution)Interactive t-table: critical t-values for any df and α, p-values, and a printable full table.Z-Test CalculatorOne-sample, two-sample and proportion z-tests with z, p-value, decision and shaded curve.Shannon Entropy CalculatorEntropy of text, data or probabilities in bits, nats or hartleys with a frequency table.Z-Table (Standard Normal Table)Interactive z-table: find the area for any z-score, or the z-score for a probability.Average Rate of Change CalculatorAverage rate of change of f(x), two points or a data table over [a, b], with the secant line.Binomial Expansion CalculatorExpand (a + b)^n with the binomial theorem: every term, Pascal coefficients and any specific term.Combinations GeneratorList every k-combination of your items, with or without repetition, and copy or export them.Covariance CalculatorSample and population covariance of paired X and Y data, with a step table and scatter plot.Grouped Data CalculatorMean, median, mode, variance and standard deviation from class intervals and frequencies.Inverse Normal Distribution CalculatorinvNorm: find the x or z value for a left, right, central or two-tail area, with a shaded curve.
See all 52 Statistics & Probability Calculators →