Skip to contents

This is the function to generate a R table summarizing the bounds in the group sequential design generated by gs_design_ahr or gs_design_wlr or gs_design_combo.

Usage

# S3 method for gs_design
summary(
  x,
  analysis_vars = NULL,
  analysis_decimals = NULL,
  col_vars = NULL,
  col_decimals = NULL,
  bound_names = c("Efficacy", "Futility"),
  ...
)

Arguments

x

an object returned by gs_design_ahr or gs_design_wlr or gs_design_combo

analysis_vars

the variables to be put at the summary header of each analysis

analysis_decimals

the displayed number of digits of analysis_vars

col_vars

the variables to be displayed

col_decimals

the decimals to be displayed for the displayed variables in col_vars

bound_names

names for bounds; default = c("Efficacy", "Futility").

...

additional arguments

Value

a summary table

Examples

# ---------------------------- #
#     design parameters        #
# ---------------------------- #
library(tibble)
library(gsDesign)
library(gsDesign2)
library(dplyr)

# enrollment/failure rates
enrollRates <- tibble(Stratum = "All", 
                      duration = 12, 
                      rate = 1)
failRates <- tibble(Stratum = "All", duration = c(4, 100), 
                    failRate = log(2) / 12,
                    hr = c(1, .6), 
                     dropoutRate = .001)

# Information fraction
IF <- (1:3)/3 

# Analysis times in months; first 2 will be ignored as IF will not be achieved
analysisTimes <- c(.01, .02, 36)  

# Experimental / Control randomization ratio
ratio <- 1 

# 1-sided Type I error
alpha <- 0.025 

# Type II error (1 - power)
beta <- .1 

# Upper bound
upper <- gs_spending_bound
upar <- list(sf = gsDesign::sfLDOF, total_spend = 0.025, param = NULL, timing = NULL)

# Lower bound
lower <- gs_spending_bound
lpar <- list(sf = gsDesign::sfHSD, total_spend = 0.1, param = 0, timing = NULL)

# weight function in WLR
wgt00 <- function(x, arm0, arm1){wlr_weight_fh(x, arm0, arm1, rho = 0, gamma = 0)}
wgt05 <- function(x, arm0, arm1){wlr_weight_fh(x, arm0, arm1, rho = 0, gamma = .5)}

# test in COMBO
fh_test <- rbind(
  data.frame(rho = 0, gamma = 0, tau = -1, test = 1, Analysis = 1:3,analysisTimes = c(12, 24, 36)), 
  data.frame(rho = c(0, 0.5), gamma = 0.5, tau = -1, test = 2:3, Analysis = 3, analysisTimes = 36)
)

# ---------------------------- #
#          ahr                 #
# ---------------------------- #
x_ahr <- gs_design_ahr(
  enrollRates = enrollRates,
  failRates = failRates,
  IF = IF, # Information fraction
  analysisTimes = analysisTimes, 
  ratio = ratio, 
  alpha = alpha, 
  beta = beta, 
  upper = upper,
  upar = upar,
  lower = lower,
  lpar = lpar)
  
x_ahr %>% summary()
#> # A tibble: 6 × 7
#> # Groups:   Analysis [3]
#>   Analysis                           Bound     Z ~HR a…¹ Nomin…² Alter…³ Null …⁴
#>   <chr>                              <chr> <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
#> 1 Analysis: 1 Time: 11.7 N: 479.6 E… Futi… -0.94   1.19   0.826   0.0338  0.176 
#> 2 Analysis: 1 Time: 11.7 N: 479.6 E… Effi…  3.71   0.510  0.0001  0.0027  0.0001
#> 3 Analysis: 2 Time: 20.3 N: 493.1 E… Futi…  0.63   0.923  0.266   0.0666  0.739 
#> 4 Analysis: 2 Time: 20.3 N: 493.1 E… Effi…  2.51   0.725  0.006   0.414   0.0061
#> 5 Analysis: 3 Time: 36 N: 493.1 Eve… Futi…  1.99   0.812  0.0233  0.101   0.977 
#> 6 Analysis: 3 Time: 36 N: 493.1 Eve… Effi…  1.99   0.812  0.0231  0.9     0.0246
#> # … with abbreviated variable names ¹​`~HR at bound`, ²​`Nominal p`,
#> #   ³​`Alternate hypothesis`, ⁴​`Null hypothesis`
x_ahr %>% summary(analysis_vars = c("Time", "Events", "IF"), analysis_decimals = c(1, 0, 2))
#> # A tibble: 6 × 7
#> # Groups:   Analysis [3]
#>   Analysis                           Bound     Z ~HR a…¹ Nomin…² Alter…³ Null …⁴
#>   <chr>                              <chr> <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
#> 1 Analysis: 1 Time: 11.7 Events: 12… Futi… -0.94   1.19   0.826   0.0338  0.176 
#> 2 Analysis: 1 Time: 11.7 Events: 12… Effi…  3.71   0.510  0.0001  0.0027  0.0001
#> 3 Analysis: 2 Time: 20.3 Events: 24… Futi…  0.63   0.923  0.266   0.0666  0.739 
#> 4 Analysis: 2 Time: 20.3 Events: 24… Effi…  2.51   0.725  0.006   0.414   0.0061
#> 5 Analysis: 3 Time: 36 Events: 365 … Futi…  1.99   0.812  0.0233  0.101   0.977 
#> 6 Analysis: 3 Time: 36 Events: 365 … Effi…  1.99   0.812  0.0231  0.9     0.0246
#> # … with abbreviated variable names ¹​`~HR at bound`, ²​`Nominal p`,
#> #   ³​`Alternate hypothesis`, ⁴​`Null hypothesis`
x_ahr %>% summary(bound_names = c("A is better", "B is better"))
#> # A tibble: 6 × 7
#> # Groups:   Analysis [3]
#>   Analysis                           Bound     Z ~HR a…¹ Nomin…² Alter…³ Null …⁴
#>   <chr>                              <chr> <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
#> 1 Analysis: 1 Time: 11.7 N: 479.6 E… B is… -0.94   1.19   0.826   0.0338  0.176 
#> 2 Analysis: 1 Time: 11.7 N: 479.6 E… A is…  3.71   0.510  0.0001  0.0027  0.0001
#> 3 Analysis: 2 Time: 20.3 N: 493.1 E… B is…  0.63   0.923  0.266   0.0666  0.739 
#> 4 Analysis: 2 Time: 20.3 N: 493.1 E… A is…  2.51   0.725  0.006   0.414   0.0061
#> 5 Analysis: 3 Time: 36 N: 493.1 Eve… B is…  1.99   0.812  0.0233  0.101   0.977 
#> 6 Analysis: 3 Time: 36 N: 493.1 Eve… A is…  1.99   0.812  0.0231  0.9     0.0246
#> # … with abbreviated variable names ¹​`~HR at bound`, ²​`Nominal p`,
#> #   ³​`Alternate hypothesis`, ⁴​`Null hypothesis`

# ---------------------------- #
#         wlr                  #
# ---------------------------- #
x_wlr <- gs_design_wlr(
  enrollRates = enrollRates,
  failRates = failRates,
  weight = wgt05,
  IF = NULL,
  analysisTimes = sort(unique(x_ahr$analysis$Time)),
  ratio = ratio,
  alpha = alpha,
  beta = beta,
  upper = upper,
  upar = upar,
  lower = lower,
  lpar = lpar
)
x_wlr %>% summary()
#> # A tibble: 6 × 7
#> # Groups:   Analysis [3]
#>   Analysis                           Bound     Z ~wHR …¹ Nomin…² Alter…³ Null …⁴
#>   <chr>                              <chr> <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
#> 1 Analysis: 1 Time: 11.7 N: 361.4 E… Futi… -1.17   1.28   0.879   0.0141  0.122 
#> 2 Analysis: 1 Time: 11.7 N: 361.4 E… Effi…  6.02   0.284  0       0       0     
#> 3 Analysis: 2 Time: 20.3 N: 371.6 E… Futi…  0.57   0.919  0.283   0.0464  0.723 
#> 4 Analysis: 2 Time: 20.3 N: 371.6 E… Effi…  3.16   0.627  0.0008  0.214   0.0008
#> 5 Analysis: 3 Time: 36 N: 371.6 Eve… Futi…  1.96   0.789  0.0247  0.100   0.978 
#> 6 Analysis: 3 Time: 36 N: 371.6 Eve… Effi…  1.96   0.789  0.0247  0.9     0.0225
#> # … with abbreviated variable names ¹​`~wHR at bound`, ²​`Nominal p`,
#> #   ³​`Alternate hypothesis`, ⁴​`Null hypothesis`

# ---------------------------- #
#         max combo            #
# ---------------------------- #
x_combo <- gs_design_combo(
  ratio = 1,
  alpha = 0.025,
  beta = 0.2,
  enrollRates = tibble::tibble(Stratum = "All", duration = 12, rate = 500/12),
  failRates = tibble::tibble(Stratum = "All", duration = c(4, 100),
                             failRate = log(2) / 15, hr = c(1, .6), dropoutRate = .001),
  fh_test = fh_test,
  upper = gs_spending_combo,
  upar = list(sf = gsDesign::sfLDOF, total_spend = 0.025),
  lower = gs_spending_combo,
  lpar = list(sf = gsDesign::sfLDOF, total_spend = 0.2))
#> The AHR reported in the `analysis` table is under the log-rank test.
x_combo %>% summary()
#> # A tibble: 6 × 6
#> # Groups:   Analysis [3]
#>   Analysis                                   Bound     Z Nomin…¹ Alter…² Null …³
#>   <chr>                                      <chr> <dbl>   <dbl>   <dbl>   <dbl>
#> 1 Analysis: 1 Time: 12 N: 301.3 Events: 64.… Futi… -2.72  0.997   0.0003  0     
#> 2 Analysis: 1 Time: 12 N: 301.3 Events: 64.… Effi…  6.18  0       0       0     
#> 3 Analysis: 2 Time: 24 N: 301.3 Events: 148… Futi…  0.65  0.257   0.0847  0     
#> 4 Analysis: 2 Time: 24 N: 301.3 Events: 148… Effi…  2.8   0.0026  0.220   0.0026
#> 5 Analysis: 3 Time: 36 N: 301.3 Events: 199… Futi…  2.1   0.018   0.2     0     
#> 6 Analysis: 3 Time: 36 N: 301.3 Events: 199… Effi…  2.1   0.018   0.8     0.025 
#> # … with abbreviated variable names ¹​`Nominal p`, ²​`Alternate hypothesis`,
#> #   ³​`Null hypothesis`

# ---------------------------- #
#      risk difference         #
# ---------------------------- #
gs_design_rd(
  p_c = tibble(Stratum = "All", Rate = .2),
  p_e = tibble(Stratum = "All", Rate = .15),
  IF = c(0.7, 1),
  rd0 = 0,
  alpha = .025,
  beta = .1,
  ratio = 1,
  stratum_prev = NULL,
  weight = "un-stratified",
  upper = gs_b,
  lower = gs_b,
  upar = gsDesign::gsDesign(k = 3, test.type = 1, sfu = gsDesign::sfLDOF, sfupar = NULL)$upper$bound,
  lpar = c(qnorm(.1), rep(-Inf, 2))
) %>% summary()
#> # A tibble: 4 × 7
#> # Groups:   Analysis [2]
#>   Analysis                       Bound       Z ~Risk d…¹ Nomin…² Alter…³ Null …⁴
#>   <chr>                          <chr>   <dbl>     <dbl>   <dbl>   <dbl>   <dbl>
#> 1 Analysis: 1 N: 2335.7 risk di… Futi…   -1.28   -0.0201  0.9      0      0.0995
#> 2 Analysis: 1 N: 2335.7 risk di… Effi…    3.71    0.0582  0.0001   0.298  0.0001
#> 3 Analysis: 2 N: 3336.7 risk di… Futi… -Inf    -Inf       1        0      0.0995
#> 4 Analysis: 2 N: 3336.7 risk di… Effi…    2.51    0.033   0.006    0.9    0.006 
#> # … with abbreviated variable names ¹​`~Risk difference at bound`, ²​`Nominal p`,
#> #   ³​`Alternate hypothesis`, ⁴​`Null hypothesis`