Method document
Sample size for a stepped-wedge trial: binary outcome
How many clusters, or how many measurements per cluster, a stepped-wedge cluster-randomised trial with a yes/no outcome needs. Covers fixed numbers of clusters and dropout.
https://statwisely.com/methods/stepped-wedge-proportions/
When to use it
- A rollout evaluated on a binary outcome, such as the share of patients receiving recommended care.
Not for
- Settings where a parallel cluster trial is feasible.
Notation
- Number of clusters
- Number of steps; there are S + 1 periods
- Measurements per cluster in each period
- Intracluster correlation coefficient (ICC)
- Total variance of the outcome
- Treatment effect: a difference in means or proportions
- 1 if cluster i is on the intervention in period j, else 0
- Proportions under control and intervention; σ² = p̄(1 − p̄)
- Significance level: the chance of a false positive
- Power: the chance of detecting the effect if it is real
- Expected dropout
Formulas
Variance of the treatment effect
The Hussey and Hughes model: cluster-period means share a cluster effect, and every period has its own term so the secular trend is estimated rather than assumed away [1]. The calculator solves this generalised least squares problem directly.
Clusters, or cluster size, with enough power
Clusters are added a sequence at a time, one cluster per step, until the power is reached; or, with the clusters fixed, the measurements per cluster-period are increased instead. The answer is reported as measurements, I × (S + 1) × m.
Dropout
Applied last, to the participants actually recruited.
Parameters
Proportion under control
Values: Between 0 and 1
Before the intervention is rolled out.
Proportion under the intervention
Values: Between 0 and 1, different from p₁
The variance used is that of the average proportion.
Number of steps
Values: A whole number of at least 1
Times at which a group of clusters crosses to the intervention.
Measurements per cluster-period
Values: Above 0
New participants measured in each cluster in each period.
What to solve for
Values: Clusters, or cluster size for a fixed number of clusters
Solve for the cluster size when the clusters are fixed, such as every hospital in a region.
Number of clustersOptional
Values: A multiple of the number of steps
When solving for cluster size; it must divide evenly between the steps.
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.
Assumptions
- A cross-sectional design: different people are measured in each period. A cohort followed throughout needs a model of repeated measurements on each participant.
- The intervention effect is immediate and constant once a cluster crosses over, and the secular trend is the same in all clusters [2].
- The calculation uses the normal approximation, which can overstate power when there are few clusters; with fewer than about 10–15, plan the analysis with a small-sample correction and allow for it here.
- The binary outcome is handled with the variance of the average proportion, a linear approximation.
- Dropout is unrelated to the outcome; recruiting more participants restores the numbers but cannot remove bias.
Worked examples
30% to 45%
0.3 rising to 0.45, 4 steps, 20 per cluster-period, ICC 0.05: 12 clusters, 1200 measurements.
Sample size: 1200
Open this example in the calculatorProtocol statement
To detect a change from 30% to 45% with 80% power at a two-sided significance level of 0.05, using a stepped-wedge cluster-randomised trial with 4 steps, and assuming an intracluster correlation of 0.05, the required sample size is 12 clusters over 5 periods, with 20 measurements per cluster in each period, 1200 measurements in total. Calculated with StatWisely (statwisely.com) using: clusters: solve GLS Var(θ̂) from (X'V⁻¹X)⁻¹ with one term per period; V=σ_c²J+(σ_e²/m)I. These are planning estimates; confirm the final design with a qualified statistician.
Allowing for missing outcomes
Expecting 10% of measurements to be missing: 1334 to collect.
Needed for analysis: 1200 · To recruit: 1334
Open this example in the calculatorProtocol statement
To detect a change from 30% to 45% with 80% power at a two-sided significance level of 0.05, using a stepped-wedge cluster-randomised trial with 4 steps, and assuming an intracluster correlation of 0.05, the required sample size is 12 clusters over 5 periods, with 20 measurements per cluster in each period, 1200 measurements in total. Allowing for 10% missing measurements, 1334 measurements should be collected. Calculated with StatWisely (statwisely.com) using: clusters: solve GLS Var(θ̂) from (X'V⁻¹X)⁻¹ with one term per period; V=σ_c²J+(σ_e²/m)I. 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 stepped-wedge trial: binary outcome. Method document, engine version 1.0.0, reviewed 2026-10-01. https://statwisely.com/methods/stepped-wedge-proportions/
Cite the original references for the formulas your design uses as well.
References
- 1.Hussey MA, Hughes JP. Design and analysis of stepped wedge cluster randomized trials. Contemporary Clinical Trials. 2007;28(2):182–191.
- 2.Hemming K, Haines TP, Chilton PJ, Girling AJ, Lilford RJ. The stepped wedge cluster randomised trial: rationale, design, analysis, and reporting. BMJ. 2015;350:h391.
- 3.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