Method document
Sample size for a chi-square test on a 2 × 2 table
How many participants are needed in total for a chi-square test that two equal groups differ in the proportion with an outcome, planned through Cohen’s w on the noncentral chi-square distribution. Covers clustering and dropout.
https://statwisely.com/methods/proportions-chi-square/
When to use it
- A 2 × 2 comparison that will be analysed with Pearson’s chi-square test.
Not for
- Unequal groups, or when the analysis is a two-proportion z test with a continuity correction. Use the two-proportion test.
- Larger tables. Use the test of independence.
Notation
- Total participants, split equally between the groups
- Expected proportions in groups 1 and 2
- Cohen’s effect size for a contingency table
- Expected cell probabilities under the alternative and under independence
- Significance level: the chance of a false positive
- Power: the chance of detecting the effect if it is real
- Intracluster correlation coefficient (ICC)
- Average number of participants per cluster
- Coefficient of variation of cluster size
- Clusters per group
- Expected loss of whole clusters
- Expected dropout
Formulas
Cohen’s w for the table
With equal groups each row holds half the participants, so P = ½(p₁, 1 − p₁, p₂, 1 − p₂), and E replaces p₁ and p₂ by their average [1].
The smallest N with enough power
When the proportions differ, the statistic follows a noncentral chi-square distribution with one degree of freedom [1].
Clustering
When participants are recruited or randomised in clusters, observations within a cluster repeat information, and the sample is multiplied by the design effect. With equal clusters (CV = 0) this is 1 + (m − 1)ρ [2, 3].
Few clusters
Optional. A cluster trial is analysed on cluster-level summaries, so its critical values come from t on 2(C − 1) degrees of freedom rather than the normal distribution. With few clusters this costs participants; because C depends on the sample, it is iterated until it settles [4].
All adjustments together
The adjustments multiply, in this order, and the result is rounded up once. Any adjustment not used contributes a factor of 1.
Dropout
Applied last, to the participants actually recruited.
Clusters to recruit
Per group. Losing a whole cluster loses every participant in it, so an expected loss of clusters inflates the clusters recruited rather than the participants.
Parameters
Expected proportion in group 1
Values: Between 0 and 1
From routine data or previous studies.
Expected proportion in group 2
Values: Between 0 and 1, different from p₁
The proportion that would make the difference worth detecting.
Significance level
Values: Between 0 and 1; usually 0.05
The false-positive rate you accept. A smaller α, for example to allow for several primary outcomes, needs a larger sample.
Power
Values: Between 0 and 1; usually 0.80 or 0.90
The chance of a significant result if the assumed effect is real. Funders and ethics committees commonly expect at least 0.80.
Expected dropoutOptional
Values: 0% up to, but not including, 100%
The share of participants expected to provide no outcome, from comparable studies. Recruiting more restores the numbers, not the comparability of the groups: if dropout is related to the outcome, the estimate can still be biased.
Intracluster correlation (ICC)Optional
Values: From 0 to 1
For clustered designs only. Published ICCs for health outcomes in primary-care and community clusters are mostly small, often below 0.05 [5]; prefer an estimate from a comparable trial.
Average cluster sizeOptional
Values: At least 1
The average number of participants per cluster. Given with the ICC.
Variation in cluster sizeOptional
Values: 0 or more; 0 for equal clusters
The SD of cluster sizes divided by their mean. Unequal clusters cost power on their own account [3].
Expected loss of whole clustersOptional
Values: 0% up to, but not including, 100%
Clusters, such as practices or schools, expected to withdraw entirely.
Correction for few clustersOptional
Values: On or off
Worth applying when there are few clusters per group, roughly fewer than 15–20.
Assumptions
- The two groups are equal in size and independent; participants are independent apart from any clustering specified.
- Every cell is expected to hold at least 5 participants, so the chi-square approximation holds.
- With clustering: clusters are independent, with the same ICC throughout, and the analysis accounts for the clustering, for example with a mixed model or cluster-level summaries [2].
- Dropout is unrelated to the outcome; recruiting more participants restores the numbers but cannot remove bias.
Worked examples
Thirty against forty-five per cent
p₁ = 0.3 and p₂ = 0.45 give w = 0.155; α = 0.05, 80% power: N = 328, 328 / 2 = 164 per group, close to the 163 of the two-proportion test.
Sample size: 328
Open this example in the calculatorProtocol statement
To detect a difference between proportions of 30% and 45% with 80% power at a significance level of 0.05, using a chi-square test on a 2 × 2 table with two equal groups, the required sample size is 328 participants. Calculated with StatWisely (statwisely.com) using: N: solve P[χ²(df=1, λ=Nw²) > χ²_(1-α,1)] = 1-β. These are planning estimates; confirm the final design with a qualified statistician.
Allowing for dropout
Expecting 10% to provide no outcome: 328 / 0.9 = 364.4, so 365 are recruited.
Needed for analysis: 328 · To recruit: 365
Open this example in the calculatorProtocol statement
To detect a difference between proportions of 30% and 45% with 80% power at a significance level of 0.05, using a chi-square test on a 2 × 2 table with two equal groups, the required sample size is 328 participants. Allowing for 10% dropout, 365 participants should be recruited. Calculated with StatWisely (statwisely.com) using: N: solve P[χ²(df=1, λ=Nw²) > χ²_(1-α,1)] = 1-β. These are planning estimates; confirm the final design with a qualified statistician.
Validation
- Every worked example on this page is recomputed by the StatWisely engine whenever the software is built. If a number or formula here stopped matching the calculator, the release would be stopped until this document was corrected.
- An independent implementation in R recomputes this test every night and before each production release, and the results are compared with the engine’s.
How to cite
StatWisely. Sample size for a chi-square test on a 2 × 2 table. Method document, engine version 1.0.0, reviewed 2026-10-01. https://statwisely.com/methods/proportions-chi-square/
Cite the original references for the formulas your design uses as well.
References
- 1.Cohen J. Statistical Power Analysis for the Behavioral Sciences. 2nd ed. Hillsdale, NJ: Lawrence Erlbaum Associates; 1988.
- 2.Donner A, Klar N. Design and Analysis of Cluster Randomization Trials in Health Research. London: Arnold; 2000.
- 3.Eldridge SM, Ashby D, Kerry S. Sample size for cluster randomized trials: effect of coefficient of variation of cluster size and analysis method. International Journal of Epidemiology. 2006;35(5):1292–1300. doi:10.1093/ije/dyl129
- 4.Hayes RJ, Moulton LH. Cluster Randomised Trials. 2nd ed. Boca Raton: CRC Press; 2017.
- 5.Adams G, Gulliford MC, Ukoumunne OC, Eldridge S, Chinn S, Campbell MJ. Patterns of intra-cluster correlation from primary care research to inform study design and analysis. Journal of Clinical Epidemiology. 2004;57(8):785–794. doi:10.1016/j.jclinepi.2003.12.013