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

Description Usage Arguments Value Author(s) References Examples

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

Description

\loadmathjax

This function utilizes iterative simulations to determine approximate power for 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 RCTs with binary outcomes.

Users must specify the desired number of simulations, number of subjects per cluster, number of clusters per arm, pre-treatment between-cluster variance, and two of the following three terms: expected probability of outcome in arm 1, expected probability of outcome in arm 2, expected difference in probabilities between groups ; post-treatment between-cluster variance, significance level, analytic method, progress updates, and simulated data set output may also be specified.

The following equations are used to estimate intra-cluster correlation coefficients:

P_h: \mjsdeqnICC = \frac\sigma_b\sigma_b + \pi^2/3 P_c: \mjsdeqnICC = \fracP(Y_ij = 1, Y_ih = 1) - \pi_j\pi_h\sqrt\pi_j(1 - \pi_j)\pi_h(1 - \pi_h) P_lmer: \mjsdeqnICC = \frac\sigma_b\sigma_b + \sigma_w

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
cps.did.binary(
  nsim = NULL,
  nsubjects = NULL,
  nclusters = NULL,
  p.diff = NULL,
  p1t0 = 0,
  p2t0 = NULL,
  p1t1 = NULL,
  p2t1 = NULL,
  or1 = NULL,
  or2 = NULL,
  or.diff = NULL,
  sigma_b_sq0 = NULL,
  sigma_b_sq1 = NULL,
  alpha = 0.05,
  method = "glmm",
  quiet = TRUE,
  allSimData = FALSE,
  poorFitOverride = FALSE,
  lowPowerOverride = FALSE,
  timelimitOverride = TRUE,
  seed = NA,
  nofit = FALSE
)

Arguments

nsim

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

nsubjects

Number of subjects per cluster; accepts integer (required).

nclusters

Number of clusters per arm; accepts integer (required).

p.diff

Optional if p1t1 and p2t0 are provided. Expected difference in outcome proportion between groups, defined as p.diff = (p1t1 - p1t0) - (p2t1 - p2t0).

At least 2 of the following 3 arguments must be specified when using expected odds ratios:

p1t0

Required. Expected outcome proportion in arm 1 at baseline. Default is 0.

p2t0

Optional. Expected outcome proportion in arm 2 at baseline. If no quantity is provided, p2t0 = p1t0 is assumed.

p1t1

Optional. Expected outcome proportion in arm 1 at follow-up. If no quantity is provided, p1t1 = p1t0 is assumed.

p2t1

Required. Expected outcome proportion in arm 2 at follow-up.

or1

Expected odds ratio for outcome in arm 1

or2

Expected odds ratio for outcome in arm 2

or.diff

Expected difference in odds ratio for outcome between groups, defined as or.diff = or1 - or2.

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 arms) or a vector of length 2 specifying treatment-specific between-cluster variances. If not provided by the user, sigma_b_sq1 = sigma_b_sq0.

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 start time and completion time. Default is TRUE.

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.

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)

References

Snjiders, T. & Bosker, R. Multilevel Analysis: an Introduction to Basic and Advanced Multilevel Modelling. London, 1999: Sage.

Elridge, S., Ukoumunne, O. & Carlin, J. The Intra-Cluster Correlation Coefficient in Cluster Randomized Trials: A Review of Definitions. International Statistical Review (2009), 77, 3, 378-394. doi: 10.1111/j.1751-5823.2009.00092.x

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Estimate power for a trial with 10 clusters in both arms, those clusters having
# 20 subjects each, with sigma_b_sq0 = 1. We have estimated arm proportions of 0.2
# and 0.3 in the first and second arms, respectively, and we use
# 100 simulated data sets analyzed by the GLMM method. The resulting estimated power 
# (if you set seed = 123) should be about 0.78.

## Not run: 
did.binary.sim = cps.did.binary(nsim = 100, nsubjects = 20, nclusters = 10, 
                                p1t0 = 0.1, p2t0 = 0.1,  
                                p1t1 = 0.2, p2t1 = 0.45, sigma_b_sq0 = 1, 
                                sigma_b_sq1 = 1, alpha = 0.05,
                                method = 'glmm', allSimData = FALSE, seed = 123)

## End(Not run)

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