setwd('./..')
getwd()
## [1] "/home/zhayuji4/Rtemp/test_temp/gsDesign2-merck/inst"
my_path <- "./old_function/"
source_files <- list.files(my_path, "*.R$")
source_files
## [1] "AHR_.R" "eEvents_.R"
## [3] "eEvents_df_.R" "gridpts_h1_hupdate_oldR.R"
## [5] "gs_design_ahr_.R" "gs_design_npe_.R"
## [7] "gs_power_ahr_.R" "gs_power_npe_.R"
## [9] "tEvents_.R"
sapply(paste0(my_path, source_files), source)
## ./old_function/AHR_.R ./old_function/eEvents_.R
## value ? ?
## visible FALSE FALSE
## ./old_function/eEvents_df_.R ./old_function/gridpts_h1_hupdate_oldR.R
## value ? ?
## visible FALSE FALSE
## ./old_function/gs_design_ahr_.R ./old_function/gs_design_npe_.R
## value ? ?
## visible FALSE FALSE
## ./old_function/gs_power_ahr_.R ./old_function/gs_power_npe_.R
## value ? ?
## visible FALSE FALSE
## ./old_function/tEvents_.R
## value ?
## visible FALSE
Test 1
enrollRates <- tibble(duration = c(2, 1, 2), rate = c(5, 10, 20))
failRates <- tibble(duration = c(1, 1, 1),failRate = c(.05, .02, .01), dropoutRate = .01)
totalDuration <- 20
x1 <- gsDesign::eEvents(lambda = failRates$failRate,
S = failRates$duration[1 : (nrow(failRates) - 1)],
eta = failRates$dropoutRate,
gamma = enrollRates$rate,
R = enrollRates$duration,
T = totalDuration)$d
x2 <- eEvents_df_(enrollRates, failRates, totalDuration, simple = TRUE)
enrollRates <- tibble(duration = c(2, 1, 2), rate = c(5, 10, 20))
failRates <- tibble(duration = c(1, 1, 1), fail_rate = c(.05, .02, .01), dropout_rate = .01)
totalDuration <- 20
x3 <- eEvents_df(enrollRates, failRates, totalDuration, simple = TRUE)
tibble(method = c("gsDesign", "old version", "new version"),
exp_events = c(x1, x2, x3)) %>% gt()
method |
exp_events |
gsDesign |
11.02302 |
old version |
11.02302 |
new version |
11.02302 |
Test 2
enrollRates <- tibble(duration = c(1, 1, 8), rate = c(3, 2, 0))
failRates <- tibble(duration = c(4, Inf), fail_rate = c(.03, .06), dropout_rate = c(.001, .002))
totalDuration <- 7
x <- eEvents_df(enrollRates, failRates, totalDuration, simple = FALSE) %>% data.frame()
# expected checked with alternate calculations in gsSurvNPH vignette
y <- data.frame(t = c(0, 4), failRate = c(0.03, 0.06), Events = c(0.5642911, 0.5194821))
x %>% gt() %>% tab_header(title = "From gsDesign2 new version")
t |
failRate |
Events |
0 |
0.03 |
0.5642911 |
4 |
0.06 |
0.5194821 |
y %>% gt() %>% tab_header(title = "From gsSurvNPH vignette")
t |
failRate |
Events |
0 |
0.03 |
0.5642911 |
4 |
0.06 |
0.5194821 |