library(gt)
library(dplyr)
library(tibble)
#library(gsDesign2)
devtools::load_all()

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")

y <- tEvents(enrollRates = enrollRates, failRates = failRates,
             ratio = ratio, targetEvents = x$Events)

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

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)

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)


keaven/gsDesign2 documentation built on Oct. 13, 2022, 8:42 p.m.