Estimate how many observations per group you need to obtain a confidence interval for the odds ratio with the target width on the log scale. This is a precision-based approach.
Calculator
Enter the expected OR, the event proportion in the reference group, and the desired precision on the log(OR) scale.
Explanation
The odds ratio (OR) measures the association between an exposure and an event in a 2×2 table. To plan how many subjects are needed to estimate it with a given precision, the calculation is done on the logarithmic scale, because \(\log(\widehat{OR})\) is approximately normally distributed with a standard error that depends on the counts in each cell.
The inputs are: the OR expected to be found, the event proportion in the reference group (\(p_2\)), and the desired precision expressed as the half-width of the CI on the \(\log(OR)\) scale. From \(p_2\) and OR, the calculator derives \(p_1\) (the event proportion in the exposed group). With both proportions it calculates the minimum number of subjects per group so that the CI has the specified width.
The formula assumes balanced allocation (the same number of subjects in each group) and sufficient counts in all four cells for the normal approximation to be valid.
Formulas
Given the expected OR and \(p_2\), the event proportion in the exposed group is obtained by inverting the definition of the odds ratio:
\( p_1 = \frac{OR \cdot p_2}{1 + (OR - 1)\cdot p_2} \)
The standard error of \(\log(\widehat{OR})\) for a table with \(n\) observations per group is:
\( SE\!\left[\log(\widehat{OR})\right] = \frac{1}{\sqrt{n}} \cdot \sqrt{\frac{1}{p_1(1-p_1)} + \frac{1}{p_2(1-p_2)}} \)
Imposing that the CI margin equal \(E_{\log} = Z \cdot SE\), we solve for \(n\):
\( n = \frac{Z^2 \cdot \left[\dfrac{1}{p_1(1-p_1)} + \dfrac{1}{p_2(1-p_2)}\right]}{E_{\log}^2} \)
- n: minimum number of observations per group (total N = 2n).
- Z: normal quantile — 1.645 (90%), 1.960 (95%), 2.576 (99%).
- \(E_{\log}\): half-width of the CI on the \(\log(OR)\) scale. The CI for OR falls between \(OR \cdot e^{-E_{\log}}\) and \(OR \cdot e^{+E_{\log}}\).
How to interpret E_log
The half-width \(E_{\log}\) determines how far each CI limit can be from the estimated OR on the multiplicative scale. With OR = 2 and \(E_{\log} = 0.5\), the CI runs from \(2 \cdot e^{-0.5} \approx 1.21\) to \(2 \cdot e^{+0.5} \approx 3.30\). A useful reference: \(E_{\log} = \log(2) \approx 0.693\) produces a CI where the upper limit is exactly double the lower limit.
Quick setup
- Expected OR: based on prior studies or on the smallest association you consider relevant.
- p₂ (reference group): frequency of the event in the unexposed population. It is the parameter with the largest influence, together with OR.
- E_log: half-width on the log scale. Values between 0.3 and 0.7 are common. Smaller E_log → narrower CI → more subjects.
- Confidence level: 95% is the standard; use 99% for regulatory or high-impact decisions.
- Expected losses: divide n per group by (1 − dropout rate).
Worked example
An epidemiologist wants to estimate the odds ratio of a disease in exposed vs. unexposed subjects to a risk factor. According to the literature, the proportion of the disease among the unexposed is \(p_2 = 0.20\) and the expected OR is 2.0. A 95% CI with a half-width of \(E_{\log} = 0.5\) on the log scale is desired.
First we derive \(p_1\):
\( p_1 = \frac{2.0 \times 0.20}{1 + (2.0 - 1) \times 0.20} = \frac{0.40}{1.20} = 0.333 \)
Now we calculate n:
\( n = \frac{(1.960)^2 \cdot \left[\dfrac{1}{0.333 \times 0.667} + \dfrac{1}{0.20 \times 0.80}\right]}{(0.5)^2} = \frac{3.8416 \times (4.502 + 6.25)}{0.25} = \frac{41.30}{0.25} = 165.2 \rightarrow n = 166 \text{ per group} \)
We need 166 subjects per group (332 in total). The resulting CI for OR will run from approximately \(2.0 \cdot e^{-0.5} \approx 1.21\) to \(2.0 \cdot e^{+0.5} \approx 3.30\), which corresponds to a U/L ratio = e ≈ 2.72.
Sensitivity analysis: if the true OR were 3.0 instead of 2.0, n would decrease because the proportions would be farther apart and the OR would be easier to estimate precisely. It's always advisable to recalculate for a plausible range of OR.
Model assumptions
- Design with two equally sized groups (1:1 allocation between exposed and unexposed).
- Sufficient counts in all four cells (\(n \cdot p_i\) and \(n \cdot (1-p_i)\) ≥ 5 in both groups) for the normal approximation to \(\log(OR)\) to be valid.
- The values of p₂ and OR are reliably estimated; uncertainty in these assumptions propagates to the sample size.
- For case-control studies with a cases:controls ratio ≠ 1:1, the formula must be adjusted.
Common uses
- Design of cohort or cross-sectional studies where the main association measure is the OR.
- Planning logistic regression analyses when the OR needs to be characterized with sufficient precision.
- Studies of risk factor prevalence in analytic epidemiology.
How to interpret the result
The value \(n\) is the minimum sample size per group so that the confidence interval of the odds ratio on the log scale has a maximum half-width of \(E_{\log}\) at the specified confidence level. In terms of the natural OR, this means the ratio between the upper and lower limits of the CI will be at most \(e^{2E_{\log}}\). Always round \(n\) up. Add the margin for losses by dividing \(n\) by \((1 - \text{dropout rate})\) to get the recruitment number per group; the total to recruit is \(2n\) adjusted.
The most influential parameters are \(p_2\) (the reference proportion) and the specified OR, since together they determine \(p_1 = \text{OR} \times p_2 / (1 + p_2(\text{OR} - 1))\) and the variance of the estimator. Run a sensitivity analysis varying \(p_2\) by ±0.05 and the OR over a reasonable range: when \(p_2\) is very small or very large, the variance of \(\log(\widehat{\text{OR}})\) is larger and more subjects are needed. Likewise, an OR closer to 1 requires more subjects to estimate the log-OR with the same absolute precision. Keep in mind that \(E_{\log}\) is the precision on the log scale; if you need to interpret the result on the natural scale, note that \(E_{\log} = 0.3\) corresponds to a multiplicative factor of \(e^{0.3} \approx 1.35\) on the upper limit relative to the center of the CI.
This approach (CI) differs from hypothesis testing: here the goal is to estimate the OR with a given precision, not to decide whether it differs from 1. If what you need is to detect an OR \(\neq 1\) with a certain power, use the sample size calculator for testing the OR. Once the data are collected, calculate the OR and its CI with the odds ratio calculator and interpret the CI limits in the clinical or epidemiological context of the study.
References and further reading
- Woolf, B. (1955). On estimating the relation between blood group and disease, Annals of Human Genetics, 19, 251–253.
- Kelsey, J. L., Whittemore, A. S., Evans, A. S., & Thompson, W. D. (1996). Methods in Observational Epidemiology (2nd ed.). Oxford University Press.
- Schlesselman, J. J. (1982). Case-Control Studies: Design, Conduct, Analysis. Oxford University Press.
Frequently asked questions
- What E_log is reasonable? It depends on how much imprecision is tolerable. E_log=0.5 gives a CI that varies by a factor of e≈2.7 between limits; E_log=0.3 reduces it to e^(0.6)≈1.82. Smaller E_log requires more sample.
- Why is the OR estimated on the log scale? Because log(OR) has an approximately normal sampling distribution and a stable standard error, while OR is positive and skewed.
- Does this calculation work for case-control studies? With caution. In case-control studies the logic is different (the groups are cases and controls, not exposed and unexposed), although the formula can be used as an approximation when the event is not rare.