1 Introduction

This tutorial introduces an online R Shiny calculator for designing stepped-wedge cluster randomized trials (SW-CRTs) with a baseline measurement of the outcome.

The Shiny app is available here:

https://kendra-davis-plourde.shinyapps.io/SWCRTbaseline/

The app implements sample size and power calculations for cross-sectional SW-CRTs where individuals may have both a baseline outcome measurement and an endline outcome measurement. The methods are based on the paper:

Davis-Plourde K, Goldfeld K, Allore HG, Taljaard M, Li F. Designing Stepped Wedge Cluster Randomized Trials With a Baseline Measurement of the Outcome. Statistics in Medicine. 2025;44(20-22):e70273.

The goal of this tutorial is to show how to use the Shiny app, how to specify the required design and correlation parameters, and how to interpret the resulting power curves.

2 Background

A stepped-wedge cluster randomized trial is a type of cluster randomized trial in which clusters begin in the control condition and cross over to the intervention condition at different time points. By the end of the trial, all clusters typically receive the intervention.

In a cross-sectional SW-CRT, different individuals are usually measured in different cluster-periods. In some studies, each individual may also have a baseline measurement of the outcome before exposure to the intervention, followed by an endline outcome measurement after exposure.

When the baseline and endline outcomes are correlated, incorporating the baseline outcome can improve statistical efficiency. The Shiny app allows investigators to evaluate this potential efficiency gain at the design stage.

3 Models Included in the App

The app includes three baseline-adjusted linear mixed effects models, along with the conventional endline-only model for comparison.

3.1 Endline-only model

The endline-only model uses only the post-intervention outcome as the response. It adjusts for period effects and accounts for clustering using random cluster and cluster-period effects.

This model does not use the baseline outcome. In the app, it is included as a reference model so that users can evaluate the efficiency gain from incorporating baseline measurements.

3.2 Bivariate model

The bivariate linear mixed model jointly models the baseline and endline outcomes. The treatment effect is specified only for the endline outcome.

This approach uses the joint correlation structure between baseline and endline outcomes. It can be highly efficient, but it requires more correlation parameters than the other approaches.

3.3 Change score model

The change score model uses the difference between the endline and baseline outcomes as the response:

\[ \Delta Y = Y_{\text{endline}} - Y_{\text{baseline}}. \]

This approach is intuitive, but its efficiency depends strongly on the correlation between the baseline and endline outcomes. Therefore, it may not always be the most efficient option.

3.4 ANCOVA model

The ANCOVA model uses the endline outcome as the response and adjusts for the baseline outcome as a covariate.

This approach is often practical because it directly adjusts for the baseline outcome while requiring fewer correlation parameters than the bivariate model.

4 Basic Assumptions

The calculator is designed for cross-sectional SW-CRTs with the following assumptions:

  • The outcome is continuous.
  • Clusters are randomized to treatment sequences.
  • Each sequence contains the same number of clusters.
  • Each cluster-period contains the same number of participants.
  • A baseline outcome and an endline outcome may be measured for each participant.
  • The degrees of freedom for the test are set to the number of clusters minus two.

These assumptions should be considered before applying the calculator to a proposed trial design.

5 Overview of the Shiny App

The Shiny app has three main input sections:

  1. Parameters for the graph
  2. Other design parameters
  3. ICC parameters

The output is a power curve showing how power changes as one design parameter varies.

6 Step 1: Choose the Baseline Adjustment Model

The first input is Model for baseline adjustment.

Users can choose one of the following options:

  • Bivariate
  • Change score
  • ANCOVA
  • Compare all models

If the goal is to compare the efficiency of different analysis strategies, select Compare all models. This option displays power curves for the bivariate, change score, ANCOVA, and endline-only models on the same plot.

If the goal is to focus on one planned analysis model, select that model directly.

7 Step 2: Choose the X-axis

The second input is X-axis.

The app allows the user to choose which design parameter varies on the x-axis:

  • Clusters per sequence
  • Number of participants in a cluster-period

Selecting Clusters per sequence is useful when the investigator wants to determine how many clusters are needed to achieve a target power.

Selecting Number of participants in a cluster-period is useful when the number of clusters is fixed, but the investigator wants to evaluate how many participants are needed within each cluster-period.

After selecting the x-axis variable, users can specify a range for that variable. The app then calculates power across this range.

8 Step 3: Enter the Main Design Parameters

The next section of the app asks for the main design inputs.

8.1 Number of participants in a cluster-period

This is the number of participants measured in each cluster during each trial period.

For example, if each hospital contributes 20 participants during each period, then this value should be set to 20.

8.2 Number of sequences

This is the number of treatment sequences in the stepped-wedge design.

For a complete stepped-wedge design, the number of periods is usually one more than the number of sequences.

For example, if there are 3 sequences, the corresponding design has 4 periods.

8.3 Mean difference

The mean difference, denoted by \(\delta\), is the expected treatment effect on the outcome scale.

This value should be chosen based on the clinically meaningful effect size or the anticipated intervention effect.

8.4 Standard deviation of baseline outcome

This is the marginal standard deviation of the baseline outcome, denoted by \(\sigma_{y0}\).

8.5 Standard deviation of endline outcome

This is the marginal standard deviation of the endline outcome, denoted by \(\sigma_{y1}\).

8.6 Significance level

This is the type I error rate. In most applications, this is set to 0.05 for a two-sided test.

9 Step 4: Enter the ICC Parameters

The right side of the app asks for ICC parameters. These parameters describe the correlation structure of the baseline and endline outcomes.

Because SW-CRTs involve repeated measurements within clusters over time, the app distinguishes between within-period and between-period ICCs.

Parameter in the app Notation Interpretation
Baseline within-period ICC \(\rho^0_0\) Correlation between baseline outcomes from different individuals in the same cluster and same period
Endline within-period ICC \(\rho^1_0\) Correlation between endline outcomes from different individuals in the same cluster and same period
Baseline between-period ICC \(\rho^0_1\) Correlation between baseline outcomes from individuals in the same cluster but different periods
Endline between-period ICC \(\rho^1_1\) Correlation between endline outcomes from individuals in the same cluster but different periods
Baseline-endline within-period ICC \(\rho^{01}_0\) Correlation between a baseline outcome and an endline outcome from different individuals in the same cluster and same period
Baseline-endline between-period ICC \(\rho^{01}_1\) Correlation between a baseline outcome and an endline outcome from individuals in the same cluster but different periods
Intra-subject ICC \(\rho^{01}_2\) Correlation between the baseline and endline outcomes for the same individual

The intra-subject ICC is especially important because the efficiency gain from using baseline outcome information depends strongly on how correlated the baseline and endline outcomes are within the same individual.

10 Step 5: Interpret the Power Curve

After all design and ICC parameters are entered, the app displays a power curve.

The y-axis shows statistical power.

The x-axis shows the selected design parameter, either the number of clusters per sequence or the number of participants per cluster-period.

When Compare all models is selected, each line corresponds to one analysis strategy:

  • Bivariate
  • Change score
  • ANCOVA
  • Endline-only

A higher power curve indicates a more efficient analysis strategy under the specified design and correlation assumptions.

11 Example: Comparing Baseline-adjusted Models

In this section, we illustrate how to use the Shiny app to compare different analysis strategies for a proposed cross-sectional stepped-wedge cluster randomized trial with a baseline measurement of the outcome.

The figure below shows an example generated from the Shiny app.

In this example, we select Compare all models under Model for baseline adjustment. This option displays four power curves on the same plot: the bivariate model, the change score model, the ANCOVA model, and the conventional endline-only model.

We choose Clusters per sequence as the x-axis. Therefore, the plot shows how statistical power changes as the number of clusters assigned to each treatment sequence increases. The range is set from 1 to 6 clusters per sequence.

The remaining design parameters are fixed as follows:

Parameter Value Interpretation
Number of participants in each cluster-period 8 Each cluster contributes 8 participants during each period
Number of sequences 4 The stepped-wedge design has 4 treatment sequences
Mean difference, \(\delta\) 3.45 The anticipated intervention effect on the outcome scale
Standard deviation of baseline outcome, \(\sigma_{y0}\) 15 The marginal standard deviation of the baseline outcome
Standard deviation of endline outcome, \(\sigma_{y1}\) 15 The marginal standard deviation of the endline outcome
Significance level, \(\alpha\) 0.05 A two-sided 5% significance level

The ICC parameters are specified as follows:

Parameter Value Interpretation
Baseline within-period ICC, \(\rho^0_0\) 0.02 Correlation between baseline outcomes from different individuals in the same cluster and same period
Endline within-period ICC, \(\rho^1_0\) 0.02 Correlation between endline outcomes from different individuals in the same cluster and same period
Baseline between-period ICC, \(\rho^0_1\) 0.01 Correlation between baseline outcomes from individuals in the same cluster but different periods
Endline between-period ICC, \(\rho^1_1\) 0.01 Correlation between endline outcomes from individuals in the same cluster but different periods
Baseline-endline within-period ICC, \(\rho^{01}_0\) 0.01 Correlation between baseline and endline outcomes from different individuals in the same cluster and same period
Baseline-endline between-period ICC, \(\rho^{01}_1\) 0.005 Correlation between baseline and endline outcomes from individuals in the same cluster but different periods
Intra-subject ICC, \(\rho^{01}_2\) 0.70 Correlation between the baseline and endline outcomes for the same individual

These values represent a setting in which the within-period ICCs are modest, the between-period ICCs are smaller than the within-period ICCs, and the baseline and endline outcomes are strongly correlated within the same individual.

The resulting power curves show that power increases as the number of clusters per sequence increases. This is expected because increasing the number of clusters increases the total sample size and provides more information for estimating the treatment effect.

Under these input values, the ANCOVA and bivariate models provide the highest power. Their power curves are nearly identical in this example, suggesting that the simpler ANCOVA approach achieves almost the same efficiency as the fully bivariate model under these assumptions.

The change score model also improves over the endline-only model, but its power is lower than the ANCOVA and bivariate models. This reflects the fact that the change score approach uses baseline information, but it may not use it as efficiently as ANCOVA or the bivariate model.

The endline-only model has the lowest power because it ignores the baseline outcome. This comparison illustrates the potential efficiency gain from incorporating baseline outcome measurements when designing a cross-sectional SW-CRT.

For example, when there are 4 clusters per sequence, the ANCOVA and bivariate models achieve substantially higher power than the endline-only model. Therefore, if baseline outcome measurements are available, using a baseline-adjusted analysis can reduce the number of clusters or participants needed to achieve a target power.

Overall, this example suggests that, for this design and set of ICC assumptions, incorporating the baseline outcome is beneficial. The ANCOVA model may be a practical choice because it is easier to specify than the bivariate model while providing very similar power in this example.

12 Practical Guidance

For most applied trial planning settings, the ANCOVA model is often a practical starting point because it adjusts for the baseline outcome directly and requires fewer correlation parameters than the bivariate model.

The bivariate model may be preferred when investigators have sufficient information to specify the joint correlation structure of baseline and endline outcomes.

The change score model is easy to understand, but it may not always be more efficient than the endline-only model. Its performance depends heavily on the intra-subject correlation between baseline and endline outcomes.

When possible, investigators should conduct sensitivity analyses over plausible values of the ICC parameters, especially the within-period ICC, between-period ICC, and intra-subject ICC.

13 Summary

This Shiny app provides a practical tool for designing cross-sectional stepped-wedge cluster randomized trials with a baseline measurement of the outcome.

The app allows users to:

  • specify key design parameters,
  • enter baseline and endline ICC parameters,
  • compare different baseline-adjusted analysis models,
  • visualize power as a function of the number of clusters or cluster-period size.

By using this app, investigators can better understand the potential efficiency gains from incorporating baseline outcome measurements at the design stage of a stepped-wedge cluster randomized trial.