acalculator

What is the odds ratio?

Type the four counts of a 2 × 2 table, exposed and unexposed, with and without the outcome. The calculator gives the odds ratio, the relative risk (risk ratio), and the risk and odds in each group, worked from the exact counts.

Your numbers

Odds ratio (OR)
7.217

The odds ratio is 7.217 and the relative risk is 6.108.

Relative risk (risk ratio)
6.108
Risk, exposed
17.83%
Risk, unexposed
2.92%
Odds, exposed
0.2171
Odds, unexposed
0.0301

Odds ratio (OR): 7.217. The odds ratio is 7.217 and the relative risk is 6.108.

How to calculate

Computes the odds ratio (ad ÷ bc) and the relative risk (risk ratio) from the four counts of a 2 × 2 table, with the risk and odds in each group.

Example with the default inputs (a: exposed, with the outcome 28, b: exposed, without the outcome 129, c: unexposed, with the outcome 4, d: unexposed, without the outcome 133): The odds ratio is 7.217 and the relative risk is 6.108.

Method: Risk, exposed = a ÷ (a + b); risk, unexposed = c ÷ (c + d); relative risk = risk exposed ÷ risk unexposed; odds ratio = (a ÷ b) ÷ (c ÷ d) = ad ÷ bc.

  • a and b are the exposed group (with and without the outcome); c and d are the unexposed group.
  • No zero correction: when b or c is 0 there is no answer; when d is 0 the unexposed odds are not shown.
  • The page gives point values only, not confidence intervals.

Machine-readable copies: Markdown, JSON.

Worked examples

Each example is checked against the calculator on every build.

  1. a: exposed, with the outcome 28, b: exposed, without the outcome 129, c: unexposed, with the outcome 4, d: unexposed, without the outcome 133 gives Odds ratio (OR) 7.217054, Relative risk (risk ratio) 6.10828, Risk, exposed 17.834395%, Risk, unexposed 2.919708%.Source: CDC, Principles of Epidemiology, Lesson 3, section 5, Example A (risk ratio 6.1) and Exercise 3.8 (OR = 28 × 133 ÷ (129 × 4) = 7.2); https://archive.cdc.gov/www_cdc_gov/csels/dsepd/ss1978/lesson3/section5.html
  2. a: exposed, with the outcome 100, b: exposed, without the outcome 1,900, c: unexposed, with the outcome 80, d: unexposed, without the outcome 7,920 gives Odds ratio (OR) 5.210526, Relative risk (risk ratio) 5, Odds, exposed 0.052632, Odds, unexposed 0.010101.Source: CDC, Principles of Epidemiology, Lesson 3, section 5, Table 3.15 (risk 5.0% and 1.0%, RR 5.0, OR 792,000 ÷ 152,000 = 5.2); https://archive.cdc.gov/www_cdc_gov/csels/dsepd/ss1978/lesson3/section5.html
  3. a: exposed, with the outcome 18, b: exposed, without the outcome 134, c: unexposed, with the outcome 3, d: unexposed, without the outcome 4 gives Relative risk (risk ratio) 0.276316, Odds ratio (OR) 0.179104.Source: CDC, Principles of Epidemiology, Lesson 3, section 5, Example B (risk 11.8% and 42.9%, RR 0.28); https://archive.cdc.gov/www_cdc_gov/csels/dsepd/ss1978/lesson3/section5.html

How it works

The table has two rows (exposed, unexposed) and two columns (with the outcome, without it):

With the outcomeWithout the outcomeTotal
Exposedaba + b
Unexposedcdc + d
  1. Risk, exposed = a ÷ (a + b). Risk, unexposed = c ÷ (c + d). Both are shown as percents.
  2. Relative risk (risk ratio) = risk exposed ÷ risk unexposed = [a ÷ (a + b)] ÷ [c ÷ (c + d)].
  3. Odds, exposed = a ÷ b. Odds, unexposed = c ÷ d.
  4. Odds ratio = (a ÷ b) ÷ (c ÷ d) = (a × d) ÷ (b × c), the cross-product ratio.

Rules. Each count is a whole number, 0 or more. Each group must have at least one person (a + b > 0 and c + d > 0). If b or c is 0, the odds ratio has no finite value, and there is no answer. If d is 0, the unexposed odds are not shown (the odds ratio is still a × d ÷ (b × c) = 0). No zero-cell correction is made.

Rounding. Every value is worked as an exact fraction of the counts and rounded once for display: the ratios to 3 decimals, the odds to 4 decimals, and the risks to 2 decimals of a percent.

The page gives point values only. It does not give confidence intervals or a test of significance.

Worked examples by hand

Tuberculosis in a prison (page default). a = 28, b = 129, c = 4, d = 133. Risk, exposed = 28 ÷ 157 = 17.83%. Risk, unexposed = 4 ÷ 137 = 2.92%. Relative risk = 0.178344 ÷ 0.029197 = 6.108. Odds ratio = (28 × 133) ÷ (129 × 4) = 3,724 ÷ 516 = 7.217. CDC reports a risk ratio of 6.1.

A rare outcome (CDC Table 3.15). a = 100, b = 1,900, c = 80, d = 7,920. Risks 100 ÷ 2,000 = 5.0% and 80 ÷ 8,000 = 1.0%, so the relative risk is 5.000. Odds ratio = (100 × 7,920) ÷ (1,900 × 80) = 792,000 ÷ 152,000 = 5.211. Odds, exposed = 100 ÷ 1,900 = 0.0526; odds, unexposed = 80 ÷ 7,920 = 0.0101.

Varicella and vaccination. a = 18, b = 134, c = 3, d = 4. Risk, vaccinated = 18 ÷ 152 = 11.84%; risk, unvaccinated = 3 ÷ 7 = 42.86%. Relative risk = 0.118421 ÷ 0.428571 = 0.276. Odds ratio = (18 × 4) ÷ (134 × 3) = 72 ÷ 402 = 0.179.

Other questions people ask

How do I calculate an odds ratio?

Put the counts in a 2 × 2 table: a and b for the exposed group (with and without the outcome), c and d for the unexposed group. The odds ratio is (a × d) ÷ (b × c). For a = 28, b = 129, c = 4, d = 133: 3,724 ÷ 516 = 7.22.

How do I calculate relative risk?

Divide the risk in the exposed group, a ÷ (a + b), by the risk in the unexposed group, c ÷ (c + d). With the same table: 28 ÷ 157 = 17.8% and 4 ÷ 137 = 2.9%, so the relative risk is 6.11.

What is the difference between an odds ratio and relative risk?

Relative risk compares probabilities (cases ÷ everyone in the group). The odds ratio compares odds (cases ÷ non-cases). When the outcome is rare, the two are close; when it is common, the odds ratio is further from 1 than the relative risk.

What does an odds ratio of 1 mean?

The odds of the outcome are the same in both groups: no association. Above 1, the outcome is more likely in the exposed group; below 1, less likely, which suggests a protective effect.

When should I use the odds ratio instead of relative risk?

In a case-control study the investigator chooses how many cases and controls to enroll, so the risks in the table are not real risks; the odds ratio is the measure used there. A cohort study or trial can give either.

What if a cell is zero?

If b or c is 0, the odds ratio has no finite value, and the page gives no answer. Some methods add 0.5 to every cell first (a zero-cell correction); this page does not, so type the corrected counts yourself if your method calls for it.