library(tibble)
library(dplyr)
library(gt)
library(testthat)
devtools::load_all()
setwd("./..")
my_path <- "./old_function/"
source_files <- list.files(my_path, "*.R$")
sapply(paste0(my_path, source_files), source)
##         ./old_function/AHR_.R ./old_function/eAccrual_.R
## value   ?                     ?                         
## visible FALSE                 FALSE                     
##         ./old_function/eEvents_.R ./old_function/eEvents_df_.R
## value   ?                         ?                           
## visible FALSE                     FALSE                       
##         ./old_function/gridpts_h1_hupdate_oldR.R
## value   ?                                       
## visible FALSE                                   
##         ./old_function/gs_design_ahr_.R ./old_function/gs_design_npe_.R
## value   ?                               ?                              
## visible FALSE                           FALSE                          
##         ./old_function/gs_info_ahr_.R ./old_function/gs_power_ahr_.R
## value   ?                             ?                             
## visible FALSE                         FALSE                         
##         ./old_function/gs_power_npe_.R ./old_function/tEvents_.R
## value   ?                              ?                        
## visible FALSE                          FALSE

Test 1

x1 <- gs_power_ahr()
x2 <- gs_power_ahr_()
version samplesize events time theta Z_upper Z_lower prob_upper prob_lower AHR info info0
1
new 108 30.00000 14.90814 0.2400699 2.668630 -1.281552 0.02306909 0.02726659 0.7865729 7.373414 7.5
old NA 30.00000 14.90814 0.2400699 2.668630 -1.281552 0.02306909 0.02726659 0.7865729 7.373414 7.5
2
new 108 40.00000 19.16437 0.2954443 2.288719 NA 0.08972699 NA 0.7442008 9.789939 10.0
old NA 40.00000 19.16437 0.2954443 2.288719 -Inf 0.08972699 0.02726659 0.7442008 9.789939 10.0
3
new 108 50.00001 24.54264 0.3385206 2.030702 NA 0.20699559 NA 0.7128241 12.227635 12.5
old NA 50.00001 24.54264 0.3385206 2.030702 -Inf 0.20699559 0.02726659 0.7128241 12.227635 12.5

Test 2

x1 <- gs_power_ahr(
  analysis_time = c(12, 24, 36),
  event = NULL,
  binding = TRUE,
  upper = gs_spending_bound,
  upar = list(sf = gsDesign::sfLDOF, total_spend = 0.025, param = NULL, timing = NULL),
  lower = gs_spending_bound,
  lpar = list(sf = gsDesign::sfLDOF, total_spend = 0.025, param = NULL, timing = NULL)
)

x2 <- gs_power_ahr_(
  analysisTimes = c(12, 24, 36),
  events = NULL,
  binding = TRUE,
  upper = gs_spending_bound,
  upar = list(sf = gsDesign::sfLDOF, total_spend = 0.025, param = NULL, timing = NULL),
  lower = gs_spending_bound,
  lpar = list(sf = gsDesign::sfLDOF, total_spend = 0.025, param = NULL, timing = NULL)
)
version samplesize events time theta Z_upper Z_lower prob_upper prob_lower AHR info info0
1
new 90 20.40451 12 0.2097907 3.872763 -3.3951783 0.0003696216 6.119278e-05 0.8107539 5.028327 5.101127
old NA 20.40451 12 0.2097907 3.872763 -3.3951783 0.0003696216 6.119278e-05 0.8107539 5.028327 5.101127
2
new 108 49.06966 24 0.3352538 2.357870 -1.2026786 0.1157980700 9.065088e-03 0.7151566 11.999266 12.267415
old NA 49.06966 24 0.3352538 2.357870 -1.2026786 0.1157980700 9.065088e-03 0.7151566 11.999266 12.267415
3
new 108 66.23948 36 0.3807634 2.009598 -0.4730657 0.3238741060 2.500579e-02 0.6833395 16.267921 16.559870
old NA 66.23948 36 0.3807634 2.009598 -0.4730657 0.3238741060 2.500579e-02 0.6833395 16.267921 16.559870

Test 3

x1 <- gs_power_ahr(
  analysis_time = NULL,
  event = c(20, 50, 70),
  binding = TRUE,
  upper = gs_spending_bound,
  upar = list(sf = gsDesign::sfLDOF, total_spend = 0.025, param = NULL, timing = NULL),
  lower = gs_spending_bound,
  lpar = list(sf = gsDesign::sfLDOF, total_spend = 0.025, param = NULL, timing = NULL)
)

x2 <- gs_power_ahr_(
  analysisTimes = NULL,
  events = c(20, 50, 70),
  binding = TRUE,
  upper = gs_spending_bound,
  upar = list(sf = gsDesign::sfLDOF, total_spend = 0.025, param = NULL, timing = NULL),
  lower = gs_spending_bound,
  lpar = list(sf = gsDesign::sfLDOF, total_spend = 0.025, param = NULL, timing = NULL)
)
version samplesize events time theta Z_upper Z_lower prob_upper prob_lower AHR info info0
1
new 88.83781 20.00000 11.87087 0.2083377 4.033339 -3.5664655 0.0001984167 0.0000311764 0.8119328 4.929331 5.000001
old NA 20.00000 11.87087 0.2083377 4.033339 -3.5664655 0.0001984167 0.0000311764 0.8119328 4.929331 5.000001
2
new 108.00000 50.00001 24.54264 0.3385206 2.409365 -1.2339747 0.1102018343 0.0078225120 0.7128241 12.227635 12.500003
old NA 50.00001 24.54264 0.3385206 2.409365 -1.2339747 0.1102018343 0.0078225120 0.7128241 12.227635 12.500003
3
new 108.00000 70.00000 39.39207 0.3877506 2.003221 -0.3933009 0.3516871516 0.0250031713 0.6785816 17.218358 17.500000
old NA 70.00000 39.39207 0.3877506 2.003221 -0.3933009 0.3516871516 0.0250031713 0.6785816 17.218358 17.500000

Test 4

x1 <- gs_power_ahr(
  analysis_time = c(12, 24, 36),
  event = c(30, 40, 50),
  binding = TRUE,
  upper = gs_spending_bound,
  upar = list(sf = gsDesign::sfLDOF, total_spend = 0.025, param = NULL, timing = NULL),
  lower = gs_spending_bound,
  lpar = list(sf = gsDesign::sfLDOF, total_spend = 0.025, param = NULL, timing = NULL)
)

x2 <- gs_power_ahr_(
  analysisTimes = c(12, 24, 36),
  events = c(30, 40, 50),
  binding = TRUE,
  upper = gs_spending_bound,
  upar = list(sf = gsDesign::sfLDOF, total_spend = 0.025, param = NULL, timing = NULL),
  lower = gs_spending_bound,
  lpar = list(sf = gsDesign::sfLDOF, total_spend = 0.025, param = NULL, timing = NULL)
)
version samplesize events time theta Z_upper Z_lower prob_upper prob_lower AHR info info0
1
new 108 30.00000 14.90814 0.2400699 3.132472 -2.479243 0.007063099 0.0009350637 0.7865729 7.373414 7.50000
old NA 30.00000 14.90814 0.2400699 3.132472 -2.479243 0.007063099 0.0009350637 0.7865729 7.373414 7.50000
2
new 108 49.06966 24.00000 0.3352538 2.368721 -1.213713 0.114573305 0.0091236873 0.7151566 11.999266 12.26741
old NA 49.06966 24.00000 0.3352538 2.368721 -1.213713 0.114573305 0.0091236873 0.7151566 11.999266 12.26741
3
new 108 66.23948 36.00000 0.3807634 2.010883 -0.474337 0.323735376 0.0250643863 0.6833395 16.267921 16.55987
old NA 66.23948 36.00000 0.3807634 2.010883 -0.474337 0.323735376 0.0250643863 0.6833395 16.267921 16.55987