View source: R/expected_time.R
expected_time | R Documentation |
expected_time()
is made to match input format with ahr()
and to solve for the
time at which the expected accumulated events is equal to an input target.
Enrollment and failure rate distributions are specified as follows.
The piecewise exponential distribution allows a simple method to specify a distribution
and enrollment pattern
where the enrollment, failure and dropout rates changes over time.
expected_time(
enroll_rate = define_enroll_rate(duration = c(2, 2, 10), rate = c(3, 6, 9) * 5),
fail_rate = define_fail_rate(stratum = "All", duration = c(3, 100), fail_rate =
log(2)/c(9, 18), hr = c(0.9, 0.6), dropout_rate = rep(0.001, 2)),
target_event = 150,
ratio = 1,
interval = c(0.01, 100)
)
enroll_rate |
An |
fail_rate |
A |
target_event |
The targeted number of events to be achieved. |
ratio |
Experimental:Control randomization ratio. |
interval |
An interval that is presumed to include the time at which
expected event count is equal to |
A data frame with Time
(computed to match events in target_event
),
AHR
(average hazard ratio), Events
(target_event
input),
info
(information under given scenarios), and info0
(information under related null hypothesis) for each value of
total_duration
input.
# Example 1 ----
# default
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.
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()`.
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.