Learn R Programming

clusterPower (version 0.7.0)

cps.sw.binary: Power simulations for cluster-randomized trials: Stepped Wedge Design, Binary Outcome

Description

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.

Usage

cps.sw.binary(
  nsim = NULL,
  nsubjects = NULL,
  nclusters = NULL,
  p0 = NULL,
  p1 = NULL,
  steps = NULL,
  sigma_b_sq = NULL,
  alpha = 0.05,
  method = "glmm",
  quiet = FALSE,
  allSimData = FALSE,
  poorFitOverride = FALSE,
  lowPowerOverride = FALSE,
  timelimitOverride = TRUE,
  optmethod = "L-BFGS-B",
  seed = NULL
)

Arguments

nsim

Number of datasets to simulate; accepts integer (required).

nsubjects

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).

nclusters

Number of clusters; accepts non-negative integer scalar (required).

p0

Expected probability of outcome in arm 1. Accepts scalar between 0 - 1 (required).

p1

Expected probability of outcome in arm 2. Accepts scalar between 0 - 1 (required).

steps

Number of crossover steps; a baseline step (all clusters in arm 1) 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).

sigma_b_sq

Between-cluster variance; accepts non-negative numeric scalar (indicating equal between-cluster variances for both arms) or a vector of length 2 specifying treatment-specific between-cluster variances (required).

alpha

Significance level. Default = 0.05.

method

Analytical method, either Generalized Linear Mixed Effects Model (GLMM) or Generalized Estimating Equation (GEE). Accepts c('glmm', 'gee') (required); default = 'glmm'.

quiet

When set to FALSE, displays simulation progress and estimated completion time; default is FALSE.

allSimData

Option to output list of all simulated datasets; default = FALSE.

poorFitOverride

Option to override stop() if more than 25% of fits fail to converge; default = FALSE.

lowPowerOverride

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.

timelimitOverride

Logical. When FALSE, stops execution if the estimated completion time is more than 2 minutes. Defaults to TRUE.

optmethod

Option to fit with a different optimizer method (using the package optimx). Default is 'L-BFGS-B'.

seed

Option to set.seed. Default is NULL.

Value

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 both arms at each time point

  • Vector containing expected difference between groups based on user inputs

  • Data frame containing mean response values for each arm 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 arm), "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)

  • "clust" (Indicator for cluster)

  • "y1" ... "yn" (Simulated response value for each of the nsim data sets).

Details

Runs power simulations for stepped wedge cluster-randomized controlled trials with a binary 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 absolute difference between arms, within-cluster variance, between-cluster variance, significance level, analytic method, progress updates, and simulated data set output may also be specified.

Examples

Run this code
# NOT RUN {
# Estimate power for a trial with 3 steps and 12 clusters in arm 1
# (often the standard-of-care or 'control' arm) at the initiation of the study.
# Those clusters have 50 subjects each, with sigma_b_sq = 1.
# We have estimated arm outcome proportions of 0.1 and 0.2 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.8.

# }
# NOT RUN {
binary.sw.rct = cps.sw.binary(nsim = 100, nsubjects = 50, nclusters = 12,
                              p0 = 0.1, p1 = 0.2, steps = 3,
                              sigma_b_sq = 1, alpha = 0.05, method = 'glmm',
                              quiet = FALSE, allSimData = FALSE, seed = 123)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab