Skip to contents
library(gsDesign)
library(tibble)
library(gt)
# load the develop version of gsDesign2
# it will finally be replaced by `libraray(gsDesign2)`
devtools::load_all()

Parameters

# Enrollment rate
enrollRates <- tibble::tibble(
   Stratum = "All", 
   duration = 18, 
   rate = 20)

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

# Study duration in months
studyDuration <- 36

# Experimental / Control randomization ratio
ratio <- 1 

# 1-sided Type I error
alpha <- 0.025 
# Type II error (1 - power)
beta <- 0.1 

AHR

under fixed power

x <- fixed_design(x = "AHR", 
             alpha = alpha, power = 1 - beta, 
             enrollRates = enrollRates, failRates = failRates, 
             studyDuration = studyDuration, ratio = ratio) 

x %>% summary()
## # A tibble: 1 × 7
##   Design                   N Events  Time Bound alpha Power
##   <chr>                <dbl>  <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 Average hazard ratio  463.   325.    36  1.96 0.025   0.9
Fixed Design under AHR Method1
Design N Events Time Bound alpha Power
AHR 463.078 324.7077 36 1.959964 0.025 0.9
1 Power computed with average hazard ratio method.

under fixed sample size

fixed_design(x = "AHR", 
             alpha = alpha,  
             enrollRates = enrollRates, failRates = failRates, 
             studyDuration = studyDuration, ratio = ratio) %>% 
  summary() %>% 
  as_gt()
Fixed Design under AHR Method1
Design N Events Time Bound alpha Power
AHR 360 252.43 36 1.959964 0.025 0.815886
1 Power computed with average hazard ratio method.

FH

under fixed power (default rho/gamma)

# fixed design with a given power with default rho/gamma
x <- fixed_design(x = "FH", 
             alpha = alpha, power = 1 - beta, 
             enrollRates = enrollRates, failRates = failRates, 
             studyDuration = studyDuration, ratio = ratio) 
x %>% summary() 
## # A tibble: 1 × 7
##   Design                            N Events  Time Bound alpha Power
##   <chr>                         <dbl>  <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 Fleming-Harrington FH(0, 0.5)  356.   249.    36  1.96 0.025   0.9
Fixed Design under Fleming-Harrington Method1
Design N Events Time Bound alpha Power
FH 355.5725 249.3255 36 1.959964 0.025 0.9
1 Power for Fleming-Harrington test FH(0, 0.5) using method of Yung and Liu.

under fixed power (custom rho/gamma)

# fixed design with a given power with input rho/gamma
fixed_design(x = "FH", 
             alpha = alpha, power = 1 - beta, 
             enrollRates = enrollRates, failRates = failRates, 
             studyDuration = studyDuration, ratio = ratio,
             rho = 0.5, gamma = 0.5) %>% 
  summary() %>%  
  as_gt()
Fixed Design under Fleming-Harrington Method1
Design N Events Time Bound alpha Power
FH 376.0673 263.6963 36 1.959964 0.025 0.9
1 Power for Fleming-Harrington test FH(0.5, 0.5) using method of Yung and Liu.

under fixed sample size (default rho/gamma)

# fixed design with power calculated
fixed_design(x = "FH", 
             alpha = alpha,  
             enrollRates = enrollRates, failRates = failRates, 
             studyDuration = studyDuration, ratio = ratio) %>% 
  summary() %>%  
  as_gt()
Fixed Design under Fleming-Harrington Method1
Design N Events Time Bound alpha Power
FH 360 252.43 36 1.959964 0.025 0.9034347
1 Power for Fleming-Harrington test FH(0, 0.5) using method of Yung and Liu.

under fixed sample size (custom rho/gamma)

# fixed design with power calculated
fixed_design(x = "FH", 
             alpha = alpha,  
             enrollRates = enrollRates, failRates = failRates, 
             studyDuration = studyDuration, ratio = ratio,
             rho = 0.5, gamma = 0.5) %>% 
  summary() %>%  
  as_gt()
Fixed Design under Fleming-Harrington Method1
Design N Events Time Bound alpha Power
FH 360 252.43 36 1.959964 0.025 0.8872751
1 Power for Fleming-Harrington test FH(0.5, 0.5) using method of Yung and Liu.

MB

under fixed power (default tau)

x <- fixed_design(x = "MB", 
             ratio = ratio, 
             alpha = alpha, power = 1 - beta,
             enrollRates = enrollRates,
             failRates = failRates,
             studyDuration = studyDuration) 
x %>% summary() 
## # A tibble: 1 × 7
##   Design                            N Events  Time Bound alpha Power
##   <chr>                         <dbl>  <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 Modestly weighted LR: tau = 6  412.   289.    36  1.96 0.025   0.9
Fixed Design under Magirr-Burman Method1
Design N Events Time Bound alpha Power
MB 412.2826 289.0902 36 1.959964 0.025 0.9
1 Power for Modestly weighted LR: tau = 6 computed with method of Yung and Liu.

under fixed power (custom tau)

fixed_design(x = "MB", 
             ratio = ratio, 
             alpha = alpha, power = 1 - beta,
             enrollRates = enrollRates,
             failRates = failRates,
             studyDuration = studyDuration,
             tau = 4) %>% 
  summary() %>%  
  as_gt()
Fixed Design under Magirr-Burman Method1
Design N Events Time Bound alpha Power
MB 429.7777 301.3577 36 1.959964 0.025 0.9
1 Power for Modestly weighted LR: tau = 4 computed with method of Yung and Liu.

under fixed sample size (default tau)

fixed_design(x = "MB",
             ratio = ratio,
             alpha = alpha,
             enrollRates = enrollRates,
             failRates = failRates,
             studyDuration = studyDuration) %>% 
  summary() %>%  
  as_gt()
Fixed Design under Magirr-Burman Method1
Design N Events Time Bound alpha Power
MB 360 252.43 36 1.959964 0.025 0.8579005
1 Power for Modestly weighted LR: tau = 6 computed with method of Yung and Liu.

under fixed sample size (custom tau)

fixed_design(x = "MB",
             ratio = ratio,
             alpha = alpha,
             enrollRates = enrollRates,
             failRates = failRates,
             studyDuration = studyDuration,
             tau = 4) %>% 
  summary() %>%  
  as_gt()
Fixed Design under Magirr-Burman Method1
Design N Events Time Bound alpha Power
MB 360 252.43 36 1.959964 0.025 0.8435226
1 Power for Modestly weighted LR: tau = 4 computed with method of Yung and Liu.

LF

under fixed power

fixed_design(x = "LF", alpha = alpha, power = 1 - beta, 
             ratio = ratio,
             enrollRates = enrollRates,
             failRates = failRates,
             studyDuration = studyDuration) %>% 
  summary() %>%  
  as_gt()
Fixed Design under Lachin and Foulkes Method1
Design N Events Time Bound alpha Power
LF 453.1714 321.8553 36 1.959964 0.025 0.9
1 Power using Lachin and Foulkes method applied using expected average hazard ratio (AHR) at time of planned analysis.

under sample size

fixed_design(x = "LF", alpha = alpha,  
             ratio = ratio, 
             enrollRates = enrollRates,
             failRates = failRates,
             studyDuration = studyDuration) %>% 
  summary() %>%  
  as_gt()
Fixed Design under Lachin and Foulkes Method1
Design N Events Time Bound alpha Power
LF 360 255.6823 36 1.959964 0.025 0.8240862
1 Power using Lachin and Foulkes method applied using expected average hazard ratio (AHR) at time of planned analysis.

MaxCombo

under fixed power (default rho/gamma/tau)

x <- fixed_design(x = "MaxCombo", alpha = alpha, power = 1 - beta,
             ratio = ratio, 
             enrollRates = enrollRates,
             failRates = failRates,
             studyDuration = studyDuration) 
## The AHR reported in the `analysis` table is under the log-rank test.
## # A tibble: 1 × 7
##   Design                            N Events  Time Bound alpha Power
##   <chr>                         <dbl>  <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 MaxCombo: logrank, FH(0, 0.5)  359.   252.    36  1.96 0.025 0.900
Fixed Design under Max Combo Method1
Design N Events Time Bound alpha Power
MaxCombo 359.06 251.7709 36 1.959964 0.025 0.9
1 Power for MaxCombo test with Fleming-Harrington tests: logrank, FH(0, 0.5).

under fixed power (custom rho/gamma/tau)

fixed_design(x = "MaxCombo", alpha = alpha, power = 1 - beta,
             ratio = ratio, 
             enrollRates = enrollRates,
             failRates = failRates,
             studyDuration = studyDuration,
             rho = c(0, 0.5, 0.5),
             gamma = c(0, 0, 0.5),
             tau = c(-1, 4, 6)) %>% 
  summary() %>% 
  as_gt()
## The AHR reported in the `analysis` table is under the log-rank test.
Fixed Design under Max Combo Method1
Design N Events Time Bound alpha Power
MaxCombo 374.9892 262.9403 36 1.959964 0.025 0.9000002
1 Power for MaxCombo test with Fleming-Harrington tests: logrank, FH(0.5, 0), FH(0.5, 0.5).

under sample size (default rho/gamma/tau)

fixed_design(x = "MaxCombo", alpha = alpha, 
             ratio = ratio, 
             enrollRates = enrollRates,
             failRates = failRates,
             studyDuration = studyDuration) %>% 
  summary() %>% 
  as_gt()
## The AHR reported in the `analysis` table is under the log-rank test.
Fixed Design under Max Combo Method1
Design N Events Time Bound alpha Power
MaxCombo 360 252.43 36 1.959964 0.025 0.9007251
1 Power for MaxCombo test with Fleming-Harrington tests: logrank, FH(0, 0.5).

under sample size (custom rho/gamma/tau)

fixed_design(x = "MaxCombo", alpha = alpha, 
             ratio = ratio, 
             enrollRates = enrollRates,
             failRates = failRates, 
             studyDuration = studyDuration,
             rho = c(0, 0.5, 0.5),
             gamma = c(0, 0, 0.5),
             tau = c(-1, 4, 6)) %>% 
  summary() %>% 
  as_gt()
## The AHR reported in the `analysis` table is under the log-rank test.
Fixed Design under Max Combo Method1
Design N Events Time Bound alpha Power
MaxCombo 360 252.43 36 1.959964 0.025 0.8883462
1 Power for MaxCombo test with Fleming-Harrington tests: logrank, FH(0.5, 0), FH(0.5, 0.5).

RMST

under fixed power

x <- fixed_design(x = "RMST", 
                  alpha = alpha, power = 1 - beta, 
                  enrollRates = enrollRates, failRates = failRates, 
                  studyDuration = studyDuration, ratio = ratio,
                  tau = 18) 

x %>% summary()
## # A tibble: 1 × 7
##   Design             N Events  Time Bound alpha Power
##   <chr>          <dbl>  <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 RMST: tau = 18 1298.   910.    36  1.96 0.025   0.9
Fixed Design under Restricted Mean Survival Time Method1
Design N Events Time Bound alpha Power
RMST 1298.358 910.4017 36 1.959964 0.025 0.9
1 Power for RMST: tau = 18 computed with method of Yung and Liu.

under fixed sample size

fixed_design(x = "RMST", 
             alpha = alpha,  
             enrollRates = enrollRates, failRates = failRates, 
             studyDuration = studyDuration, ratio = ratio,
             tau = 18) %>% 
  summary() %>% 
  as_gt()
Fixed Design under Restricted Mean Survival Time Method1
Design N Events Time Bound alpha Power
RMST 360 252.43 36 1.959964 0.025 0.4001002
1 Power for RMST: tau = 18 computed with method of Yung and Liu.

Milestone

under fixed power

x <- fixed_design(x = "Milestone", 
                  alpha = alpha, power = 1 - beta, 
                  enrollRates = enrollRates, failRates = failRates, 
                  studyDuration = studyDuration, ratio = ratio,
                  tau = 18) 

x %>% summary()
## # A tibble: 1 × 7
##   Design                  N Events  Time Bound alpha Power
##   <chr>               <dbl>  <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 Milestone: tau = 18  557.   390.    36  1.96 0.025   0.9
Fixed Design under Milestone Method1
Design N Events Time Bound alpha Power
Milestone 556.9044 390.4983 36 1.959964 0.025 0.9
1 Power for Milestone: tau = 18 computed with method of Yung and Liu.

under fixed sample size

fixed_design(x = "Milestone", 
             alpha = alpha,  
             enrollRates = enrollRates, failRates = failRates, 
             studyDuration = studyDuration, ratio = ratio,
             tau = 18) %>% 
  summary() %>% 
  as_gt()
Fixed Design under Milestone Method1
Design N Events Time Bound alpha Power
Milestone 360 252.43 36 1.959964 0.025 0.7409392
1 Power for Milestone: tau = 18 computed with method of Yung and Liu.

RD

under fixed power

x <- fixed_design(x = "RD", 
                  alpha = alpha, power = 1 - beta, 
                  p_c = .15, p_e = .1, rd0 = 0,
                  ratio = ratio) 

x %>% summary()
## # A tibble: 1 × 5
##   Design              N Bound alpha Power
##   <chr>           <dbl> <dbl> <dbl> <dbl>
## 1 Risk difference 1835.  1.96 0.025   0.9
Fixed Design of Risk Difference under Farrington-Manning Method1
Design N Bound alpha Power
RD 1834.641 1.959964 0.025 0.9
1 Risk difference power without continuity correction using method of Farrington and Manning.

under fixed sample size

fixed_design(x = "RD", 
             alpha = alpha, power = NULL, 
             p_c = .15, p_e = .1, rd0 = 0,
             N = 2000, ratio = ratio) %>% 
  summary() %>% 
  as_gt()
Fixed Design of Risk Difference under Farrington-Manning Method1
Design N Bound alpha Power
RD 2000 1.959964 0.025 0.9228823
1 Risk difference power without continuity correction using method of Farrington and Manning.

Multiple Designs

x_AHR <- fixed_design(x = "AHR", alpha = alpha, ratio = ratio,
                      enrollRates = enrollRates, failRates = failRates, 
                      studyDuration = studyDuration)

x_FH <- fixed_design(x = "FH", alpha = alpha, ratio = ratio, 
                     enrollRates = enrollRates, failRates = failRates, studyDuration = studyDuration,
                     rho = 0.5, gamma = 0.5) 

x_MB <- fixed_design(x = "MB", alpha = alpha, ratio = ratio, 
                     enrollRates = enrollRates,failRates = failRates, studyDuration = studyDuration, 
                     tau = 4)

x_LF <- fixed_design(x = "LF", alpha = alpha, ratio = ratio, 
                     enrollRates = enrollRates, failRates = failRates, studyDuration = studyDuration)

x_MaxCombo <- fixed_design(x = "MaxCombo", alpha = alpha, ratio = ratio, 
                           enrollRates = enrollRates, failRates = failRates, studyDuration = studyDuration,
                           rho = c(0, 0.5, 0.5), gamma = c(0, 0, 0.5), tau = c(-1, 4, 6))

x_RMST <- fixed_design(x = "RMST", alpha = alpha, ratio = ratio, 
                       enrollRates = enrollRates, failRates = failRates, studyDuration = studyDuration,
                       tau = 30)

x_Milestone <- fixed_design(x = "Milestone", alpha = alpha, ratio = ratio, 
                       enrollRates = enrollRates, failRates = failRates, studyDuration = studyDuration,
                       tau = 30)

rbind(summary(x_AHR), summary(x_FH), summary(x_MB), summary(x_LF), summary(x_MaxCombo), summary(x_RMST), summary(x_Milestone)) %>% gt()
Design N Events Time Bound alpha Power
Average hazard ratio 360 252.4300 36 1.959964 0.025 0.8158860
Fleming-Harrington FH(0.5, 0.5) 360 252.4300 36 1.959964 0.025 0.8872751
Modestly weighted LR: tau = 4 360 252.4300 36 1.959964 0.025 0.8435226
Lachin and Foulkes 360 255.6823 36 1.959964 0.025 0.8240862
MaxCombo: logrank, FH(0.5, 0), FH(0.5, 0.5) 360 252.4300 36 1.959964 0.025 0.8883464
RMST: tau = 30 360 252.4300 36 1.959964 0.025 0.7149430
Milestone: tau = 30 360 252.4300 36 1.959964 0.025 0.7737853