cps.did.normal: Power simulations for cluster-randomized trials: Difference...

Description Usage Arguments Value Author(s) Examples

View source: R/cps.did.normal.R

Description

\loadmathjax

This set of functions utilize iterative simulations to determine approximate power for difference in difference cluster-randomized controlled trials. Users can modify a variety of parameters to suit the simulations to their desired experimental situation.

Runs the power simulation for difference in difference (DID) cluster-randomized controlled trial.

Users must specify the desired number of simulations, number of subjects per cluster, number of clusters per arm, expected absolute difference between arms, two of the following: ICC, within-cluster variance, or between-cluster variance; significance level, analytic method, progress updates, and simulated data set output may also be specified.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
cps.did.normal(
  nsim = NULL,
  nsubjects = NULL,
  nclusters = NULL,
  delta_mu = 0,
  delta_mu2 = NULL,
  sigma_sq = NULL,
  sigma_b_sq0 = NULL,
  sigma_b_sq1 = 0,
  alpha = 0.05,
  method = "glmm",
  poorFitOverride = FALSE,
  lowPowerOverride = FALSE,
  timelimitOverride = TRUE,
  quiet = FALSE,
  allSimData = FALSE,
  seed = NA,
  nofit = FALSE
)

Arguments

nsim

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

nsubjects

Number of subjects per arm; accepts either a scalar (equal cluster sizes, both groups), a vector of length two (equal cluster sizes within groups), or a vector of length sum(nclusters) (unequal cluster sizes within groups) (required).

nclusters

Number of clusters per group; accepts integer scalar or vector of length 2 for unequal number of clusters per arm (required)

delta_mu

Default = 0. Reference arm expected change between from baseline to followup.

delta_mu2

Expected change in tretament arm at follow-up; accepts numeric (required).

sigma_sq

Within-cluster variance; accepts numeric scalar (indicating equal within-cluster variances for both arms at both time points) or vector of length 4 specifying within-cluster variance for each arm at each time point.

sigma_b_sq0

Pre-treatment (time == 0) between-cluster variance; accepts numeric scalar (indicating equal between-cluster variances for both arms) or a vector of length 2 specifying treatment-specific between-cluster variances

sigma_b_sq1

Post-treatment (time == 1) between-cluster variance; accepts numeric scalar (indicating equal between-cluster variances for both arm) or a vector of length 2 specifying treatment-specific between-cluster variances. For data simulation, sigma_b_sq1 is added to sigma_b_sq0, such that if sigma_b_sq0 = 5 and sigma_b_sq1 = 2, the between-cluster variance at time == 1 equals 7. Default = 0.

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

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.

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.

seed

Option to set the seed. Default is NA.

nofit

Option to skip model fitting and analysis and only return the simulated data. Default = FALSE.

Value

A list with the following components:

If nofit = T, a data frame of the simulated data sets, containing:

Author(s)

Alexander R. Bogdan

Alexandria C. Sakrejda (acbro0@umass.edu)

Ken Kleinman (ken.kleinman@gmail.com)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Estimate power for a trial with 6 clusters in arm 1 and 6 clusters in arm 2,
# those clusters having 120 subjects each, with sigma_sq = 1. Estimated
# arm mean changes are 0 and 0.48 in the first and second arms, respectively, and we use
# 100 simulated data sets analyzed by the GLMM method. The resulting estimated
# power (for seed = 123) should be 0.81.

## Not run: 
normal.did.rct = cps.did.normal(nsim = 100, nsubjects = 120, nclusters = 6,
                                delta_mu = 0, delta_mu2 = 0.48, sigma_sq = 1, alpha = 0.05,
                                sigma_b_sq0 = 0.1, method = 'glmm', seed = 123)

## End(Not run)

clusterPower documentation built on Jan. 29, 2021, 1:06 a.m.