This set of functions utilize iterative simulations to determine approximate power for stepped wedge cluster-randomized controlled trials. Users can modify a variety of parameters to suit the simulations to their desired experimental situation.
cps.sw.normal(
nsim = NULL,
nsubjects = NULL,
nclusters = NULL,
mu0 = 0,
mu1 = NULL,
steps = NULL,
sigma_sq = NULL,
sigma_b_sq = NULL,
alpha = 0.05,
method = "glmm",
quiet = FALSE,
allSimData = FALSE,
poorFitOverride = FALSE,
lowPowerOverride = FALSE,
timelimitOverride = TRUE,
seed = NULL
)
Number of datasets to simulate; accepts integer (required).
Number of subjects per cluster; accepts either a scalar (equal cluster sizes)
or a vector of length nclusters
(user-defined size for each cluster) (required).
Number of clusters; accepts non-negative integer scalar (required).
Expected baseline mean; accepts numeric, default 0. Required..
Expected post-treatment mean; accepts numeric. Required.
Number of crossover steps; a baseline step (all clusters in non-treatment group) is assumed.
Accepts positive scalar (indicating the total number of steps; clusters per step is obtained by
nclusters / steps
) or a vector of non-negative integers corresponding either to the number
of clusters to be crossed over at each time point (e.g c(2,4,4,2); nclusters = 10) or the cumulative
number of clusters crossed over by a given time point (e.g. c(2,4,8,10); nclusters = 10) (required).
Within-cluster variance; accepts non-negative numeric scalar (indicating equal within-cluster variances for both treatment groups) or a vector of length 2 specifying within-cluster variances for the non-treatment and treatment groups, respectively (required).
Between-cluster variance; accepts non-negative numeric scalar (indicating equal between-cluster variances for both treatment groups) or a vector of length 2 specifying treatment-specific between-cluster variances (required).
Significance level. Default = 0.05.
Analytical method, either Generalized Linear Mixed Effects Model (GLMM) or Generalized Estimating Equation (GEE). Accepts c('glmm', 'gee') (required); default = 'glmm'.
When set to FALSE, displays simulation progress and estimated completion time; default is FALSE.
Option to output list of all simulated datasets; default = FALSE.
Option to override stop()
if more than 25%
of fits fail to converge; default = FALSE.
Option to override stop()
if the power
is less than 0.5 after the first 50 simulations and every ten simulations
thereafter. On function execution stop, the actual power is printed in the
stop message. Default = FALSE. When TRUE, this check is ignored and the
calculated power is returned regardless of value.
Logical. When FALSE, stops execution if the estimated completion time is more than 2 minutes. Defaults to TRUE.
Option to set.seed. Default is NULL.
A list with the following components
Character string indicating total number of simulations and simulation type
Number of simulations
Data frame with columns "Power" (Estimated statistical power), "lower.95.ci" (Lower 95 "upper.95.ci" (Upper 95
Analytic method used for power estimation
Significance level
Vector containing user-defined cluster sizes
Vector containing user-defined number of clusters
Data frame reporting ICC, within & between cluster variances for Treatment/Non-Treatment groups at each time point
Vector containing expected means for each arm based on user inputs
Data frame containing mean response values for each treatment group at each time point
Matrix showing cluster crossover at each time point
Data frame with columns: "Estimate" (Estimate of treatment effect for a given simulation), "Std.err" (Standard error for treatment effect estimate), "Test.statistic" (z-value (for GLMM) or Wald statistic (for GEE)), "p.value", "sig.val" (Is p-value less than alpha?)
If allSimData = TRUE
, a list of data frames, each containing:
"y" (Simulated response value),
"trt" (Indicator for treatment group),
"time.point" (Indicator for step; "t1" = time point 0)
"clust" (Indicator for cluster),
"period" (Indicator for at which step a cluster crosses over)
If nofit = T
, a data frame of the simulated data sets, containing:
"arm" (Indicator for treatment arm)
"cluster" (Indicator for cluster)
"y1" ... "yn" (Simulated response value for each of the nsim
data sets).
Runs power simulations for stepped wedge cluster-randomized controlled trials with continuous outcome. The stepped wedge trial design is a type of cross-over design in which clusters change treatments in waves. Initially all the clusters recieve the same standard treatment, and at the end of the trial all of the clusters will be recieving the treatment of interest. More than one cluster can change treatments in a wave, but the order in which clusters change treatments is randomly determined. The outcome of interest is assessed in each cluster during each wave.
Users must specify the desired number of simulations, number of subjects per cluster, number of clusters per arm, expected means for each arm, within-cluster variance, between-cluster variance, significance level, analytic method, progress updates, and simulated data set output may also be specified.
# NOT RUN {
# Estimate power for a trial with 3 steps and 9 clusters in arm 1 (often the
# standard-of-care or 'control' arm) at the initiation of the study. Those
# clusters have 14 subjects each, with sigma_b = 1 and sigma_b_sq = 1. We
# have estimated arm outcome means of 1 and 2.1 in the first and second arms,
# respectively, and 100 simulated data sets analyzed by the GLMM method. Using seed = 123,
# the resulting power should be 0.82.
# }
# NOT RUN {
normal.sw.rct = cps.sw.normal(nsim = 100, nsubjects = 14, nclusters = 9,
mu0 = 1, mu1 = 2.1, steps = 3, sigma_sq = 1,
sigma_b_sq = 1, alpha = 0.05, method = 'glmm',
seed = 123)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab