Calculate how many cases and controls you need for a case-control study to detect an odds ratio different from 1 with the desired power, fixing the controls:cases ratio.
Calculator
Enter the exposure prevalence in controls, the odds ratio to detect and the design parameters.
Explanation
In a case-control study the parameter of interest is not the difference of means but the odds ratio (OR): the ratio between the odds of exposure in cases and in controls. The OR is a fundamental measure of association in epidemiology, especially useful when the disease is rare, because it estimates the relative risk with good approximation in that scenario.
To calculate the sample size, the OR is converted into exposure proportions and Fleiss's formula for two independent proportions is applied. The key is that the OR implicitly defines the proportion of exposed cases (\(p_1\)) from the proportion in controls (\(p_0\)) and the desired OR. It also allows adjusting the controls-per-case ratio (r), which is useful when cases are scarce and controls are abundant.
Sample size formula
Let \(p_0\) be the proportion of exposed controls. The proportion in cases is obtained as:
\( p_1 = \frac{\text{OR}\cdot p_0}{1 + p_0\,(\text{OR}-1)} \)
With \(\bar{p} = (p_1 + r\,p_0)/(1+r)\) and allocation ratio \(r\) (controls per case):
\( n_{\text{cases}} = \frac{\left(Z_{\alpha/2}\sqrt{(1+1/r)\,\bar{p}(1-\bar{p})} + Z_\beta\sqrt{p_1(1-p_1)+p_0(1-p_0)/r}\right)^2}{(p_1-p_0)^2} \)
\( n_{\text{controls}} = r\cdot n_{\text{cases}} \)
- p₀: prevalence of exposure in the control population (or in the general population if the disease is rare).
- p₁: implicit prevalence of exposure in cases given the OR; computed automatically.
- r: number of controls per case. Increasing r raises power when cases are scarce, but with diminishing returns: going from r = 1 to r = 2 gains more than going from r = 3 to r = 4.
- p̄: weighted proportion of combined exposure in the sample.
Quick setup
- p₀: use population data or health registries. If unknown, 0.20–0.30 is common for many environmental and lifestyle risk factors.
- OR: the minimum relevant OR you want to detect. OR = 2 is a moderate effect in epidemiology; OR = 1.5 is small and requires large samples.
- r: increasing to 2–3 controls per case improves power when cases are scarce; going beyond 4 controls per case brings little additional gain in power.
- Protective OR (OR < 1): enter it directly; the calculator handles it correctly (p₁ < p₀ in that case).
Simple example
Study on smoking and lung cancer: exposure (smokers) in controls p₀ = 0.30, OR = 2.0, α = 0.05 two-tailed, power 0.80, 1:1 ratio. This implies p₁ = 0.462. You need approximately 141 cases and 141 controls (total ≈ 282).
Worked example
An epidemiology team designs a case-control study to investigate the association between smoking and lung cancer. The proportion of smokers among the controls (healthy people with similar characteristics) is estimated at \(p_2 = 0.30\). They want to detect an odds ratio of at least \(\text{OR} = 2.5\) with \(\alpha = 0.05\) two-tailed and 80% power.
The first step is to convert the OR into the expected proportion of exposed cases:
\( p_1 = \frac{\text{OR} \times p_2}{1 + p_2 \times (\text{OR} - 1)} = \frac{2.5 \times 0.30}{1 + 0.30 \times 1.5} = \frac{0.75}{1.45} \approx 0.517 \)
With \(z_{\alpha/2} = 1.960\) and \(z_{\beta} = 0.842\), Fleiss's formula for two independent proportions is applied:
\( n = \frac{\bigl(z_{\alpha/2}\sqrt{2\bar{p}(1-\bar{p})} + z_{\beta}\sqrt{p_1(1-p_1)+p_2(1-p_2)}\bigr)^2}{(p_1-p_2)^2} \)
With \(\bar{p} = (0.517+0.30)/2 = 0.4085\): the first term is \(1.960\times\sqrt{2\times0.4085\times0.5915} = 1.960\times0.6951 = 1.362\); the second, \(0.842\times\sqrt{0.517\times0.483+0.30\times0.70} = 0.842\times\sqrt{0.4597} = 0.842\times0.6780 = 0.571\). The difference between proportions is \(p_1 - p_2 = 0.217\).
\( n = \frac{(1.362 + 0.571)^2}{(0.217)^2} = \frac{(1.933)^2}{0.04709} = \frac{3.736}{0.04709} \approx 79.3 \rightarrow 80 \)
Rounding up to the nearest integer, 80 cases and 80 controls (160 total participants) are needed to achieve 80% power.
Model assumptions
- Independent sampling: cases and controls are selected independently, without matching (for matched designs, use the McNemar method).
- Binary exposure: the risk factor is treated as exposed/unexposed. Other approaches are needed for polytomous or continuous exposures.
- Stable p₀: the exposure prevalence in controls must be representative of the source population of the cases.
- Constant OR: the formula assumes a homogeneous OR; it does not account for interaction or residual confounding.
- Rare disease: interpreting the OR as an approximation to the relative risk is valid when incidence is low (< 10%). With common diseases, the OR overestimates the RR.
Common uses
- Studies on risk factors for rare diseases (uncommon cancers, autoimmune diseases).
- Pharmacoepidemiology and surveillance of adverse drug effects.
- Investigation of infectious outbreaks or occupational exposures.
- Case-control studies nested within cohorts.
How to interpret the result
The value \(n\) is the minimum size per group (cases and controls, or exposed and unexposed) needed to detect the specified odds ratio with the indicated power and \(\alpha\) level. The total number of participants to recruit is \(2n\) in a balanced design. Always round up and add a margin for losses: divide \(n\) by \((1 - \text{dropout rate})\) per group. If the design is unbalanced (a different number of cases and controls in a \(k\!:\!1\) ratio), the case group needs \(n\) and the control group \(k \cdot n\); increasing \(k\) beyond 4:1 rarely reduces the total \(n\) substantially.
The OR is the parameter of interest, but the sensitivity of \(n\) also depends on the baseline probability \(p_0\) (proportion of events in the reference group). A given OR requires more subjects when \(p_0\) is extreme (close to 0 or 1) than when it is close to 0.5. Perform a sensitivity analysis by varying \(p_0\) by ±0.05 and the OR over a reasonable range (\(\pm 0.2\) on the natural scale) to assess the robustness of the plan. Keep in mind that the OR is a relative measure of association; for it to have clinical interpretation, it is useful to translate it into the relative risk (RR) or the risk difference (RD) when the baseline prevalence is known.
If the computed \(n\) is not feasible, consider whether the minimum detectable OR can be increased or whether the power can be reduced to 80%. In case-control studies, the controls-per-case ratio can also be increased (e.g., 2:1 or 3:1) to reduce the number of cases needed when they are scarce. Once you have collected the data, estimate the OR and its CI with the odds ratio calculator; if the goal was to estimate the OR with a given precision rather than testing it, use the sample size calculator for the OR confidence interval.
External references
- Odds ratio (Wikipedia) — definition, interpretation and relationship with relative risk
- Case–control study (Wikipedia) — design, advantages, limitations and common biases
- Sample size determination (Wikipedia)
- Fleiss, J. L., Levin, B., & Paik, M. C. (2003). Statistical Methods for Rates and Proportions (3rd ed.). Wiley. — source of the two-proportions formula implemented here.
Frequently asked questions
- What is the odds ratio? The ratio of the odds of exposure between cases and controls: OR = [p₁/(1−p₁)] / [p₀/(1−p₀)]. OR = 1 implies no association; OR > 1, the factor is a risk factor; OR < 1, it is protective.
- Why not use the relative risk (RR) directly? In case-control studies, the researcher chooses how many cases and controls to include, so the actual incidence cannot be estimated, and therefore neither can the RR. The OR can be estimated directly and approximates the RR well when the disease is rare (< 10%).
- How do I obtain p₀? From prevalence studies, national health surveys or registries of exposure in the reference population. Small errors in p₀ can substantially affect the computed n.
- How many controls per case? Increasing r from 1 to 2 or 3 substantially reduces the number of cases needed when cases are scarce; going from r = 3 to r = 4 adds little. The practical rule is r ≤ 4.
- Is the sample size exact? No; it depends on the assumptions (p₀, actual OR) and is rounded up to the nearest integer. Add a 10–20% margin for expected losses.