library(tibble)
library(dplyr)
library(testthat)
devtools::load_all()

Test 1: unstratified population

enrollRates <- tibble(Stratum = "All",
                      duration = c(2, 10, 4, 4, 8),
                      rate = c(5, 10, 0, 3, 6))
failRates <- tibble(Stratum = "All",
                    duration = 1,
                    failRate = c(.1, .2, .3, .4),
                    hr = c(.9, .75, .8, .6),
                    dropoutRate = .001)
x1 <- AHR(enrollRates = enrollRates, failRates = failRates, totalDuration = c(15, 30))
x2 <- AHR_(enrollRates = enrollRates, failRates = failRates, totalDuration = c(15, 30))

expect_equal(x1, x2)

Test 2: stratified population

enrollRates <- tibble(Stratum = c(rep("Low", 2), rep("High", 3)),
                      duration = c(2, 10, 4, 4, 8),
                      rate = c(5, 10, 0, 3, 6))
failRates <- tibble(Stratum = c(rep("Low", 2), rep("High", 2)),
                    duration = 1,
                    failRate = c(.1, .2, .3, .4),
                    hr = c(.9, .75, .8, .6),
                    dropoutRate = .001)

x1 <- AHR(enrollRates = enrollRates, failRates = failRates, totalDuration = c(15, 30))
x2 <- AHR_(enrollRates = enrollRates, failRates = failRates, totalDuration = c(15, 30))

expect_equal(x1, x2)


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