Hypothesis tests

Odds ratio hypothesis test calculator

Test H₀: OR = 1 in a 2×2 contingency table. Computes the Z statistic on ln(OR), the p-value, the confidence interval and the statistical decision.

Parameters

Enter the frequencies of the 2×2 case-control table to get the odds ratio, the Z statistic, the p-value, the confidence interval and the statistical decision.

Result pending…

Rejection regions and observed statistic

What is the odds ratio test?

It is the test used to decide whether there is an association between an exposure and an outcome from a 2×2 table, measuring that association with the odds ratio (OR). It is the standard tool of case-control studies: you gather a group of people with the disease (cases) and another without it (controls), and compare how often each group was exposed to a factor —tobacco, a drug, a pollutant.

If the exposure has nothing to do with the disease, the proportion exposed should be similar among cases and controls, and the OR close to 1. An OR greater than 1 indicates that the exposure is more frequent among cases (risk factor); less than 1, that it is less frequent (protective factor).

Odds and odds ratio

The odds of an event is the ratio between the probability that it happens and the probability that it does not: with a probability of 40%, the odds are 0.4/0.6 = 0.67, that is, 2 to 3. The odds ratio compares two odds. With the table the calculator asks for:

ExposedUnexposed
Casesab
Controlscd

\( \widehat{OR} = \dfrac{a/b}{c/d} = \dfrac{a \cdot d}{b \cdot c} \)

It is the odds of exposure among cases divided by the odds of exposure among controls. A very useful property is that it equals the odds ratio of disease between exposed and unexposed people, which is what really matters. That is why the OR can be estimated in a case-control study, where the proportion of cases is set by the researcher and risk cannot be computed.

Hypotheses and test statistic

\(H_0: OR = 1\) (no association)

\(H_1: OR \neq 1\), \(OR > 1\) or \(OR < 1\)

The OR has a very skewed distribution (it ranges from 0 to infinity, with 1 in the middle), so the test is carried out on its logarithm, which is well approximated by a normal distribution:

\( SE[\ln \widehat{OR}] = \sqrt{\dfrac{1}{a} + \dfrac{1}{b} + \dfrac{1}{c} + \dfrac{1}{d}}, \qquad z = \dfrac{\ln \widehat{OR}}{SE} \)

This is the Wald test. The same standard error gives Woolf's confidence interval: it is computed on the log scale, \(\ln \widehat{OR} \pm z_{1-\alpha/2}\,SE\), and then exponentiated. That is why the interval is not symmetric around the OR: an OR of 1.56 can have an interval from 0.87 to 2.79.

The standard error depends mainly on the smallest cell: if one has very few individuals, \(1/a\) shoots up and the test becomes unreliable. With any cell below 5, it is worth checking the result with Fisher's exact test, which the calculator links to already filled in.

Decision rule

  • If the p-value is less than \(\alpha\), \(H_0\) is rejected: there is evidence of an association.
  • In the two-tailed test, this is equivalent to the OR confidence interval not containing 1.
  • Not rejecting \(H_0\) does not prove that there is no association.

Odds ratio and relative risk

The relative risk (RR) compares probabilities: the risk of disease among the exposed divided by that among the unexposed. It is more intuitive, but it can only be computed in cohort studies or trials, which follow exposed and unexposed people. The OR approximates the RR when the disease is rare (below roughly 10% of the population): in that case, an OR of 2 means, in practice, that the risk doubles. When the outcome is common, the OR exaggerates the association compared with the RR, and the two should not be read as the same thing.

If your two groups are exposed and unexposed people and you measure the outcome, you can compare the proportions directly with the two-proportion test or compute the interval for the ratio of proportions.

Assumptions of the test

  • Independent observations: each person appears only once in the table. If each case is matched to a specific control, you need an analysis for paired data (McNemar or conditional logistic regression).
  • Cells that are not too small: the normal approximation of the log OR works well with all cells around 5 or more.
  • No zero cells: with a zero, the OR is 0 or infinite. The calculator requires at least 1 in each cell; with zeros, use Fisher's exact test or the interval with a 0.5 correction.
  • No selection bias or confounding: an OR different from 1 may be due to another variable related to both the exposure and the disease. The test measures association, not causation.

Worked example 1: a non-significant association

In a study of 100 cases and 100 controls, 40 cases (a) and 30 controls (c) were exposed; 60 cases (b) and 70 controls (d) were not. We test \(H_0\colon OR = 1\) with \(\alpha = 0.05\), two-tailed.

\( \widehat{OR} = \dfrac{40 \times 70}{60 \times 30} \approx 1.556, \qquad \ln \widehat{OR} \approx 0.442 \)

\( SE = \sqrt{\dfrac{1}{40} + \dfrac{1}{60} + \dfrac{1}{30} + \dfrac{1}{70}} \approx 0.299, \qquad z = \dfrac{0.442}{0.299} \approx 1.48 \)

The two-tailed p-value is \(p \approx 0.139\): \(H_0\) is not rejected. The 95% confidence interval for the OR runs from 0.87 to 2.79 and contains 1.

Conclusion: there is not enough evidence of an association. But the interval is compatible both with no effect and with nearly tripling the odds. With 100 cases and 100 controls, and 30% of controls exposed, the test detects with 80% probability only odds ratios of 2.27 or more (or 0.37 or less).

In the calculator: a = 40, b = 60, c = 30, d = 70. These are the values the page opens with.

Worked example 2: a risk factor

Another study with 100 cases and 100 controls finds 60 exposed cases (a) and 40 unexposed (b), against 35 exposed controls (c) and 65 unexposed (d).

\( \widehat{OR} = \dfrac{60 \times 65}{40 \times 35} \approx 2.79, \qquad SE \approx 0.293, \qquad z = \dfrac{\ln 2.79}{0.293} \approx 3.50 \)

The p-value is \(p \approx 0.0005\): \(H_0\) is rejected. The odds of exposure are about 2.8 times higher among cases, with a 95% confidence interval from 1.57 to 4.94. If the disease is rare, this can be read as the exposure multiplying the risk by just under 3.

In the calculator: a = 60, b = 40, c = 35, d = 65.

How to interpret the result

Rejecting \(H_0\) (p-value < α) indicates that there is an association between the exposure and the outcome: with OR > 1, the exposure behaves as a risk factor; with OR < 1, as a protective factor. To judge its importance, look at the OR and its confidence interval: an OR of 1.2 can be significant in a huge study and have little practical relevance.

Not rejecting \(H_0\) does not prove that there is no association: look at the interval, which tends to be very wide in small studies.

In the calculator, the result shows the decision with the p-value, the OR with the z statistic and a sentence stating the conclusion. On the chart, the green area is the non-rejection region on the standard normal, the red areas are the critical regions and the amber line marks the statistic. Under "Calculation details" you will find the log OR, its standard error, Woolf's interval, the proportion exposed among cases and controls, and Pearson's chi-square as a check.

Power and minimum detectable odds ratio

Below the conclusion, the calculator shows the minimum detectable odds ratio: the OR closest to 1 that, with your numbers of cases and controls and the proportion exposed among the controls, the test would detect with 80% probability. If it is more extreme than the effect that would matter to you, the study has low power. The link opens the sample size calculator for the odds ratio with your proportion exposed, your α, the number of controls per case and the type of test.

Confidence interval

The other link opens the odds ratio confidence interval calculator with your table. That calculator arranges the table by exposure (rows) and outcome (columns), so the link reorders the cells for you; the OR is the same.

Common mistakes

  • Entering the cells in a different order: swapping b and c gives you the inverse of the OR.
  • Reading the OR as a relative risk when the outcome is common.
  • Interpreting the association as causation without controlling for confounding.
  • Using the Wald test with very small cells: check with Fisher.
  • Analysing one-to-one matched cases and controls as independent.
  • Reporting the OR without a confidence interval.

Frequently asked questions

  • What is the odds ratio? The ratio between two odds: in a case-control study, the odds of exposure among cases divided by that among controls. It equals 1 if there is no association.
  • How is an OR of 2 interpreted? The odds of exposure are twice as high among cases as among controls. If the disease is rare, it roughly means that the exposure doubles the risk.
  • Why work with the log of the OR? Because the OR is very skewed and its logarithm is much closer to a normal distribution. That is why the confidence interval is not symmetric around the OR.
  • How does it differ from relative risk? Relative risk compares probabilities and requires a cohort study; the OR compares odds and can be estimated in case-control studies. They are similar only when the outcome is rare.
  • What if a cell is zero or very small? Use Fisher's exact test. For the interval, the 0.5 correction allows it to be computed with zeros.
  • What hypothesis does it test? That the odds ratio equals 1, that is, that there is no association between exposure and outcome.
  • What is the minimum detectable odds ratio? The OR closest to 1 that the test would detect with 80% probability given your numbers of cases and controls.
  • Does a significant OR prove causation? No. It may be due to selection bias or confounding variables. Logistic regression is used to adjust for them.

Reference: Odds ratio — Wikipedia