Calculator
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.
Explanation
The odds ratio (OR) is the standard measure of association in case-control studies. In this design, people with the condition (cases) and without it (controls) are selected, and whether they were exposed to the factor of interest is recorded retrospectively. The 2×2 table summarizes the four possible combinations of exposure and case status.
Under the null hypothesis \(H_0: \mathrm{OR} = 1\) there is no association between exposure and disease: the odds of exposure are equal in cases and controls. An OR greater than 1 suggests the exposure is a risk factor; an OR less than 1 suggests it is a protective factor.
The test relies on the normal approximation of the log odds ratio. Since \(\ln(\hat{\mathrm{OR}})\) is approximately normal with mean \(\ln(\mathrm{OR})\) and standard error \(\mathrm{SE} = \sqrt{1/a + 1/b + 1/c + 1/d}\), under \(H_0\) the statistic \(Z = \ln(\hat{\mathrm{OR}}) / \mathrm{SE}\) follows an \(N(0,1)\) distribution. This approximation is reliable when all frequencies in the table are at least 5; with smaller frequencies, use Fisher's exact test.
Hypotheses and test statistic
\(H_0: \mathrm{OR} = 1 \quad \Leftrightarrow \quad H_0: \ln(\mathrm{OR}) = 0\)
\( \widehat{\mathrm{OR}} = \frac{a \cdot d}{b \cdot c} \)
\( \mathrm{SE}\bigl(\ln\widehat{\mathrm{OR}}\bigr) = \sqrt{\frac{1}{a} + \frac{1}{b} + \frac{1}{c} + \frac{1}{d}} \)
\( Z = \frac{\ln\widehat{\mathrm{OR}}}{\mathrm{SE}\bigl(\ln\widehat{\mathrm{OR}}\bigr)} \sim N(0,1) \)
Quick test
To quickly interpret an odds ratio, look at three elements: the point estimate of the OR, the confidence interval and the p-value.
- OR = 1: no association between exposure and disease.
- OR > 1: the exposure is associated with a higher risk of being a case (risk factor). The larger the OR, the stronger the association.
- OR < 1: the exposure is associated with a lower risk of being a case (protective factor). An OR of 0.5 means the odds of exposure are half as high in cases as in controls.
If the confidence interval for the OR does not include the value 1, the association is statistically significant at the chosen level, which is equivalent to rejecting \(H_0\) with that p-value. Along with the p-value, it is always worth reporting the OR with its confidence interval, since statistical significance does not necessarily imply clinical or practical relevance.
As an additional check, this calculator also shows the Pearson chi-square for the 2×2 table. Squared, the Z statistic of the OR test coincides (approximately) with the Pearson chi-square, which allows cross-validating the results.
Worked example
Consider the 2×2 table with the default values: \(a = 40\) (exposed-cases), \(b = 60\) (unexposed-cases), \(c = 30\) (exposed-controls), \(d = 70\) (unexposed-controls).
The odds ratio is computed as:
\( \widehat{\mathrm{OR}} = \frac{a \cdot d}{b \cdot c} = \frac{40 \times 70}{60 \times 30} = \frac{2800}{1800} \approx 1.5556 \)
The natural logarithm of the OR and its standard error:
\( \ln\widehat{\mathrm{OR}} = \ln(1.5556) \approx 0.4418 \)
\( \mathrm{SE} = \sqrt{\frac{1}{40} + \frac{1}{60} + \frac{1}{30} + \frac{1}{70}} \approx \sqrt{0.0250 + 0.0167 + 0.0333 + 0.0143} = \sqrt{0.0893} \approx 0.2988 \)
The Z statistic:
\( Z = \frac{0.4418}{0.2988} \approx 1.479 \)
For a two-tailed test with \(\alpha = 0.05\), the critical value is \(z_{0.025} \approx 1.96\). Since \(|Z| = 1.479 < 1.96\), \(H_0\) is not rejected. The two-tailed p-value is \(p \approx 0.139 > 0.05\).
The 95% confidence interval for the OR is:
\( \mathrm{CI}_{95\%}(\mathrm{OR}) = \bigl(e^{0.4418 - 1.96 \times 0.2988},\; e^{0.4418 + 1.96 \times 0.2988}\bigr) \approx (0.867;\; 2.793) \)
Since the interval includes 1, the conclusion is consistent: there is not enough evidence of an association between the exposure and the disease at the 5% level.
How to interpret the result
Rejecting \(H_0\) (p-value < \(\alpha\)) indicates statistical evidence that the population odds ratio \(\text{OR}\) differs from 1, that is, that the exposure and the outcome are associated. An \(\widehat{\text{OR}} > 1\) suggests the exposure increases the odds of the event; an \(\widehat{\text{OR}} < 1\) suggests a protective effect. The magnitude of the OR is as important as the significance: an OR of 1.05 can be statistically significant with large samples but represent a trivial association in practice.
Not rejecting \(H_0\) (p-value ≥ \(\alpha\)) does not prove that there is no association; it only indicates that the data are compatible with \(\text{OR} = 1\) at the chosen level. Small studies have little power to detect moderate associations. A confidence interval for the OR that extends widely above and below 1 signals that the estimate is very imprecise. In epidemiology it is common to interpret the 95% CI this way: if it excludes the value 1, the association is significant at the 5% level; if it includes it, it is not.
The Z statistic is obtained from the logarithmic transformation of the OR (\(\ln\widehat{\text{OR}}\)), whose asymptotic distribution is normal under \(H_0\). In the chart, the green zone is the non-rejection region, the red zones are the critical regions and the amber line marks the observed statistic. Remember that the OR estimates the odds ratio, not the risk ratio (RR): when the prevalence of the event is high (>10%), OR and RR can differ considerably, and the RR may be more intuitive for communicating the results.
Frequently asked questions
- When should I use the odds ratio test instead of chi-square? The OR test is preferable when the goal is to quantify the magnitude of the association and obtain an interpretable confidence interval. Chi-square only indicates whether there is a significant association, but not how strong it is. Both are equivalent in the rejection decision (the squared Z statistic of the OR test coincides with the Pearson chi-square).
- What does an OR of 2 mean? An OR of 2 means the odds of being exposed are twice as high among cases as among controls. In practical terms, it means the exposure is associated with a higher probability of being a case, although it does not imply causation.
- What is the assumption behind this test? The test relies on the normal approximation of the log odds ratio. All expected frequencies in the 2×2 table should be at least 5. With smaller frequencies, use Fisher's exact test.
- What is the difference between odds ratio and relative risk? Relative risk (RR) directly compares disease probabilities between exposed and unexposed groups, and can only be computed in cohort studies. The OR compares odds and can be computed in both cohort and case-control studies. When the disease is rare, OR ≈ RR.
Reference: Odds ratio — Wikipedia