Skip to contents

Test 1

In this test, we verify tEvents() by AHR().

enrollRates <- tibble(Stratum = "All", duration = c(2, 2, 10), rate = c(3, 6, 9) * 5)
failRates <- tibble(Stratum = "All", duration = c(3, 100), failRate = log(2) / c(9, 18), hr = c(.9, .6), dropoutRate = rep(.001, 2))
ratio <- 1

x <- AHR(enrollRates = enrollRates, failRates = failRates, 
         ratio = ratio, totalDuration = 20)
cat("The number of events by 20 months is ", x$Events, ".\n")
## The number of events by 20 months is  208.3641 .
y <- tEvents(enrollRates = enrollRates, failRates = failRates,
             ratio = ratio, targetEvents = x$Events)

cat("The time to get ", x$Events, " is ", y$Time, "months.\n")
## The time to get  208.3641  is  20 months.

Test 2

x1 <- tEvents()
x2 <- gsDesign2:::tEvents_()

x1 %>% 
  union_all(x2) %>% 
  mutate(`function comes from` = c("new version", "old version")) %>% 
  select(`function comes from`, Time, AHR, Events, info, info0)
## # A tibble: 2 × 6
##   `function comes from`  Time   AHR Events  info info0
##   <chr>                 <dbl> <dbl>  <dbl> <dbl> <dbl>
## 1 new version            14.9 0.787   150.  36.9  37.5
## 2 old version            14.9 0.787   150.  36.9  37.5

Test 3

enrollRates <- tibble(Stratum = "All", duration = c(2, 2, 10), rate = c(3, 6, 9) * 5)
failRates <- tibble(Stratum = "All", duration = c(3, 100), failRate = log(2) / c(9, 18), hr = c(.9, .6), dropoutRate = rep(.001, 2))
ratio <- 1

x1 <- tEvents(enrollRates = enrollRates, failRates = failRates, ratio = ratio, targetEvents = 200)
x2 <- gsDesign2:::tEvents_(enrollRates = enrollRates, failRates = failRates, ratio = ratio, targetEvents = 200)

x1 %>% 
  union_all(x2) %>% 
  mutate(`function comes from` = c("new version", "old version")) %>% 
  select(`function comes from`, Time, AHR, Events, info, info0)
## # A tibble: 2 × 6
##   `function comes from`  Time   AHR Events  info info0
##   <chr>                 <dbl> <dbl>  <dbl> <dbl> <dbl>
## 1 new version            19.2 0.744   200.  48.9  50.0
## 2 old version            19.2 0.744   200.  48.9  50.0