cps.normal: Power simulations for cluster-randomized trials: Parallel...

Description Usage Arguments Details Value Testing details Author(s) Examples

View source: R/cps.normal.R

Description

\loadmathjax

This function uses Monte Carlo methods (simulations) to estimate power for parallel design cluster-randomized trials with normal outcomes. Users can modify a variety of parameters to suit the simulations to their desired experimental situation.

Users must specify the desired number of simulations, number of subjects per cluster, number of clusters per arm, expected means of the arms, and two of the following: ICC, within-cluster variance, or between-cluster variance. Defaults are provided for significance level, analytic method, progress updates, and whether the simulated data sets are retained.

Users have the option of specifying different variance parameters for each arm, different numbers of clusters for each treatment group, and different numbers of units within each cluster.

Non-convergent models are not included in the calculation of exact confidence intervals.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
cps.normal(
  nsim = NA,
  nclusters = NA,
  nsubjects = NA,
  mu = 0,
  mu2 = NA,
  ICC = NA,
  sigma_sq = NA,
  sigma_b_sq = NA,
  ICC2 = NA,
  sigma_sq2 = NA,
  sigma_b_sq2 = NA,
  alpha = 0.05,
  method = "glmm",
  quiet = FALSE,
  allSimData = FALSE,
  seed = NA,
  poorFitOverride = FALSE,
  timelimitOverride = TRUE,
  lowPowerOverride = FALSE,
  irgtt = FALSE,
  nofit = FALSE
)

Arguments

nsim

Number of datasets to simulate; accepts integer. Required.

nclusters

Number of clusters per condition; accepts single integer (implying equal numbers of clusters in the two groups) or vector of length 2 (unequal number of clusters per arm). Required.

nsubjects

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

mu

Mean in the first arm; accepts numeric, default 0. Required..

mu2

Mean in the second arm; accepts numeric. Required.

At least 2 of the following must be specified:

ICC

Intra-cluster correlation coefficient; accepts a value between 0 and 1.

sigma_sq

Within-cluster variance; accepts numeric.

sigma_b_sq

Between-cluster variance; accepts numeric.

The defaults for the following are all NA, implying equal variance parameters for the two groups. If one of the following is given, variance parameters differ between treatment groups, and at least 2 of the following must be specified:

ICC2

Intra-cluster correlation coefficient for clusters in the second arm.

sigma_sq2

Within-cluster variance for clusters in the second arm.

sigma_b_sq2

Between-cluster variance for clusters in the second arm.

Optional parameters:

alpha

Significance level; default = 0.05.

method

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

quiet

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

allSimData

Option to include a list of all simulated datasets in the output object. Default = FALSE.

seed

Option to set the seed. Default, NA, selects a seed based on the system clock.

poorFitOverride

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

timelimitOverride

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

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.

irgtt

Logical. Default = FALSE. Is the experimental design an individually randomized group treatment trial? For details, see ?cps.irgtt.normal.

nofit

Option to skip model fitting and analysis and instead return a dataframe with the simulated datasets. Default = FALSE.

Details

The data generating model for observation \mjseqni in cluster \mjseqnj is: \mjsdeqny_ij \sim N(\mu + b_i, \sigma^2) for the first group or arm, where \mjseqnb_i \sim N(0,\sigma_b^2) , while for the second group,

\mjsdeqn

y_ij \sim N(\mu_2 + b_i, \sigma_2^2) where \mjseqnb_i \sim N(0,\sigma_b_2^2); if none of \mjseqn\sigma_2^2, \sigma_b_2^2 or ICC2 are used, then the second group uses \mjseqnb_i \sim N(0,\sigma_b^2) and \mjseqny_ij \sim N(\mu_2 + b_i, \sigma^2) .

All random terms are generated independent of one another.

For calls without \mjseqn\sigma_2^2, \sigma_b_2^2 or ICC2, and using method="glmm" the fitted model is: \mjsdeqny_ij|b_i = \mu + \beta_1 x_ij + b_i + e_ij

with \mjseqn\beta_1 = \mu_2 - \mu, treatment group indicator \mjseqnx_ij = 0 for the first group, with \mjseqnb_i \sim N(0, \sigma_b^2) and \mjseqne_ij \sim N(0,\sigma^2). In this case, both the random effects distribution and the residual distribution are the same for both conditions.

Otherwise, for method="glmm" the fitted model is: \mjsdeqny_ij|b_i = \mu + \beta_1 x_ij + b_i I(x_ij=0) + e_ij I(x_ij=0) + g_i I(x_ij=1) + f_ij I(x_ij=1)

with \mjseqn\beta_1, \mjseqnx_ij, b_i, and \mjseqne_ij as above, with \mjseqng_i \sim N(0, \sigma_b_2^2) and \mjseqnf \sim N(0,\sigma_2^2), the random effects and residual distribution in the second group.

Value

If nofit = F, a list with the following components:

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

Testing details

This function has been verified, where possible, against reference values from the NIH's GRT Sample Size Calculator, PASS11, CRTsize::n4means, and clusterPower::cpa.normal.

Author(s)

Alexander R. Bogdan, Alexandria C. Sakrejda (acbro0@umass.edu), and Ken Kleinman (ken.kleinman@gmail.com)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Estimate power for a trial with 10 clusters in each arm and 25 subjects in each 
# cluster, with an ICC of .3, sigma squared of 20 (implying sigma_b^2 of 8.57143) 
# in each group, with arm means of 1 and 4.75 in the two groups, using 100 simulated 
# data sets. The resulting estimated power should be 0.78.
   
## Not run: 

normal.sim = cps.normal(nsim = 100, nsubjects = 25, nclusters = 10, mu = 1, 
  mu2 = 4.75, ICC = 0.3, sigma_sq = 20, seed = 123)

## End(Not run)



# Estimate power for a trial with 5 clusters in one arm, those clusters having 25 subjects 
# each, 25 clusters in the other arm, those clusters having 5 subjects each, the first arm
# having a sigma squared of 20 and sigma_b squared of 8.57143, and the second a sigma squared
# of 9 and a sigma_b squared of 1, with estimated arm means of 1 and 4.75 in the first and 
# second groups, respectively, using 100 simulated data sets analyzed by the GEE method. 
# The estimated power should be 0.79, assuming seed = 123.

## Not run: 
normal.sim2 = cps.normal(nsim = 100, nclusters = c(5,25), nsubjects = c(25,5), mu = 1, 
  mu2 = 4.75, sigma_sq = 20,sigma_b_sq = 8.8571429, sigma_sq2 = 9, sigma_b_sq2 = 1, 
  method = "gee", seed = 123)

## End(Not run)


# Estimate power for a trial with 5 clusters in one arm, those clusters having
# 4, 5, 6, 7, 7, and 7 subjects each, and 10 clusters in the other arm,
# those clusters having 5 subjects each, with sigma_b_sq = .3 and and ICC of .3 in both arms.
# We have estimated arm means of 1 and 2 in the first and second arms, respectively, and we use
# 100 simulated data sets analyzed by the GLMM method.

## Not run: 
normal.sim2 = cps.normal(nsim = 100, nclusters = c(6,10), 
  nsubjects = list(c(4, 5, 6, 7, 7, 7), rep(5, times = 10)),
  mu = 1, mu2 = 2, sigma_b_sq = .3, ICC = .3, method = "glmm",
  seed = 1)

## End(Not run)

# The resulting estimated power (if you set seed = 1) should be about 0.76.

# Estimate power for a trial with 3 clusters in one arm, 
# those clusters having 25, 35, and 45 subjects each, and 10 clusters 
# in the other arm, those clusters having 5 subjects each, the first arm
# having a sigma squared of 20 and sigma_b squared of 8.57143, and the second a sigma squared
# of 9 and a sigma_b squared of 1, with estimated arm means of 1 and 4.75 in the first and 
# second groups, respectively, using 100 simulated data sets analyzed by the GLMM method.

## Not run: 

normal.sim2 <- cps.normal(nsim = 100, nclusters = c(3,10), 
  nsubjects = c(25, 35, 45, rep(5, times = 10)),
  mu = 1, mu2 = 4.75, sigma_sq = 20, sigma_b_sq = 8.8571429,
  sigma_sq2 = 9, sigma_b_sq2 = 1, method = "glmm")

## End(Not run)

# The resulting estimated power (if you set seed = 1) should be about 0.71.

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