Package 'swdpwr'

Title: Power Calculation for Stepped Wedge Cluster Randomized Trials
Description: To meet the needs of statistical power calculation for stepped wedge cluster randomized trials, we developed this software. Different parameters can be specified by users for different scenarios, including: cross-sectional and cohort designs, binary and continuous outcomes, marginal (GEE) and conditional models (mixed effects model), three link functions (identity, log, logit links), with and without time effects (the default specification assumes no-time-effect) under exchangeable, nested exchangeable and block exchangeable correlation structures. Unequal numbers of clusters per sequence are also allowed. The methods included in this package: Zhou et al. (2020) <doi:10.1093/biostatistics/kxy031>, Li et al. (2018) <doi:10.1111/biom.12918>. Supplementary documents can be found at: <https://ysph.yale.edu/cmips/research/software/study-design-power-calculation/swdpwr/>. The Shiny app for swdpwr can be accessed at: <https://jiachenchen322.shinyapps.io/swdpwr_shinyapp/>. The package also includes functions that perform calculations for the intra-cluster correlation coefficients based on the random effects variances as input variables for continuous and binary outcomes, respectively.
Authors: Jiachen Chen [cre, aut], Xin Zhou [aut], Fan Li [aut], Donna Spiegelman. [aut]
Maintainer: Jiachen Chen <[email protected]>
License: GPL-3
Version: 1.11
Built: 2024-11-08 06:46:28 UTC
Source: CRAN

Help Index


Power Calculation for Stepped Wedge Cluster Randomized Trials

Description

This package includes a function swdpower that accounts for power calculation for stepped wedge cluster randomized trials.

Details

Package: swdpwr
Type: Package
Version: 1.11
Date: 2024-10-06
License: GPL (version 3)

Previous literature and developement of software focused mainly on continuous outcomes and obtained approximation results for binary outcomes. This package implemented new methods of power calculation for stepped wedge designs with binary outcomes and also incorporated procedures for continuous outcomes. The function swdpower can accommodate both cross-sectional and cohort designs, binary and continuous outcomes, marginal (GEE) and conditional models (mixed effects model), three link functions (identity, log, logit links), with and without time effects (the default specification assumes no-time-effect) under exchangeable, nested exchangeable and block exchangeable correlation structures. Unequal numbers of clusters per sequence are also allowed. With this package, investigators can obtain more accurate calculation of statistical power, that will help a lot in the design and analysis of stepped wedge cluster randomized trials. The package also includes functions that perform calculations for the intra-cluster correlation coefficients based on the random effects variances as input variables for continuous and binary outcomes, respectively. Other supplementary documents can be found at: https://ysph.yale.edu/cmips/research/software/study-design-power-calculation/swdpwr/. The Shiny app for swdpwr can be accessed at: <https://jiachenchen322.shinyapps.io/swdpwr_shinyapp/>.

Author(s)

Jiachen Chen, Xin Zhou , Fan Li and Donna Spiegelman.

Maintainer:Jiachen Chen <[email protected]>

References

Zhou X, Liao X, Kunz L M, et al. A maximum likelihood approach to power calculations for stepped wedge designs of binary outcomes[J]. Biostatistics, 2020, 21(1): 102-121.

Li F, Turner E L, Preisser J S. Sample size determination for GEE analyses of stepped wedge cluster randomized trials[J]. Biometrics, 2018, 74(4): 1450-1458.


A function for calculating the intracluster correlation coefficient (ICC) for binary outcomes given the cluster level random effects variance

Description

This function calculates the ICC (intracluster correlation coeffcient which measures the correlation between individuals in the same cluster) under different link funcitions in a cross-sectional stepped wedge CRT with binary outcomes. This model considers only the fixed time effects and does not include cluster by time interaction random effect.

Usage

BinICC(link = "identity", meanresponse_start, tau2 = 0)

Arguments

link

choose link function from link="identity", link="log" and link="logit", with default value of identity link

meanresponse_start

the anticipated mean response in the control group at the start of the study

tau2

also denoted as sigma_b: variance of the between-cluster random effect, default is 0

Value

The object returned includes the link function and value for the ICC in this study

Examples

BinICC(link="identity",meanresponse_start=0.2,tau2=0.05)

A function for calculating ICCs for continuous outcomes given random effects variances

Description

This function calculates the within-period, between-period, and within-individual correlation parameters for continuous outcomes in a stepped wedge CRT

Usage

ContICC(
  type = "cross-sectional",
  sigma2 = 1,
  sigma_b = 0,
  sigma_c = 0,
  sigma_pi = NA
)

Arguments

type

choose the study type, specify type="cohort" for closed cohort study and type="cross-sectional" for cross-sectional study, default is "cross-sectional"

sigma2

marginal variance of the outcom, default is 1

sigma_b

variance of the between-cluster random effect, default is 0

sigma_c

variance of the cluster-by-time interaction random effect, default is 0

sigma_pi

variance of the random effect for repeated measures of one individual, this parameter should not be specified for cross-sectional studies, default is NA

Value

The object returned includes the study type and values for the ICCs in this study

Examples

ContICC(type="cohort",sigma2=1.5,sigma_b=0.5,sigma_c=0.2,sigma_pi=0.3)

Print the results of swdpower

Description

The print method for class "swdpower"

Usage

## S3 method for class 'swdpower'
print(x, ...)

Arguments

x

an object used to select a method.

...

further arguments passed to or from other methods.

Value

The output from print


A function of power calculation for Stepped Wedge Design Studies

Description

This function performs power calculations for stepped wedge cluster randomized trials under different scenarios. The default setting assumes no time effect; to include time effects, set meanresponse_start and meanresponse_end0 to different values. Please refer to the documentation for guidance on incorporating time effects.

Usage

swdpower(
  K,
  design,
  family = "binomial",
  model = "conditional",
  link = "identity",
  type = "cross-sectional",
  meanresponse_start = NA,
  meanresponse_end0 = meanresponse_start,
  meanresponse_end1 = NA,
  effectsize_beta = NA,
  sigma2 = 0,
  typeIerror = 0.05,
  alpha0 = 0.1,
  alpha1 = alpha0/2,
  alpha2 = NA
)

Arguments

K

number of participants at each time period in a cluster, specified as the average clusterperiod size considering cluster-size variability

design

I*J dimensional data set that describes the study design (control 0, intervention 1), I is the number of clusters, J is the number of time periods. Unequal allocation of sequences and only complete designs with no transition periods are allowed

family

family of responses, specify family="gaussian" for continuous outcome and family="binomial" for binary outcome, with default value of "binomial"

model

choose from conditional model (model="conditional") and marginal model (model="marginal"), with default value of applying conditional model

link

choose link function from link="identity", link="log" and link="logit", with default value of identity link

type

choose the study type, specify type="cohort" for closed cohort study and type="cross-sectional" for cross-sectional study, with default value of cross-sectional study

meanresponse_start

the anticipated mean response in the control group at the start of the study

meanresponse_end0

the anticipated mean response in the control group at the end of the study, with default value equals to meanresponse_start (no time effects). To include time effects in your model, set meanresponse_start and meanresponse_end0 to different values.

meanresponse_end1

the anticipated mean response in the intervention group at the end of the study

effectsize_beta

the anticipated effect size, just omit this parameter if you don't need to specify it. In all scenarios, you can choose to specify the three parameters about mean responses without specifying this effect size, or alternatively specify meanresponse_start, meanresponse_end0 and this effect size. For continuous outcomes, users can conduct power calculations by only specifying this parameter without the above three parameters about mean responses (as the power is dependent just on it), then calculation will be implemented assuming scenarios without time effects. If you would consider scenarios with time effects and continuous outcomes, please specify meanresponse_start, meanresponse_end0 (donot require accurate information, just make sure they are not equal) and this effectsize_beta.

sigma2

marginal variance of the outcome (only needed for continuous outcomes and should not be an input for binary outcomes), with default value of 0.

typeIerror

two-sided type I error, with default value of 0.05

alpha0

within-period correlation, with default value of 0.1

alpha1

between-period correlation, with default value of alpha0/2

alpha2

within-individual correlation, should not be an input under cross-sectional designs although it is numerically identical to alpha1 in this scenario by definition

Value

The object returned has a class of swdpower, which includes a list of the design matrix and a summary of this design (including the power)

Examples

library(swdpwr)
#a cross-sectional design with 12 clusters, 3 periods and binary outcomes applying conditional model
#alpha2 should not be specified, as the current version does not support power calculation using
#conditional models with binary outcomes in a cohort design
#create a 12*3 matrix which describes the study design,
#0 means control status, 1 means intervention status
dataset = matrix(c(rep(c(0,1,1),6),rep(c(0,0,1),6)),12,3,byrow=TRUE)

#specify meanresponse_start, meanresponse_end0 and meanresponse_end1
swdpower(K = 30, design = dataset, family = "binomial", model = "conditional", link = "logit",
type = "cross-sectional", meanresponse_start = 0.2, meanresponse_end0 = 0.3,
meanresponse_end1 = 0.4, typeIerror = 0.05, alpha0 = 0.01, alpha1 = 0.01)

#specify meanresponse_start, meanresponse_end0 and effectsize_beta
swdpower(K = 30, design = dataset, family = "binomial", model = "conditional", link = "logit",
type = "cross-sectional", meanresponse_start = 0.2, meanresponse_end0 = 0.3, effectsize_beta = 0.6,
typeIerror = 0.05, alpha0 = 0.01, alpha1 = 0.01)

#a cohort design with 8 clusters, 3 periods and continuous outcomes applying marginal model
#sigma2 should be specified, as continuous outcomes require marginal variance in calculation
#create a 8*3 matrix which describes the study design,
#0 means control status, 1 means intervention status
dataset = matrix(c(rep(c(0,1,1),4),rep(c(0,0,1),4)),8,3, byrow=TRUE)

#specify meanresponse_start, meanresponse_end0 and meanresponse_end1 assuming time effects
swdpower(K = 24, design = dataset, family = "gaussian", model = "marginal", link = "identity",
type = "cohort", meanresponse_start = 0.1, meanresponse_end0 = 0.2,  meanresponse_end1 = 0.4,
sigma2 = 0.095, typeIerror = 0.05, alpha0 = 0.03, alpha1 = 0.015, alpha2 = 0.2)

#specify meanresponse_start, meanresponse_end0 and effectsize_beta assuming time effects.
#As an alternative to the previous example, the time effect specification for meanresponse_start
#and meanresponse_end0 does not need to be precise (make sure they are not equal).
swdpower(K = 24, design = dataset, family = "gaussian", model = "marginal", link = "identity",
type = "cohort", meanresponse_start = 0.1, meanresponse_end0 = 0.2,  effectsize_beta=0.2,
sigma2 = 0.095, typeIerror = 0.05, alpha0 = 0.03, alpha1 = 0.015, alpha2 = 0.2)

#specify effectsize_beta only, then the program runs assuming no time effects
swdpower(K = 24, design = dataset, family = "gaussian", model = "marginal", link = "identity",
type = "cohort",effectsize_beta=0.3, sigma2 = 0.095, typeIerror = 0.05, alpha0 = 0.03,
alpha1 = 0.015, alpha2 = 0.2)