Tutorials › Biostatistics › Stepped-Wedge Trial Design Explained

Cluster Randomized & Adaptive Study Design

Stepped-Wedge Trial Design Explained

A practical guide to stepped-wedge cluster randomized trials, including clusters and periods, randomized rollout sequences, treatment effects, intracluster correlation, sample size and power, analysis models, secular trends, and a complete worked example.

Advanced 18 min read

What You'll Learn

  • What a stepped-wedge cluster randomized trial is and why it is called a “wedge”
  • How clusters, periods, sequences, and treatment rollout are structured
  • Why secular time trends are central to stepped-wedge analysis
  • How intracluster correlation affects precision and sample size
  • How a stepped-wedge trial can be analyzed with mixed-effects or GEE models
  • How to plan a stepped-wedge trial and evaluate its operating characteristics

Introduction

Many interventions in clinical and health-services research are not delivered to individual patients independently. Instead, the intervention may be implemented at the level of a hospital, clinic, practice, ward, community, school, or other naturally occurring group.

When the intervention is introduced at the cluster level, individual randomization may be impractical or may create substantial contamination. A cluster randomized trial solves this problem by randomizing groups rather than individual participants.

A stepped-wedge cluster randomized trial goes one step further. Rather than assigning some clusters permanently to control and others permanently to intervention, all clusters eventually receive the intervention, but they receive it at different prespecified times.

Key idea: In a stepped-wedge trial, clusters are randomized to different sequences of intervention rollout. At each successive period, another group of clusters crosses from control to intervention until all clusters are exposed.

The design therefore combines:

  • Cluster randomization
  • Repeated observations over time
  • Sequential intervention rollout
  • Within-cluster correlation
  • Time-period effects

Why Is It Called a "Stepped Wedge"?

Imagine four groups of clusters. At the beginning, all clusters are under control. Then, at each transition, another group switches to the intervention. The treatment assignment can be represented as:

Sequence Period 1 Period 2 Period 3 Period 4 Period 5
A Control Intervention Intervention Intervention Intervention
B Control Control Intervention Intervention Intervention
C Control Control Control Intervention Intervention
D Control Control Control Control Intervention

If the treatment indicators are plotted over time, the intervention region forms a shape resembling a staircase or wedge.

The defining feature: The intervention is introduced sequentially, but the order of introduction is determined by randomization rather than investigator preference.

The Core Structure

A stepped-wedge trial has several levels of organization.

Level Meaning
Individual The patient or participant providing an outcome
Cluster The unit randomized to a rollout sequence
Sequence The intervention timing assigned to a group of clusters
Period A calendar or study interval during which outcomes are measured
Transition The point at which a sequence changes from control to intervention

The distinction between these levels is essential. The individual is usually not randomized. The cluster is randomized to a sequence, and that sequence determines when the cluster receives the intervention.

Cluster Randomization

Suppose a study includes 20 hospitals. The investigators might randomize the hospitals to four rollout sequences:

$$ 20\text{ hospitals} \longrightarrow 4\text{ sequences} $$

with five hospitals assigned to each sequence.

The randomization might therefore look like:

Sequence Number of Clusters Intervention Introduction
A 5 Period 2
B 5 Period 3
C 5 Period 4
D 5 Period 5

The sequence assignment is the randomized component of the study.

Why Randomize the Rollout Order?

The major statistical concern in a stepped-wedge study is that outcomes can change over calendar time even if the intervention has no effect.

For example, suppose a hospital's infection rate is:

  • 12% in Period 1
  • 11% in Period 2
  • 10% in Period 3
  • 9% in Period 4
  • 8% in Period 5

The improvement might be caused by:

  • Seasonal effects
  • Changes in clinical practice
  • Staffing changes
  • Learning over calendar time
  • Changes in patient case mix
  • Other secular trends

If the intervention were introduced at exactly the same time in every cluster, its effect could be difficult to distinguish from the time trend.

Randomized rollout solves an important problem: Because clusters switch at different randomized times, the analysis can compare intervention and control observations occurring during the same calendar periods.

The Central Statistical Model

Let:

  • \(Y_{ijk}\) = outcome for individual \(k\) in cluster \(i\) during period \(j\)
  • \(A_{ij}\) = intervention indicator for cluster \(i\) during period \(j\)
  • \(\beta\) = intervention effect
  • \(\gamma_j\) = fixed effect of period \(j\)
  • \(b_i\) = cluster-specific random effect

For a continuous outcome, a basic linear mixed model can be written:

$$ Y_{ijk} = \mu + \beta A_{ij} + \gamma_j + b_i + \epsilon_{ijk} $$

where:

$$ b_i\sim N(0,\sigma_b^2) $$

and:

$$ \epsilon_{ijk}\sim N(0,\sigma_e^2) $$

The treatment effect is represented by \(\beta\), while the period effects \(\gamma_j\) account for secular changes over calendar time.

For Binary Outcomes

Many clinical trial endpoints are binary. For example:

  • Hospital readmission: yes/no
  • Infection: yes/no
  • Clinical response: yes/no
  • Adverse event: yes/no
  • Successful treatment: yes/no

A generalized linear mixed model can use a logit link:

$$ \operatorname{logit}\{P(Y_{ijk}=1)\} = \mu + \beta A_{ij} + \gamma_j + b_i $$

The odds ratio associated with the intervention is:

$$ OR=e^\beta $$

For example, if:

$$ \beta=\log(0.70) $$

then:

$$ OR=0.70 $$

which represents 30% lower odds of the outcome under the intervention, conditional on the model.

Continuous Outcomes

For a continuous endpoint, such as blood pressure, length of stay, or a quality-of-life score, the treatment effect may be interpreted directly as an adjusted mean difference.

For example:

$$ \beta=-4.2 $$

would indicate an estimated four-unit reduction in the outcome associated with the intervention, assuming the model is parameterized in that direction.

What Makes the Design Different from an Ordinary Cluster Trial?

In a conventional parallel cluster randomized trial:

  • Some clusters remain control.
  • Some clusters remain intervention.
  • The assignment usually does not change during follow-up.

In a stepped-wedge trial:

  • All clusters begin in control.
  • Clusters cross over to intervention at different times.
  • All clusters eventually receive the intervention.
  • The timing of the crossover is randomized.
Feature Parallel Cluster Trial Stepped-Wedge Trial
Randomization unit Cluster Cluster
All clusters eventually receive intervention? Usually no Yes
Multiple periods Possible Fundamental to design
Rollout timing randomized? Usually no Yes
Secular time effects Important Especially important
Within-cluster correlation Important Important

The Most Important Design Assumption

A stepped-wedge design requires a credible interpretation of the intervention effect after accounting for calendar time.

If the outcome changes dramatically over time for reasons unrelated to the intervention, the analysis must adequately model those time effects.

This is why period indicators are typically included in the primary analysis.

Do not analyze a stepped-wedge trial as though time did not exist. The intervention indicator and period indicators are both fundamental parts of the design matrix.

A Complete Worked Example

Consider a multicenter clinical implementation study evaluating a new infection-prevention program. The intervention is implemented at the hospital level, so individual randomization would be difficult and could produce substantial contamination.

The primary endpoint is whether an eligible patient develops the target infection during the predefined observation window.

Suppose the investigators plan:

Design Parameter Planning Value
Clusters 20 hospitals
Sequences 4
Periods 5
Clusters per sequence 5
Average patients per cluster-period 25
Total observations 2,500
Primary endpoint Binary infection outcome

The total number of individual outcome observations is:

$$ N = 20\times5\times25 = 2500 $$

This is not the same thing as having 2,500 independently randomized participants. The effective amount of information is reduced by correlation within clusters.

Step 1: Define the Rollout Schedule

The four sequences are:

Sequence P1 P2 P3 P4 P5
A C I I I I
B C C I I I
C C C C I I
D C C C C I

where:

  • C = control
  • I = intervention

All hospitals therefore begin in the control condition. At the end of the rollout, all hospitals receive the intervention.

Step 2: Randomize Hospitals to Sequences

The 20 hospitals are randomly assigned to the four sequences.

A balanced allocation might be:

Sequence Hospitals
A 5
B 5
C 5
D 5

The actual hospital identities assigned to each sequence should be determined by the prespecified randomization procedure.

Randomization protects the comparison. The objective is not merely to spread hospitals across sequences. The assignment mechanism should prevent investigators from choosing rollout timing based on anticipated outcomes.

Step 3: Identify the Treatment Indicator

For each cluster-period, define:

$$ A_{ij} = \begin{cases} 0,&\text{before intervention rollout}\\ 1,&\text{after intervention rollout} \end{cases} $$

For Sequence A:

$$ A_A=(0,1,1,1,1) $$

For Sequence B:

$$ A_B=(0,0,1,1,1) $$

For Sequence C:

$$ A_C=(0,0,0,1,1) $$

For Sequence D:

$$ A_D=(0,0,0,0,1) $$

Step 4: Account for Calendar Time

Suppose infection rates are declining over the five study periods because infection-control practices are improving generally. The analysis therefore includes period indicators:

$$ \gamma_2,\gamma_3,\gamma_4,\gamma_5 $$

with Period 1 serving as the reference period.

The model then estimates the intervention effect after adjusting for those period effects.

Step 5: Specify the Intracluster Correlation

Patients within the same hospital are generally more similar to one another than patients from different hospitals. This produces an intracluster correlation coefficient, or ICC.

For a simple random-intercept model, the ICC can be expressed as:

$$ \rho = \frac{\sigma_b^2} {\sigma_b^2+\sigma_e^2} $$

A larger ICC means that observations within the same cluster contain less independent information.

Why the ICC matters: Increasing the number of patients within the same hospital does not provide the same amount of information as increasing the number of independent hospitals. In cluster randomized trials, the number of clusters is often a much more important determinant of precision than the raw number of individuals.

Cluster-Period Correlation

Stepped-wedge studies are more complicated than a simple one-time cluster randomized comparison because outcomes may be correlated both:

  • Within the same cluster and period
  • Across periods within the same cluster

The correlation structure should therefore be considered explicitly during design and analysis.

Common working or covariance structures include:

  • Exchangeable correlation
  • Nested exchangeable correlation
  • Autoregressive correlation
  • Random-intercept covariance structures
  • More flexible covariance structures when supported by the data

Step 6: Define the Treatment Effect

Suppose the investigators expect the intervention to reduce the odds of infection. They might define the target treatment effect as:

$$ OR=0.70 $$

The corresponding log odds-ratio is:

$$ \beta = \log(0.70) \approx-0.3567 $$

The primary hypothesis can then be expressed as:

$$ H_0:\beta=0 \qquad\text{vs.}\qquad H_A:\beta\ne0 $$

or, if the protocol specifies a directional hypothesis:

$$ H_0:\beta\ge0 \qquad\text{vs.}\qquad H_A:\beta<0 $$

The choice between one-sided and two-sided testing should be made before the study begins and should reflect the scientific question and applicable regulatory expectations.

Step 7: Construct the Analysis Model

For the binary endpoint, one possible primary model is:

$$ \operatorname{logit} \{P(Y_{ijk}=1)\} = \mu + \beta A_{ij} + \gamma_j + b_i $$

The terms have the following interpretation:

Term Meaning
\(\mu\) Baseline model intercept
\(\beta\) Adjusted intervention effect
\(A_{ij}\) Intervention status
\(\gamma_j\) Calendar-period effects
\(b_i\) Cluster-specific random effect

Step 8: Interpret the Estimated Effect

Suppose the fitted model produces:

$$ \hat\beta=-0.3567 $$

Then:

$$ e^{\hat\beta}=0.70 $$

The estimated intervention odds ratio is therefore 0.70.

A corresponding interpretation is: after adjustment for study period and the specified cluster-level correlation structure, the estimated odds of infection under the intervention are 30% lower than under control.

The interpretation depends on the precise model, link function, covariates, and estimand specified in the statistical analysis plan.

Why Period Effects Are Not Optional Decoration

Suppose infection risk falls over time:

$$ P_1>P_2>P_3>P_4>P_5 $$

Now suppose early-rollout clusters happen to contain more intervention observations during the later periods. Without adjusting for time, the analysis could mistakenly attribute the general downward trend to the intervention.

The treatment indicator and time indicators therefore need to be separated statistically.

Core principle: The stepped-wedge treatment effect is identified by comparing intervention and control observations across different periods while accounting for calendar time.

Cross-Sectional vs. Cohort Stepped-Wedge Designs

There are two major ways participants can contribute repeated-period data.

Cross-Sectional Design

Different participants are sampled during each period. For example:

Period Participants
1 Patients sampled during Period 1
2 Different patients sampled during Period 2
3 Different patients sampled during Period 3
4 Different patients sampled during Period 4
5 Different patients sampled during Period 5

This is common when the intervention affects populations of newly enrolled or newly treated individuals.

Cohort Design

The same participants are followed across multiple periods.

This creates an additional level of within-participant correlation.

Design implication: Cross-sectional and cohort stepped-wedge trials can have different covariance structures and therefore different sample-size requirements. The participant-level correlation structure should be incorporated into the planning calculations.

Cross-Sectional Worked Example

For the hospital infection study, assume a cross-sectional design. Each hospital contributes approximately 25 new eligible patients per period. Therefore:

$$ m=25 $$

participants are observed per cluster-period.

With 20 clusters and 5 periods:

$$ N=20\times5\times25=2500 $$

Again, this is the number of observations, not the number of independent randomization units. The 20 hospitals are the units randomized to rollout sequences.

The "Cluster Is the Unit of Randomization" Rule

This is one of the most important concepts in the entire design. If 20 hospitals are randomized, there are:

$$ 20 $$

independent randomized units—not 2,500.

The 2,500 patient observations provide repeated information within those 20 randomized clusters.

This distinction affects:

  • Standard errors
  • Degrees of freedom
  • Power
  • Confidence intervals
  • Randomization inference
  • Sample-size calculations

Sample Size: The Basic Idea

Sample-size planning for stepped-wedge trials is more complicated than ordinary individually randomized trial calculations. The calculation depends on:

  • Number of clusters
  • Number of periods
  • Clusters per sequence
  • Participants per cluster-period
  • ICC
  • Correlation across periods
  • Baseline event rate or outcome variance
  • Magnitude of treatment effect
  • Type I error
  • Target power
  • Statistical analysis model

There is therefore no single universal stepped-wedge sample-size formula that works for every design.

A Simple Design-Effect Approximation

For an ordinary parallel cluster randomized design with \(m\) participants per cluster, a familiar approximation is:

$$ DE = 1+(m-1)\rho $$

This is the familiar design effect. For example, if:

$$ m=25 \qquad \rho=0.05 $$

then:

$$ DE = 1+(25-1)(0.05) $$
$$ DE = 1+1.20 = 2.20 $$

This means that, under the simple parallel-cluster approximation, the variance is approximately 2.2 times that of independent observations.

Caution: The ordinary design-effect formula is useful for intuition, but it is not a complete stepped-wedge sample-size calculation. Stepped-wedge designs have multiple periods and within-cluster longitudinal correlation, so a dedicated stepped-wedge calculation or simulation is preferred for final design work.

Why Adding More Participants per Cluster Has Diminishing Returns

Consider two hospitals. If their patients are highly correlated, adding many additional patients to the same hospital provides less information than adding another independent hospital.

This is because:

$$ \operatorname{Cov}(Y_{ijk},Y_{ij\ell})>0 $$

for two patients within the same cluster under positive intracluster correlation.

Therefore, investigators should generally think about sample size in terms of both:

  • Number of clusters
  • Number of participants per cluster-period

rather than simply targeting a large total number of patients.

Number of Sequences

The number of rollout sequences is a major design choice. In the simplest design, the number of sequences corresponds to the number of distinct intervention introduction times.

For example:

$$ J=4 $$

sequences may provide four different transition times.

Increasing the number of sequences can provide more staggered comparisons, but it also changes:

  • The allocation of clusters to each sequence
  • The number of clusters per sequence
  • The information available at each transition
  • The operational complexity

Clusters Per Sequence

If there are:

$$ K=20 $$

clusters and:

$$ J=4 $$

sequences, a balanced allocation gives:

$$ \frac{K}{J} = \frac{20}{4} = 5 $$

clusters per sequence.

Balanced allocation is often attractive because it gives each rollout sequence similar representation.

However, unequal allocation can sometimes be justified by practical or scientific considerations.

Number of Periods

The number of periods determines how many opportunities there are to observe the transition from control to intervention.

A five-period design might be:

Period Time
1 Baseline
2 Early rollout
3 Mid rollout
4 Late rollout
5 Final rollout

More periods provide more longitudinal information but may increase study duration, operational complexity, and exposure to secular changes.

Period Length Matters

The periods should be long enough to:

  • Recruit or observe enough participants
  • Implement the intervention
  • Allow the intervention to have an effect
  • Measure the endpoint reliably

If a period is too short, there may be insufficient information to distinguish a genuine intervention effect from implementation delay.

Implementation Lag

A particularly important issue in stepped-wedge trials is that an intervention may not become fully effective immediately after rollout.

For example, suppose a hospital receives a new electronic clinical decision support system at the beginning of Period 3. The intervention may require:

  • Staff training
  • Workflow adaptation
  • Technical troubleshooting
  • Behavioral change

The treatment effect in Period 3 may therefore differ from the effect in Periods 4 and 5.

A simple treatment indicator assumes:

$$ A_{ij}=1 $$

immediately means full intervention exposure. That assumption may not be scientifically appropriate.

Modeling an Implementation Lag

One approach is to distinguish between rollout and mature exposure. For example:

$$ A^{\text{early}}_{ij} $$

and:

$$ A^{\text{mature}}_{ij} $$

could represent early and mature intervention periods. The model might then estimate separate effects:

$$ \operatorname{logit}(P(Y=1)) = \mu+ \beta_1A^{\text{early}} + \beta_2A^{\text{mature}} + \gamma_j+b_i $$

This should be prespecified when implementation dynamics are scientifically important.

Permanent vs. Transient Intervention Effects

The standard stepped-wedge design often assumes that once a cluster receives the intervention, the intervention remains in place.

That is:

$$ 0\rightarrow1\rightarrow1\rightarrow1 $$

But not every intervention behaves this way. Some interventions may have temporary effects. In that situation, a simple permanent treatment indicator may not adequately represent the scientific question.

Contamination and Carryover

A stepped-wedge design also needs careful consideration of contamination. Once a cluster receives the intervention, its staff may continue using intervention practices even if a particular participant would otherwise be classified as control.

This is usually less problematic than individual randomization for cluster-level interventions, but it creates an important interpretive issue: the control condition must remain meaningfully different from the intervention condition during the relevant period.

Parallel Cluster vs. Stepped-Wedge: Conceptual Difference

Question Parallel Cluster Trial Stepped-Wedge Trial
Does every cluster receive intervention? Not necessarily Usually yes
When is intervention assigned? At randomization At randomized rollout time
Are multiple periods essential? No Yes
Does each cluster contribute control observations? Depends on design Usually yes
Does each cluster contribute intervention observations? Depends on design Usually yes

Advantages of the Stepped-Wedge Design

Stepped-wedge trials can be attractive for several reasons.

All Clusters Eventually Receive the Intervention

This can be ethically or operationally attractive when the intervention is expected to be beneficial and investigators do not want some clusters to remain permanently untreated.

Each Cluster Contributes Both Conditions

A cluster can provide observations before and after intervention rollout. This can improve efficiency by allowing the cluster to serve partly as its own longitudinal comparator.

Useful for Implementation Studies

The design is particularly natural when an intervention is being introduced sequentially across healthcare systems.

Randomized Rollout

Randomizing implementation timing provides a stronger basis for causal inference than simply introducing an intervention according to convenience.

Disadvantages of the Stepped-Wedge Design

The design also has important limitations.

Long Study Duration

Because rollout occurs over multiple periods, the study may last substantially longer than a simple parallel comparison.

Secular Trends Can Be Powerful

Time trends can confound interpretation if the analysis does not appropriately model them.

Implementation Changes Over Time

The intervention may be delivered differently in early and late rollout periods.

Loss to Follow-Up and Cluster Attrition

Loss of clusters or major changes in cluster size can materially reduce power.

Complex Statistical Analysis

The correlation structure is more complicated than in a simple individually randomized trial.

Potential for Carryover

Once a cluster receives the intervention, it may not return to the original control condition.

Important: "Everyone eventually receives treatment" is not itself a statistical advantage. The design is useful when the sequential rollout is scientifically and operationally appropriate and when the resulting time-dependent comparisons can support the intended causal estimand.

The Role of the Baseline Period

The first period usually provides a period in which all clusters are under control. This can provide valuable information about baseline outcome rates and between-cluster variability.

However, the baseline period should not be interpreted as an ordinary parallel-control group that is independent of all later observations. The same clusters are observed repeatedly.

Why Each Cluster Can Act as Its Own Comparator

Suppose Hospital A has a relatively high baseline infection rate because its patients are medically complex. Hospital B has a lower baseline infection rate. In a conventional parallel cluster trial, the baseline differences between hospitals can contribute to between-cluster variability. In a stepped-wedge trial, each hospital contributes observations before and after rollout.

This within-cluster longitudinal information can improve efficiency when the correlation structure is favorable.

But "each cluster is its own control" is an oversimplification. The primary comparison still depends on randomized rollout timing and adjustment for calendar period. A stepped-wedge trial should not be analyzed as a simple paired pre/post study.

Pre/Post Analysis Is Usually Not Enough

A tempting analysis is:

$$ \text{Outcome after rollout} - \text{Outcome before rollout} $$

for each cluster. This ignores the possibility that outcomes would have changed over time even without the intervention.

The stronger analysis uses the randomized sequence assignment and adjusts for period.

A Generic Mixed-Effects Analysis

For a continuous endpoint:

library(lme4)

fit <- lmer(
  outcome ~ intervention + factor(period) + (1 | cluster),
  data = dat
)

summary(fit)

The coefficient for intervention estimates the adjusted treatment effect under the specified linear mixed model.

Binary Outcome: Logistic Mixed Model

library(lme4)

fit <- glmer(
  outcome ~ intervention + factor(period) + (1 | cluster),
  data = dat,
  family = binomial(link = "logit")
)

summary(fit)

The exponentiated intervention coefficient gives the model-based odds ratio:

exp(fixef(fit)["intervention"])

The exact model specification should reflect the estimand, outcome distribution, cluster structure, and analysis plan.

Generalized Estimating Equations

A stepped-wedge trial can also be analyzed using generalized estimating equations.

library(geepack)

fit <- geeglm(
  outcome ~ intervention + factor(period),
  id = cluster,
  data = dat,
  family = binomial(link = "logit"),
  corstr = "exchangeable"
)

summary(fit)

GEE provides a population-averaged interpretation under the corresponding model and working correlation structure.

Mixed model vs. GEE: These approaches answer closely related but not necessarily identical estimands depending on model specification. The primary analysis should be selected based on the scientific estimand and prespecified statistical plan, not simply because one model is easier to fit.

Small Numbers of Clusters

Stepped-wedge trials often have relatively few clusters. For example:

$$ K=20 $$

clusters may be considered a reasonably substantial operational study while still representing a relatively small number of independent randomization units statistically.

With small numbers of clusters, standard asymptotic variance estimates can be optimistic. Possible approaches include:

  • Small-sample corrections
  • Cluster-level analyses
  • Finite-sample degrees-of-freedom methods
  • Randomization-based inference
  • Simulation-based power assessment

The appropriate method depends on the design and estimand.

Degrees of Freedom Matter

It is tempting to look at:

$$ N=2500 $$

and assume the study has thousands of degrees of freedom. It does not.

The randomized units are the clusters. If only 20 hospitals are randomized, inference must account for the limited number of independent clusters.

Sample Size Using Simulation

Simulation is often the most flexible approach for a stepped-wedge design. A simulation can reproduce:

  • Cluster assignment
  • Period effects
  • Cluster heterogeneity
  • Participant-level outcomes
  • Intracluster correlation
  • Intervention effects
  • Missing data
  • Cluster dropout
  • Implementation lag
  • The planned analysis model

Power is then estimated as the proportion of simulated trials that reject the null hypothesis.

$$ \widehat{\operatorname{Power}} = \frac{\#\{\text{simulated trials rejecting }H_0\}} {B} $$

where \(B\) is the number of simulated trials.

A Simple Simulation Framework in R

set.seed(2026)

B <- 2000

reject <- logical(B)

for (b in seq_len(B)) {

  # 1. Randomize clusters to rollout sequences
  # 2. Generate period effects
  # 3. Generate cluster effects
  # 4. Generate patient-level outcomes
  # 5. Apply the planned intervention effect
  # 6. Fit the prespecified analysis model
  # 7. Store whether the null was rejected
}

mean(reject)

A real simulation should generate data using the assumed correlation structure and then fit exactly the model intended for the final analysis.

Best practice: For complicated stepped-wedge designs, simulation-based power calculations are often preferable to relying exclusively on simplified closed-form approximations.

Worked Simulation Assumptions

Suppose the planning assumptions are:

Parameter Value
Clusters 20
Sequences 4
Periods 5
Patients per cluster-period 25
Baseline infection probability 15%
Target odds ratio 0.70
ICC 0.05
Two-sided alpha 0.05

The total number of patient-period observations is:

$$ 20\times5\times25=2500 $$

But the power calculation must reflect the correlation among patients and repeated observations from the same hospital.

Power Is Not Determined by Total N Alone

Consider two hypothetical studies:

Study Clusters Patients / Cluster Total Patients
A 20 100 2,000
B 100 20 2,000

Both studies have the same number of patient observations. But they do not necessarily have the same power. The second study has substantially more independent clusters.

Cluster randomized principle: For a fixed total number of observations, spreading participants across more independent clusters can substantially improve information when the ICC is positive.

Unequal Cluster Sizes

Real hospitals rarely contribute exactly the same number of patients. Suppose cluster sizes range from:

$$ m_i=15,\ldots,40 $$

A sample-size calculation based on equal cluster sizes may then be optimistic.

Potential approaches include:

  • Inflating the sample size for anticipated variation
  • Using coefficient-of-variation adjustments
  • Simulating the expected cluster-size distribution
  • Using actual historical cluster sizes when available

Cluster Dropout

Loss of an individual patient is not equivalent to loss of an entire cluster. If one hospital withdraws, the study loses observations across multiple periods.

For example, if:

$$ K=20 $$

clusters are planned and one hospital is lost, 5% of the randomized clusters have disappeared. But the resulting information loss can be greater than simply removing 5% of individual observations because the hospital represents an independent randomization unit.

Inflating for Cluster Attrition

If the anticipated cluster retention rate is:

$$ q=0.90 $$

then the number of clusters needed before attrition can be approximated as:

$$ K_{\text{recruit}} \approx \frac{K_{\text{required}}}{q} $$

For example, if 20 evaluable clusters are required:

$$ K_{\text{recruit}} \approx \frac{20}{0.90} = 22.22 $$

Because clusters are discrete, the operational plan would need to round this to an appropriate feasible allocation and preserve the sequence structure.

Important: Cluster-level attrition should ideally be incorporated directly into the simulation rather than handled only by a simple percentage inflation.

Missing Individual Outcomes

Missing observations can occur because patients:

  • Withdraw
  • Move to another facility
  • Miss follow-up
  • Have incomplete records
  • Become unevaluable

The impact depends on whether missingness is associated with:

  • Intervention status
  • Calendar period
  • Cluster
  • Patient characteristics
  • Outcome risk

The statistical analysis plan should specify how missing outcomes are handled.

Secular Trends: A Worked Example

Suppose the control infection probabilities decline over time:

Period Control Infection Probability
1 15%
2 14%
3 13%
4 12%
5 11%

Now suppose the intervention is associated with an odds ratio of 0.70. The treatment effect must be evaluated against this changing baseline rather than against a constant 15% risk.

This illustrates why calendar-period effects are fundamental to the analysis.

Linear vs. Nonlinear Time Trends

A simple model may treat period as a categorical variable:

$$ \gamma_2,\gamma_3,\ldots,\gamma_T $$

This makes relatively few assumptions about the shape of the secular trend.

Alternatively, investigators could model time continuously:

$$ \gamma t $$

or use nonlinear terms.

Categorical period effects are often attractive when there are enough periods because they avoid imposing a linear time trend.

Time-by-Treatment Interaction

An important extension is to allow the intervention effect to change with time since implementation.

For example:

$$ \operatorname{logit}(P(Y=1)) = \mu+ \gamma_j+ \beta_1A_{ij} + \beta_2A_{ij}T_{ij} + b_i $$

where \(T_{ij}\) represents time since intervention.

This can help investigate whether the intervention:

  • Works immediately
  • Becomes more effective with experience
  • Loses effectiveness over time

However, additional parameters require additional information and should not be added indiscriminately.

Estimand Considerations

Before designing the trial, investigators should define what treatment effect they want to estimate. Examples include:

  • Average intervention effect across all post-rollout periods
  • Effect after full implementation
  • Effect after a predefined implementation lag
  • Population-averaged effect
  • Cluster-specific effect

Different estimands can lead to different analysis models.

Design should follow the estimand. The number of periods, rollout schedule, and analysis model should be chosen to identify the treatment effect that the clinical question actually requires.

When Is a Stepped-Wedge Design Appropriate?

A stepped-wedge design can be appropriate when:

  • The intervention is naturally delivered at the cluster level.
  • Contamination would make individual randomization problematic.
  • There is a practical reason to roll out the intervention sequentially.
  • All clusters are expected to eventually receive the intervention.
  • The rollout order can be randomized or otherwise credibly assigned.
  • There is enough time to observe both pre- and post-intervention outcomes.
  • The secular trend can be adequately modeled.

When a Stepped-Wedge Design May Be Less Appropriate

The design may be problematic when:

  • The intervention cannot be delayed ethically for later sequences.
  • There is a strong external time trend that cannot be adequately modeled.
  • The intervention has substantial irreversible carryover that invalidates the planned comparison.
  • Rapid individual-level treatment assignment is feasible and preferable.
  • Clusters cannot reliably remain in their assigned rollout sequence.
  • Implementation timing is strongly determined by prognosis rather than randomization.
  • The intervention effect is expected to disappear before the next period.

Stepped-Wedge Trials Are Not Automatically More Powerful

A common misconception is that because every cluster contributes both control and intervention observations, a stepped-wedge design must be more efficient than a parallel cluster randomized trial.

That is not generally true.

Efficiency depends on:

  • Number of clusters
  • Number of periods
  • Cluster size
  • ICC
  • Within-cluster temporal correlation
  • Secular trends
  • Treatment effect
  • Timing of rollout

The correct comparison should be based on the information available for the specific estimand under the proposed designs.

The Importance of Rollout Balance

Consider a design in which almost all clusters receive intervention early and only a few receive it late. The design would have fewer contemporaneous control observations during the later periods.

A more balanced rollout can provide stronger overlap between:

  • Intervention observations
  • Control observations
  • Calendar periods

This overlap helps separate treatment effects from time effects.

Randomization and Stratification

If clusters differ substantially in size or baseline risk, randomization can be stratified. For example, hospitals might first be classified by:

  • Hospital size
  • Geographic region
  • Baseline outcome rate
  • Academic vs. community status

Clusters can then be randomized within strata to rollout sequences.

Stratified randomization: The stratification variables should be chosen before randomization and documented in the protocol. They should not be selected after examining outcomes.

Baseline Covariates

The primary analysis may include prespecified baseline covariates to improve precision. For example:

$$ \operatorname{logit}(P(Y=1)) = \mu+ \beta A+ \gamma_j+ \theta Z+ b_i $$

where \(Z\) represents a baseline covariate.

Covariate adjustment should be motivated scientifically and prespecified. It should not replace the randomized rollout assignment.

Cluster-Level vs. Individual-Level Analysis

One approach is to aggregate outcomes within each cluster-period. For a binary endpoint, define:

$$ \hat p_{ij} = \frac{Y_{ij}}{m_{ij}} $$

where \(Y_{ij}\) is the number of events and \(m_{ij}\) is the number of participants in cluster \(i\), period \(j\).

The analysis can then operate on cluster-period summaries.

Alternatively, an individual-level mixed model or GEE can use every participant-level observation.

Approach Advantages Considerations
Cluster-period analysis Simple, transparent Must appropriately account for cluster-period variance
Mixed model Flexible covariance modeling Model assumptions matter
GEE Population-averaged interpretation Small-cluster inference requires care

A Practical Data Structure

A long-format analysis dataset might contain:

cluster sequence period patient intervention outcome
H01 A 1 P001 0 0
H01 A 1 P002 0 1
H01 A 2 P003 1 0
H02 D 1 P004 0 0
H02 D 5 P005 1 0

This structure makes it straightforward to construct:

  • Cluster identifiers
  • Sequence identifiers
  • Period indicators
  • Intervention indicators
  • Outcome variables
  • Baseline covariates

Primary Analysis Workflow

1
Define the estimand and primary endpoint.
2
Randomize clusters to rollout sequences.
3
Collect outcomes during each prespecified period.
4
Construct the intervention and period indicators.
5
Account for within-cluster correlation.
6
Fit the prespecified primary model.
7
Estimate the intervention effect and confidence interval.
8
Perform prespecified sensitivity analyses.

Common Mistakes

  1. Ignoring calendar time. A stepped-wedge trial cannot generally be analyzed as a simple pre/post comparison.
  2. Confusing participants with independent randomized units. If 20 hospitals are randomized, the trial has 20 randomized clusters even if thousands of patients are observed.
  3. Using an ordinary individual-level sample-size formula. Such calculations ignore intracluster correlation and the repeated-period structure.
  4. Failing to prespecify rollout sequences. Changing rollout timing based on emerging outcomes can compromise the original randomization-based operating characteristics.
  5. Assuming all intervention periods have the same effect. Implementation lag or learning effects may make this assumption unrealistic.
  6. Ignoring cluster dropout. Loss of a cluster can be substantially more consequential than loss of a single participant.
  7. Using a very small number of clusters without considering finite-sample inference. Asymptotic standard errors may be unreliable when the number of clusters is small.
  8. Calling every stepped-wedge design "crossover." The intervention typically rolls out permanently from control to intervention; it is not the same as repeatedly crossing back and forth between treatments.
  9. Assuming everyone receiving intervention guarantees ethical superiority. The scientific and ethical justification still depends on uncertainty, implementation timing, equipoise, and the specific intervention.
  10. Changing the estimand after looking at the data. The target treatment effect should be defined before the primary analysis.

Stepped-Wedge vs. Individual Crossover Trial

These designs are sometimes confused because both involve treatment changes over time. They are fundamentally different.

Feature Stepped-Wedge Individual Crossover
Randomization unit Cluster Individual
Intervention timing Cluster rollout Individual treatment sequence
Typical treatment switch Control → Intervention Control ↔ Intervention
All participants receive both treatments? Not necessarily Usually yes
Carryover concern Cluster implementation/carryover Classical treatment carryover

Stepped-Wedge vs. Interrupted Time Series

An interrupted time-series study observes outcomes before and after an intervention. But the intervention timing is generally determined by implementation rather than randomized rollout.

A stepped-wedge design adds randomization to the timing of intervention introduction across clusters.

The distinction is causal: A randomized stepped-wedge design can use differences in randomized rollout timing to strengthen causal inference relative to a simple uncontrolled before-and-after analysis.

Stepped-Wedge vs. Parallel Cluster Randomization

The basic conceptual comparison is:

A
Parallel cluster design: randomize clusters to control or intervention and retain those assignments.
B
Stepped-wedge design: randomize clusters to different times of intervention introduction.
C
Both: must account for cluster-level correlation and prespecify the analysis.

Statistical Power in the Worked Example

Suppose the primary hypothesis is:

$$ H_0:\beta=0 \qquad \text{vs.} \qquad H_A:\beta=\log(0.70) $$

If the study is designed for 80% power at the assumed treatment effect, then the power calculation asks:

$$ P(\text{reject }H_0 \mid \beta=\log(0.70)) \ge0.80 $$

The actual power should be calculated using the exact planned design, including the number of clusters, periods, cluster sizes, ICC, correlation structure, time effects, and primary analysis model.

Why Simulation Can Be Superior to a Closed-Form Calculation

Suppose the trial includes:

  • Unequal hospital sizes
  • Missing outcomes
  • Cluster dropout
  • Nonlinear time trends
  • Implementation lag
  • Binary outcomes
  • Random cluster effects
  • Small-sample inference

A simple formula may not adequately represent the planned analysis. Simulation can reproduce all of these features.

Monte Carlo Standard Error for Simulated Power

Suppose \(B=2{,}000\) simulations are run and the estimated power is:

$$ \hat\pi=0.80 $$

The Monte Carlo standard error is approximately:

$$ SE_{\text{MC}} = \sqrt{ \frac{\hat\pi(1-\hat\pi)} {B} } $$

Therefore:

$$ SE_{\text{MC}} = \sqrt{ \frac{0.80(0.20)} {2000} } \approx0.0089 $$

So the simulation itself has approximately 0.9 percentage points of Monte Carlo standard error.

Practical point: If a design decision depends on distinguishing, for example, 79% from 80% power, substantially more simulations may be appropriate.

Analysis of a Continuous Outcome in R

library(lme4)

fit_continuous <- lmer(
  outcome ~ intervention + factor(period) + (1 | cluster),
  data = dat
)

summary(fit_continuous)

confint(
  fit_continuous,
  parm = "intervention"
)

The intervention coefficient represents the adjusted mean difference under the specified linear mixed model.

Analysis of a Binary Outcome in R

library(lme4)

fit_binary <- glmer(
  outcome ~ intervention + factor(period) + (1 | cluster),
  data = dat,
  family = binomial()
)

beta_hat <- fixef(fit_binary)["intervention"]

OR <- exp(beta_hat)

OR

The exponentiated coefficient is the model-based odds ratio.

Including a Baseline Covariate

fit_binary <- glmer(
  outcome ~ intervention +
            factor(period) +
            baseline_risk +
            (1 | cluster),
  data = dat,
  family = binomial()
)

Covariate adjustment can improve precision when the covariate is strongly associated with the outcome.

Testing for a Treatment-by-Time Interaction

fit_interaction <- glmer(
  outcome ~ intervention * factor(period) +
            (1 | cluster),
  data = dat,
  family = binomial()
)

summary(fit_interaction)

This model asks whether the intervention effect varies across calendar periods.

However, a large interaction model can consume degrees of freedom, especially when the number of clusters is modest.

Primary vs. Sensitivity Analyses

A robust analysis plan might specify:

Analysis Purpose
Primary mixed model Primary estimand
GEE analysis Population-averaged sensitivity analysis
Alternative covariance structure Assess correlation assumptions
Cluster-level analysis Robustness to individual-level model assumptions
Missing-data sensitivity analysis Assess impact of missing outcomes

Protocol Considerations

The protocol should specify:

  • Cluster definition
  • Randomization unit
  • Number of sequences
  • Number of clusters per sequence
  • Period definitions
  • Rollout schedule
  • Randomization method
  • Primary endpoint
  • Primary estimand
  • Primary analysis model
  • Period-effect specification
  • Correlation structure
  • ICC assumptions for sample size
  • Cluster-size assumptions
  • Missing-data strategy
  • Cluster dropout strategy
  • Implementation-lag assumptions
  • Multiplicity strategy, where applicable

Statistical Analysis Plan Considerations

The SAP should make the analysis reproducible. At minimum, specify:

  • The coding of the intervention variable
  • The reference period
  • The treatment-effect scale
  • The treatment-by-time specification, if applicable
  • The covariance structure
  • The inferential method
  • Small-sample corrections, if used
  • Confidence-interval construction
  • Handling of missing observations
  • Handling of cluster withdrawal
  • Prespecified sensitivity analyses

Ethical Considerations

The fact that all clusters eventually receive the intervention can make stepped-wedge trials attractive in settings where withholding the intervention permanently is difficult to justify.

However, the design still creates periods in which some clusters have not yet received the intervention.

Therefore, the study must have appropriate scientific and ethical justification for delayed implementation.

If the intervention is already known to be effective and withholding it for the later sequences would create unacceptable risk, a stepped-wedge randomized design may not be appropriate.

Operational Considerations

A stepped-wedge design is also an implementation project. The statistical design must therefore be coordinated with:

  • Training schedules
  • Site activation
  • Technical deployment
  • Staff turnover
  • Data collection windows
  • Monitoring visits
  • Intervention fidelity
  • Contamination prevention

A statistically elegant rollout schedule is not useful if sites cannot implement it reliably.

Intervention Fidelity

Receiving the intervention assignment does not guarantee that the intervention was actually delivered. Investigators should distinguish:

  • Assigned intervention
  • Implemented intervention
  • Adherence
  • Exposure

The primary randomized analysis generally follows the assigned rollout sequence. A separate per-protocol or implementation-fidelity analysis may be useful, but it answers a different question.

Intent-to-Treat Principle

The primary analysis should generally preserve the randomized sequence assignment. If a hospital assigned to receive the intervention in Period 3 does not implement it until Period 4, simply changing its treatment status to match what actually happened can compromise the randomized comparison.

Preserve randomization: The primary analysis should normally be based on the prespecified randomized assignment and rollout schedule, with deviations handled according to the statistical analysis plan.

Example of an Implementation Deviation

Suppose Hospital C is randomized to Sequence B:

$$ (0,0,1,1,1) $$

but the intervention is not activated until Period 4. The protocol should specify how this deviation is represented in the primary analysis.

Possible secondary analyses might distinguish:

  • Assigned treatment status
  • Actual treatment exposure
  • Per-protocol implementation

These analyses should not be chosen after examining which approach produces the preferred result.

Sample-Size Planning Workflow

1
Define the primary estimand and endpoint.
2
Define the cluster and randomization unit.
3
Choose the number of periods and rollout sequences.
4
Specify the expected cluster size per period.
5
Specify the expected ICC and longitudinal correlation.
6
Specify the clinically important treatment effect.
7
Specify the secular time trend.
8
Choose a sample-size formula or simulation strategy.
9
Evaluate power under the primary assumptions.
10
Perform sensitivity analyses over ICC, cluster size, effect size, and dropout.
11
Finalize the number of clusters and rollout allocation.

Sensitivity Analysis for the ICC

The ICC is often uncertain during planning. Suppose the primary assumption is:

$$ \rho=0.05 $$

It is prudent to examine alternatives such as:

$$ \rho\in\{0.01,0.03,0.05,0.08,0.10\} $$

If the design loses substantial power at modestly higher ICC values, the sample-size plan may need to be revisited.

Sensitivity Analysis for Cluster Size

Likewise, evaluate plausible cluster-period sizes:

$$ m\in\{15,20,25,30,40\} $$

This is especially important when recruitment varies substantially among hospitals or clinics.

Sensitivity Analysis for Treatment Effect

Suppose the target odds ratio is:

$$ OR=0.70 $$

A sensitivity analysis might consider:

$$ OR\in\{0.60,0.70,0.80\} $$

This illustrates how much power depends on the assumed clinical effect.

Do not design only around the most optimistic effect. If the intervention effect is smaller than expected, power can fall rapidly. The assumed effect should be clinically meaningful and defensible.

A Compact Design Matrix

For the worked example, the treatment indicator can be written as:

Sequence Period 1 Period 2 Period 3 Period 4 Period 5
A 0 1 1 1 1
B 0 0 1 1 1
C 0 0 0 1 1
D 0 0 0 0 1

This simple matrix is the foundation of the statistical design. Every patient observation can be mapped to:

$$ (\text{cluster},\text{sequence},\text{period},\text{intervention}) $$

and the analysis then estimates the intervention effect after accounting for period and clustering.

The Most Important Statistical Contrast

At any given period after rollout begins, some clusters are under intervention while other clusters are still under control. For example, in Period 3:

Sequence Period 3 Status
A Intervention
B Intervention
C Control
D Control

Thus Period 3 contains a contemporaneous comparison between intervention and control clusters. The same principle occurs in later periods with different allocations.

Why the wedge works: The staggered rollout creates repeated periods in which intervention and control clusters coexist, while the randomized sequence determines which clusters are in each condition.

What Happens in the Final Period?

In the final period of the example, every sequence has crossed to intervention:

$$ (1,1,1,1) $$

There is therefore no contemporaneous control group in that final period. This does not mean the final period is useless. It contributes information about post-intervention outcomes and longitudinal cluster trajectories. However, the identification of the treatment effect relies on the complete pattern of randomized rollout across all periods, not on the final period alone.

Why the Earlier Periods Are So Important

The earlier periods contain the strongest overlap between:

  • Control clusters
  • Intervention clusters
  • Calendar time

This overlap helps separate:

$$ \text{intervention effect} \quad\text{from}\quad \text{time effect} $$

A design with too few periods or poor rollout balance can therefore be much less informative than its total number of observations suggests.

What If the Intervention Is Introduced at Different Rates?

Not every stepped-wedge design needs equal numbers of clusters at every transition. For example:

Sequence Clusters Rollout Period
A 8 2
B 6 3
C 4 4
D 2 5

This is statistically possible, but the information contributed by each transition differs. The allocation should therefore be justified during design planning.

Period Effects Can Be Categorical

A particularly flexible primary model treats each period as a categorical factor:

$$ \gamma_2,\gamma_3,\ldots,\gamma_T $$

This does not require the outcome to follow a straight-line trend. For example, the model can accommodate:

$$ \text{Period effect} = (0,-0.1,-0.3,-0.1,-0.4) $$

without forcing the changes to be linear.

Why a Linear Time Trend Can Be Dangerous

If investigators fit:

$$ \gamma t $$

they assume that the calendar effect follows a particular functional form. If the true trend is nonlinear, the treatment coefficient can potentially absorb some of the model misspecification.

Categorical period effects are often a useful primary specification when the number of periods permits them.

Cluster-Specific Random Effects

The random-intercept model:

$$ b_i\sim N(0,\sigma_b^2) $$

allows each cluster to have its own baseline tendency. For example:

  • Hospital A may have systematically high infection risk.
  • Hospital B may have systematically low infection risk.
  • Hospital C may be intermediate.

The random effect captures this cluster-level heterogeneity.

Fixed vs. Random Cluster Effects

Another approach is to include cluster fixed effects:

$$ Y_{ijk} = \alpha_i+ \beta A_{ij} + \gamma_j + \epsilon_{ijk} $$

where \(\alpha_i\) represents a separate intercept for each cluster. This can be useful in some settings because it makes fewer assumptions about the distribution of cluster effects. However, the choice between fixed and random cluster effects should be consistent with the estimand, design, number of clusters, and inferential strategy.

Cluster Fixed Effects and Treatment Identification

A stepped-wedge design has a useful property: Each cluster has both pre- and post-intervention observations. This makes cluster fixed effects possible in many settings. The model can then be written:

$$ g\{E(Y_{ij})\} = \alpha_i+ \gamma_j+ \beta A_{ij} $$

where \(g\) is the chosen link function.

The intervention effect is identified from changes in intervention status within clusters, together with the randomized staggered rollout across clusters and periods.

But Fixed Effects Do Not Eliminate Time Confounding

Cluster fixed effects control for stable differences between hospitals. They do not automatically control for calendar-time trends.

You generally still need:

$$ \gamma_j $$

to account for period effects.

Two different sources of variation: Cluster effects address persistent differences between clusters. Period effects address changes over calendar time. They solve different statistical problems.

Reporting the Results

A typical primary result might report:

Statistic Example
Estimated odds ratio 0.70
95% confidence interval 0.55–0.89
p-value 0.004
Period adjustment Yes
Cluster adjustment Yes

The exact interpretation should identify the estimand and model. For example:

Example reporting language: "The primary analysis estimated the intervention effect using a logistic mixed-effects model including fixed effects for study period and a cluster-level random intercept. The estimated odds ratio for the intervention was 0.70 (95% CI 0.55–0.89)."

What Should Be Reported About the Design?

A complete report should describe:

  • Number of clusters
  • Number of sequences
  • Number of periods
  • Clusters per sequence
  • Duration of each period
  • Randomization procedure
  • Rollout schedule
  • Number of participants per cluster-period
  • Primary endpoint
  • Primary estimand
  • Primary analysis model
  • Period adjustment
  • Correlation structure
  • Missing-data handling
  • Protocol deviations
  • Implementation fidelity

Reporting the Rollout Matrix

The treatment assignment matrix is often one of the clearest ways to communicate the design. For example:

Sequence P1 P2 P3 P4 P5
A Control Intervention Intervention Intervention Intervention
B Control Control Intervention Intervention Intervention
C Control Control Control Intervention Intervention
D Control Control Control Control Intervention

This matrix should be included in the protocol or statistical documentation whenever possible.

A Minimal R Data-Generation Example

set.seed(2026)

clusters <- 20
periods  <- 5
m        <- 25

sequence <- rep(
  LETTERS[1:4],
  each = clusters / 4
)

rollout <- c(
  A = 2,
  B = 3,
  C = 4,
  D = 5
)

dat <- expand.grid(
  cluster = 1:clusters,
  period = 1:periods,
  patient = 1:m
)

dat$sequence <- sequence[dat$cluster]

dat$intervention <-
  as.integer(
    dat$period >=
    rollout[dat$sequence]
  )

head(dat)

This creates the basic longitudinal treatment structure. A full simulation would then add cluster effects, period effects, and individual outcomes.

A Simple Binary Outcome Simulation

library(lme4)

set.seed(2026)

beta <- log(0.70)

period_effect <- c(
  0,
  -0.10,
  -0.20,
  -0.15,
  -0.25
)

cluster_effect <-
  rnorm(
    clusters,
    mean = 0,
    sd = 0.20
  )

dat$eta <-
  qlogis(0.15) +
  beta * dat$intervention +
  period_effect[dat$period] +
  cluster_effect[dat$cluster]

dat$prob <-
  plogis(dat$eta)

dat$outcome <-
  rbinom(
    nrow(dat),
    size = 1,
    prob = dat$prob
  )

fit <- glmer(
  outcome ~
    intervention +
    factor(period) +
    (1 | cluster),
  data = dat,
  family = binomial()
)

summary(fit)

This is a simplified illustration rather than a production sample-size program. A formal design simulation should also reproduce the intended cluster correlation, participant sampling, missingness, implementation behavior, and inferential procedure.

Extract the Estimated Odds Ratio

beta_hat <-
  fixef(fit)["intervention"]

OR_hat <-
  exp(beta_hat)

OR_hat

The resulting value estimates the odds ratio associated with the intervention under the simulated model.

Simulation-Based Power Code Structure

simulate_trial <- function(
  n_clusters,
  n_periods,
  m,
  beta,
  sigma_cluster
) {

  # Create cluster-period structure
  # Randomize clusters to sequences
  # Generate cluster effects
  # Generate period effects
  # Generate patient outcomes
  # Fit the prespecified model
  # Return the test statistic or p-value

}

B <- 2000

p_values <- replicate(
  B,
  simulate_trial(
    n_clusters = 20,
    n_periods = 5,
    m = 25,
    beta = log(0.70),
    sigma_cluster = 0.20
  )
)

mean(p_values < 0.05)

The estimated proportion of significant simulated trials is the Monte Carlo estimate of power under the assumed alternative.

Type I Error Simulation

The same simulation framework can be used under:

$$ \beta=0 $$

to evaluate whether the complete design and analysis maintain the desired type I error.

# Under H0:
beta_null <- 0

# Repeat the complete trial simulation
# using beta_null.

# Estimated type I error:
mean(p_values_null < 0.05)
Why this is valuable: Simulation can assess the actual operating characteristics of the complete planned procedure rather than a simplified mathematical approximation.

Design Sensitivity Grid

A useful planning exercise is to create a grid across:

Parameter Illustrative Values
ICC 0.01, 0.03, 0.05, 0.08, 0.10
Cluster-period size 15, 20, 25, 30, 40
Odds ratio 0.60, 0.70, 0.80
Cluster dropout 0%, 5%, 10%

Power can then be evaluated across the grid. This identifies assumptions under which the study may become underpowered.

What Makes a Good Stepped-Wedge Design?

A well-designed study should have:

  • A scientifically meaningful intervention effect
  • A credible cluster definition
  • A randomized rollout schedule
  • A sufficient number of independent clusters
  • Enough periods to identify the treatment effect
  • Reasonable overlap between intervention and control conditions
  • A defensible ICC assumption
  • A prespecified approach to secular trends
  • A realistic implementation timeline
  • A primary analysis aligned with the estimand
  • Robust sensitivity analyses

The Biggest Design Trade-Off

The central trade-off is between:

$$ \text{more information} \qquad\text{vs.}\qquad \text{greater operational complexity} $$

More clusters and periods can increase information. But they also increase:

  • Cost
  • Study duration
  • Site burden
  • Training requirements
  • Data-management complexity
  • Exposure to secular changes

The optimal design therefore depends on the clinical and operational context.

A Practical Stepped-Wedge Design Workflow

1
Define the intervention and why it must be delivered at the cluster level.
2
Define the primary endpoint and estimand.
3
Identify the cluster and randomization unit.
4
Choose the number of periods.
5
Define the intervention rollout sequences.
6
Randomize clusters to sequences.
7
Specify expected cluster-period enrollment.
8
Specify ICC and longitudinal correlation assumptions.
9
Specify the expected secular time trend.
10
Calculate power using an appropriate stepped-wedge method or simulation.
11
Evaluate sensitivity to ICC, cluster size, effect size, and attrition.
12
Prespecify the final design and analysis in the protocol and SAP.

Worked Example Summary

The hospital infection-prevention example can be summarized as follows:

Component Value
Design Stepped-wedge cluster randomized trial
Clusters 20 hospitals
Sequences 4
Clusters per sequence 5
Periods 5
Patients per cluster-period 25
Total patient-period observations 2,500
Primary endpoint Binary infection outcome
Illustrative baseline risk 15%
Illustrative treatment effect OR = 0.70
Illustrative ICC 0.05
Primary model Logistic mixed-effects model
Period adjustment Categorical study period

The numbers above are intentionally illustrative. A real trial's number of clusters and participants should be determined by a formal power calculation or simulation using the actual endpoint, covariance structure, treatment effect, and analysis plan.

What Should Be Included in a Statistical Analysis Plan?

For a stepped-wedge trial, the SAP should make the primary analysis completely reproducible.

At minimum, document:

  • Definition of the cluster
  • Randomization unit
  • Sequence allocation
  • Period definitions
  • Intervention indicator
  • Primary estimand
  • Primary endpoint
  • Primary analysis population
  • Period effects
  • Cluster effects
  • Covariance structure
  • Inference method
  • Small-sample correction
  • Missing-data handling
  • Protocol deviations
  • Implementation fidelity
  • Sensitivity analyses

Checklist for Sample-Size Planning

Question Required?
How many clusters? Yes
How many sequences? Yes
How many periods? Yes
How many participants per cluster-period? Yes
What is the ICC? Yes
What is the expected treatment effect? Yes
What is the baseline event rate or outcome variance? Yes
What is the secular time trend? Yes
What correlation exists across periods? Yes
What cluster dropout is expected? Yes
What analysis model will be used? Yes

The Most Important Concept

The most important conceptual point is this: a stepped-wedge trial is not simply a cluster randomized trial in which everyone eventually gets treatment.

Its statistical power and causal interpretation come from the combination of:

  • Randomized rollout timing
  • Repeated observations across periods
  • Within-cluster correlation
  • Contemporaneous intervention and control observations
  • Adjustment for calendar time

The intervention effect is therefore identified from the structured pattern of treatment exposure across clusters and periods.

Bottom line: A stepped-wedge trial is a cluster randomized design in which all clusters eventually receive an intervention, but the timing of rollout is randomized across clusters. Its defining statistical challenge is separating the intervention effect from secular time trends while accounting for correlation within clusters and across repeated periods. A successful design requires careful selection of the number of clusters, sequences, periods, cluster-period sample sizes, ICC, treatment effect, and analysis model. For complex designs, simulation is often the most transparent way to verify type I error and power under realistic assumptions.

References

Hussey, M.A. & Hughes, J.P. (2007). Design and analysis of stepped wedge cluster randomized trials. Contemporary Clinical Trials, 28(2), 182–191.
Hemming, K., Haines, T.P., Chilton, P.J., Girling, A.J. & Lilford, R.J. (2015). The stepped wedge cluster randomised trial: rationale, design, analysis, and reporting. BMJ, 350, h391.
Hemming, K., Taljaard, M., McKenzie, J.E., et al. (2018). Reporting of stepped wedge cluster randomised trials: extension of the CONSORT 2010 statement with explanation and elaboration. BMJ, 363, k1614.
Hemming, K., Kasza, J., Hooper, R., Forbes, A. & Taljaard, M. (2020). A tutorial on sample size calculation for multiple-period cluster randomised parallel, cross-over and stepped-wedge trials using the Shiny CRT Calculator. International Journal of Epidemiology, 49(3), 979–995.
Hooper, R., Copas, A., Forbes, A. & Sisirak, V. (2019). Analysis of stepped wedge trials with continuous outcomes. Trials, 20, 248.
Hemming, K., Taljaard, M., Forbes, A. & Grimshaw, J. (2017). Analysis of stepped wedge cluster randomized trials as repeated cross-sectional designs. Trials, 18, 101.