Learn R Programming

swCRTdesign (version 3.3)

swGlmPwr: Power of Stepped Wedge Cluster Randomized Trial with Discrete Outcomes

Description

swGlmPwr returns (two-sided) power of the treatment effect for the specified SW CRT design in the context of generalized linear models by adopting the Laplace approximation detailed in Breslow and Clayton (1993) to obtain the covariance matrix of the estimated parameters. The response/outcome of interest can be binomial or Poisson distributed. The outcome is assumed to come from a model with fixed treatment effect (using an immediate treatment (IT) or exposure time indicator (ETI) model - see Kenny et al (2022)), fixed time effect, random intercepts, random treatment effects, and random cluster-specific time effects. The coefficients for fixed effects can be specified using fixed.intercept, fixed.treatment.effect, and fixed.time.effect. Variance components can be specified using tau, eta, rho, and gamma.

Usage

swGlmPwr(design, distn, n, fixed.intercept,
fixed.treatment.effect, fixed.time.effect, H = NULL,
tau = 0, eta = 0, rho = 0, gamma = 0, alpha=0.05, retDATA = FALSE)

Value

numeric (scalar): swGlmPwr returns the power of treatment effect if retDATA = FALSE.

numeric (list): swGlmPwr returns all specified and computed items as objects of a list if retDATA = TRUE.

$design

list: A stepped wedge design object, typically from swDsn, that includes at least the following components: swDsn, swDsn.unique.clusters, clusters, n.clusters, total.time

$distn

character: Distribution assumed (binomial or Poisson). "binomial" implies binomial outcomes and "poisson" implies Poisson outcome.

$n

integer (scalar, vector, or matrix): Number of observations: (scalar) for all clusters and all time points; (vector) for each cluster at all time points; and (matrix) for each cluster at each time point, where rows correspond to clusters and columns correspond to time. n can also be used to specify a design with transition periods (e.g. in the first time period that each sequence receives treatment, no observations are collected from that sequence). Simply define n as a matrix with a sample size of 0 during every transition period.

$fixed.intercept

numeric (scalar): Intercept for the fixed effect on canonical scales (logit for binomial outcomes and log for Poisson outcomes).

$fixed.treatment.effect

numeric (scalar): Coefficient for the treatment in the fixed effect model on canonical scales (logit for binomial outcomes and log for Poisson outcomes).

$fixed.time.effect

numeric(scalar, vector): Coefficients for the time (as dummy variables) in the fixed effect model on canonical scales (logit for binomial outcomes and log for Poisson outcomes). The first time point is always used as reference. A common time effect for all time points after the first (scalar) or differnt time effects for each time point after the first (vector of length (total time-1)).

$tau

numeric (scalar): Standard deviation of random intercepts on canonical scales (logit for binomial outcomes and log for Poisson outcomes).

$eta

numeric (scalar): Standard deviation of random treatment effects on canonical scales (logit for binomial outcomes and log for Poisson outcomes).

$rho

numeric (scalar): Correlation between random intercepts and random treatment effects on canonical scales (logit for binomial outcomes and log for Poisson outcomes).

$gamma

numeric (scalar): Standard deviation of random time effects on canonical scales (logit for binomial outcomes and log for Poisson outcomes).

$alpha

numeric (scalar): Statistical significance level. Default is 0.05.

$var.theta.null

numeric (scalar): Variance estimate of the estimated treatment effect under the null for this SW CRT design.

$var.theta.alt

numeric (scalar): Variance estimate of the estimated treatment effect under the alternative for this SW CRT design.

$pwrGLM

numeric (scalar): Power of treatment effect using a simplified Laplace approximation.

Arguments

design

list: A stepped wedge design object, typically from swDsn, that includes at least the following components: swDsn, swDsn.unique.clusters, clusters, n.clusters, total.time

distn

character: Distribution assumed (binomial or Poisson). "binomial" implies binomial outcomes and "poisson" implies Poisson outcome.

n

integer (scalar, vector, or matrix): Number of observations: (scalar) for all clusters and all time points; (vector) for each cluster at all time points; and (matrix) for each cluster at each time point, where rows correspond to clusters and columns correspond to time. n can also be used to specify a design with transition periods (e.g. in the first time period that each sequence receives treatment, no observations are collected from that sequence). Simply define n as a matrix with a sample size of 0 during every transition period.

fixed.intercept

numeric (scalar): Intercept for the fixed effect on canonical scales (logit for binomial outcomes and log for Poisson outcomes). It is the mean outcome under the control condition in the first time point transformed to the canonical scales.

fixed.treatment.effect

numeric (scalar, vector): If H = NULL then an IT model is assumed and and fixed.treatment.effect is the scalar coefficient for the treatment in the fixed effect model on canonical scales (logit for binomial outcomes and log for Poisson outcomes). If H is non-NULL then an ETI model is assumed and fixed.treatment.effect is a vector as long as the longest treatment effect lag (typically, number of time periods minus one) giving the coefficient for the treatment effect on the canonical scale.

fixed.time.effect

numeric(scalar, vector): Coefficients for the time (as dummy variables) in the fixed effect model on canonical scales (logit for binomial outcomes and log for Poisson outcomes). The first time point is always used as reference. Specify a common time effect for all time points after the first (scalar) or differnt time effects for each time point after the first (vector of length (total time-1)).

H

numeric (vector): If NULL, then swGlmPwr assumes an immediate, constant treatment effect (IT) model. If not NULL, then an exposure time indicator (ETI) model is assumed and H should be a vector as long as the longest treatment effect lag (typically, number of time periods minus one). H specifies the desired linear combination of fixed.treatment.effect. For example, in a stepped wedge trial with 5 time periods and four exposure times, H = rep(.25,4) gives the average treatment effect over the four exposure times; H = c(0,0,.5,.5) ignores the first two periods after the intervention is introduced and averages the remaining periods. Typically, the sum of H is 1.0.

tau

numeric (scalar): Standard deviation of random intercepts on canonical scales (logit for binomial outcomes and log for Poisson outcomes).

eta

numeric (scalar): Standard deviation of random treatment effects on canonical scales (logit for binomial outcomes and log for Poisson outcomes).

rho

numeric (scalar): Correlation between random intercepts and random treatment effects on canonical scales (logit for binomial outcomes and log for Poisson outcomes).

gamma

numeric (scalar): Standard deviation of random time effects on canonical scales (logit for binomial outcomes and log for Poisson outcomes).

alpha

numeric (scalar): Statistical significance level. Default is 0.05.

retDATA

logical: if TRUE, all stored (input, intermediate, and output) values of swGlmPwr are returned. Default value is FALSE.

Author

Fan Xia, James P Hughes, and Emily C Voldal

Details

The two-sided statistical power of treatment effect \(\theta\) (equal to H%*%fixed.treatment.effect if H is non-NULL) is $$Pwr(\theta) = \Phi( \frac{Z - z_{1 - \alpha /2} \sqrt{V_0(\hat{\theta})}}{\sqrt{V_\alpha(\hat{\theta})}}) + 1 - \Phi( \frac{Z+ z_{1 - \alpha /2} \sqrt{V_0(\hat{\theta})}}{\sqrt{V_\alpha(\hat{\theta})}})$$, where \(\Phi\) is the cumulative distribution function of the standard normal distribution.

The variance of \(\hat{\theta}\) under the null is denoted as \(V_0(\hat{\theta})\), and the variance of \(\hat{\theta}\) under the alternative is denoted as \(V_\alpha(\hat{\theta})\)). Both variances are approximated by simplifying the Laplace approximation that marginalizes the random effects in the generalized linear mixed models. For more details, see Xia et al. (2020).

When the outcome is Gaussian, the method adopted by swGlmPwr coincides with that of swPwr, so power calculation for Gaussian outcomes is not included in swGlmPwr to avoid repetition. When the outcome is binomial, swGlmPwr performs power calculation on the natural scale (logit), while swPwr performs power calculation on the linear scale.

References

Breslow NE and Clayton DG (1993). Approximate inference in generalized linear mixed models. Journal of the American Statistical Association, 88(421):9-25.

Kenny A, Voldal E, Xia F, Heagerty PJ, Hughes JP. Analysis of stepped wedge cluster randomized trials in the presence of a time-varying treatment effect. Statistics in Medicine, in press, 2022.

Xia F, Hughes JP, Voldal EC, Heagerty PJ. Power and sample size calculation for stepped-wedge designs with discrete outcomes. Trials. 2021 Dec;22(1):598.

Examples

Run this code
##test-case large clusters
library(swCRTdesign)
#specify large cluster sizes
size = c(35219,53535,63785,456132,128670,96673,
51454,156667,127440,68615,56502,17719,75931,58655,52874,75936)
#calculate power
swGlmPwr(design=swDsn(c(4,3,5,4)),distn="binomial",n=size,
fixed.intercept=log(28.62/(2*100000)),fixed.time.effect = 1,fixed.treatment.effect = log(.6),
tau=.31,eta=abs(0.4*log(.6)),rho=0,gamma=.15,alpha=.05,retDATA = FALSE)

Run the code above in your browser using DataLab