# Example 1 ----
# default
# \donttest{
expected_time()
# }
# Example 2 ----
# check that result matches a finding using AHR()
# Start by deriving an expected event count
enroll_rate <- define_enroll_rate(duration = c(2, 2, 10), rate = c(3, 6, 9) * 5)
fail_rate <- define_fail_rate(
duration = c(3, 100),
fail_rate = log(2) / c(9, 18),
hr = c(.9, .6),
dropout_rate = .001
)
total_duration <- 20
xx <- ahr(enroll_rate, fail_rate, total_duration)
xx
# Next we check that the function confirms the timing of the final analysis.
# \donttest{
expected_time(enroll_rate, fail_rate,
target_event = xx$event, interval = c(.5, 1.5) * xx$time
)
# }
# Example 3 ----
# In this example, we verify `expected_time()` by `ahr()`.
# \donttest{
x <- ahr(
enroll_rate = enroll_rate, fail_rate = fail_rate,
ratio = 1, total_duration = 20
)
cat("The number of events by 20 months is ", x$event, ".\n")
y <- expected_time(
enroll_rate = enroll_rate, fail_rate = fail_rate,
ratio = 1, target_event = x$event
)
cat("The time to get ", x$event, " is ", y$time, "months.\n")
# }
Run the code above in your browser using DataLab