Skip to main content

    Method document

    Sample size for comparing two proportions

    How many participants are needed in each of two independent groups to show that the proportions with an outcome differ, with chosen significance and power. The usual design for a trial with a binary outcome. Covers the continuity correction, clustering, non-adherence and dropout.

    Engine version 1.0.0 · Reviewed 1 October 2026

    https://statwisely.com/methods/proportions-two/

    When to use it

    • A randomised trial or comparative study with two independent groups and a yes/no outcome.

    Not for

    • The same people measured twice, or matched pairs. Use McNemar’s test.
    • Showing that a new treatment is not worse. Use non-inferiority for proportions.

    Notation

    nn
    Participants per group
    p1, p2p_1,\ p_2
    Expected proportions in groups 1 and 2
    pˉ\bar{p}
    Average of the two proportions, (p₁ + p₂) / 2
    δ\delta
    Difference between the proportions, |p₁ − p₂|
    α\alpha
    Significance level: the chance of a false positive
    1−β1-\beta
    Power: the chance of detecting the effect if it is real
    ρ\rho
    Intracluster correlation coefficient (ICC)
    mm
    Average number of participants per cluster
    CV\mathrm{CV}
    Coefficient of variation of cluster size
    CC
    Clusters per group
    ℓ\ell
    Expected loss of whole clusters
    dt, dcd_t,\ d_c
    Share of the treatment arm not taking treatment, and of the control arm receiving it
    qq
    Expected dropout, overall or for each arm (q₁, q₂)

    Formulas

    Fleiss’s normal approximation

    n=⌈[z1−α/22pˉ(1−pˉ)+z1−βp1(1−p1)+p2(1−p2)]2δ2⌉n = \left\lceil \frac{\left[z_{1-\alpha/2}\sqrt{2\bar{p}(1-\bar{p})} + z_{1-\beta}\sqrt{p_1(1-p_1) + p_2(1-p_2)}\right]^{2}}{\delta^{2}} \right\rceil

    The null variance uses the pooled proportion p̄, as the test does; the alternative uses each group’s own [1]. The calculator uses equal groups and a two-sided test.

    With the continuity correction

    ncc=⌈n4(1+1+4n δ)2⌉n_{cc} = \left\lceil \frac{n}{4}\left(1 + \sqrt{1 + \frac{4}{n\,\delta}}\right)^{2} \right\rceil

    Optional, and on by default. It matches the analysis when that will be a continuity-corrected chi-square or Fisher’s exact test, and adds participants [2, 3].

    Clustering

    DE=1+[(CV2+1) m−1]ρ\mathrm{DE} = 1 + \left[(\mathrm{CV}^{2} + 1)\,m - 1\right]\rho

    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)ρ [4, 5].

    Few clusters

    Ft=(t2(C−1), 1−α/τ+t2(C−1), 1−βz1−α/τ+z1−β)2F_t = \left(\frac{t_{2(C-1),\,1-\alpha/\tau} + t_{2(C-1),\,1-\beta}}{z_{1-\alpha/\tau} + z_{1-\beta}}\right)^{2}

    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 [6].

    Non-adherence and crossover

    n′=n(1−dt−dc)2n' = \frac{n}{(1 - d_t - d_c)^{2}}

    An intention-to-treat analysis keeps everyone in the arm they were allocated to, so participants who do not receive their allocated treatment dilute the difference. Lachin’s correction restores the power [7].

    All adjustments together

    nadj=⌈nDE  Ft 1(1−dt−dc)2⌉n_{\text{adj}} = \left\lceil n \mathrm{DE}\;F_t\,\frac{1}{(1 - d_t - d_c)^{2}} \right\rceil

    The adjustments multiply, in this order, and the result is rounded up once. Any adjustment not used contributes a factor of 1.

    Dropout

    nrecruit,i=⌈nadj1−qi⌉,i=1,2n_{\text{recruit},i} = \left\lceil \frac{n_{\text{adj}}}{1 - q_i} \right\rceil, \qquad i = 1, 2

    Applied last, to the participants actually recruited. The rate can differ between the arms; when it does not, q₁ = q₂ = q.

    Clusters to recruit

    C=⌈nrecruitm⌉,Crecruit=⌈C1−ℓ⌉C = \left\lceil \frac{n_{\text{recruit}}}{m} \right\rceil, \qquad C_{\text{recruit}} = \left\lceil \frac{C}{1 - \ell} \right\rceil

    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 1p1p_1

    Values: Between 0 and 1

    Usually the control group, from routine data or previous studies.

    Expected proportion in group 2p2p_2

    Values: Between 0 and 1, different from p₁

    The proportion that would make the difference worth detecting; not an optimistic hope.

    Continuity correctionccccOptional

    Values: On or off

    Turn it off only if the analysis will be an uncorrected chi-square or z test.

    Significance levelα\alpha

    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.

    Power1−β1-\beta

    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 dropoutqqOptional

    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.

    Dropout in each armq1, q2q_1,\ q_2Optional

    Values: 0% up to, but not including, 100%, for each arm

    When dropout is expected to differ between arms, for example higher with an unpleasant treatment. Each arm is then inflated by its own rate.

    Intracluster correlation (ICC)ρ\rhoOptional

    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 [8]; prefer an estimate from a comparable trial.

    Average cluster sizemmOptional

    Values: At least 1

    The average number of participants per cluster. Given with the ICC.

    Variation in cluster sizeCV\mathrm{CV}Optional

    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 [5].

    Expected loss of whole clustersℓ\ellOptional

    Values: 0% up to, but not including, 100%

    Clusters, such as practices or schools, expected to withdraw entirely.

    Correction for few clustersFtF_tOptional

    Values: On or off

    Worth applying when there are few clusters per group, roughly fewer than 15–20.

    Non-adherence and crossoverdt, dcd_t,\ d_cOptional

    Values: 0% up to, but not including, 100%; the two together below 100%

    The share of the treatment arm expected not to take it, and of the control arm expected to receive it, from comparable trials.

    Assumptions

    • The groups are independent and equal in size, and participants are independent apart from any clustering specified.
    • Each group expects comfortably more than 10 participants with and without the outcome, so the normal 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 [4].
    • Dropout is unrelated to the outcome; recruiting more participants restores the numbers but cannot remove bias.
    • Non-adherence is corrected for an intention-to-treat analysis, with treatment received having its full effect and no effect otherwise.

    Worked examples

    Thirty against forty-five per cent

    p₁ = 0.3, p₂ = 0.45, so p̄ = 0.375 and δ = 0.15; without the continuity correction: n = [1.96 × 0.685 + 0.8416 × 0.676]² / 0.15² = 162.4, rounded up to 163 per group.

    Group 1: 163 · Group 2: 163 · Total: 326

    Protocol statement

    To detect a difference between proportions of 30% and 45% with 80% power at a two-sided significance level of 0.05, using a comparison of two proportions, the required sample size is 163 per group (326 in total). Calculated with StatWisely (statwisely.com) using: Fleiss normal approximation; optional Casagrande-Pike-Smith continuity correction. These are planning estimates; confirm the final design with a qualified statistician.

    Open this example in the calculator

    With the continuity correction

    The same comparison corrected for continuity: 176 per group.

    Group 1: 176 · Group 2: 176 · Total: 352

    Open this example in the calculator

    Allowing for non-adherence

    With 10% of the treatment arm not taking it and 5% of controls receiving it: 163 / 0.85² = 225.6, so 226 per group.

    Group 1: 226 · Group 2: 226 · Total: 452

    Protocol statement

    To detect a difference between proportions of 30% and 45% with 80% power at a two-sided significance level of 0.05, using a comparison of two proportions, the test itself needs 163 per group. With non-adherence of 10% in the treatment arm and crossover of 5% in the control arm, the required sample size is 226 per group (452 in total). Calculated with StatWisely (statwisely.com) using: Fleiss normal approximation; optional Casagrande-Pike-Smith continuity correction; non-adherence: n / (1 - d_t - d_c)^2. These are planning estimates; confirm the final design with a qualified statistician.

    Open this example in the calculator

    A cluster-randomised trial

    Clusters of 20 with ICC 0.02: DE = 1.38, so 163 × 1.38 = 224.9, rounded up to 225 per group, in 12 clusters per group.

    Group 1: 225 · Group 2: 225 · Total: 450

    Protocol statement

    To detect a difference between proportions of 30% and 45% with 80% power at a two-sided significance level of 0.05, using a comparison of two proportions, the test itself needs 163 per group. With clustering (ICC 0.02, an average of 20 per cluster; design effect 1.38), the required sample size is 225 per group (450 in total), in 12 clusters per group. Calculated with StatWisely (statwisely.com) using: Fleiss normal approximation; optional Casagrande-Pike-Smith continuity correction; clustered: n x DE, DE = 1 + (m-1)ρ. These are planning estimates; confirm the final design with a qualified statistician.

    Open this example in the calculator

    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 comparing two proportions. Method document, engine version 1.0.0, reviewed 2026-10-01. https://statwisely.com/methods/proportions-two/

    Cite the original references for the formulas your design uses as well.

    References

    1. 1.Fleiss JL, Levin B, Paik MC. Statistical Methods for Rates and Proportions. 3rd ed. Hoboken, NJ: John Wiley & Sons; 2003.
    2. 2.Casagrande JT, Pike MC, Smith PG. An improved approximate formula for calculating sample sizes for comparing two binomial distributions. Biometrics. 1978;34(3):483–486.
    3. 3.Fleiss JL, Tytun A, Ury HK. A simple approximation for calculating sample sizes for comparing independent proportions. Biometrics. 1980;36(2):343–346.
    4. 4.Donner A, Klar N. Design and Analysis of Cluster Randomization Trials in Health Research. London: Arnold; 2000.
    5. 5.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
    6. 6.Hayes RJ, Moulton LH. Cluster Randomised Trials. 2nd ed. Boca Raton: CRC Press; 2017.
    7. 7.Lachin JM. Biostatistical Methods: The Assessment of Relative Risks. New York: John Wiley & Sons; 2000.
    8. 8.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