rpw_enroll | R Documentation |
With piecewise exponential enrollment rate generation any enrollment rate distribution can be easily approximated.
rpw_enroll()
is to support simulation of both the Lachin and Foulkes (1986) sample size
method for (fixed trial duration) as well as the Kim and Tsiatis(1990) method
(fixed enrollment rates and either fixed enrollment duration or fixed minimum follow-up);
see gsDesign
.
rpw_enroll(n = NULL, enroll_rate = tibble(duration = c(1, 2), rate = c(2, 5)))
n |
Number of observations.
Default of |
enroll_rate |
A tibble containing period duration ( |
A vector of random enrollment times.
library(tibble)
# Example 1
# piecewise uniform (piecewise exponential inter-arrival times) for 10k patients enrollment
# enrollment rates of 5 for time 0-100, 15 for 100-300, and 30 thereafter
x <- rpw_enroll(n = 1e5,
enroll_rate = tibble(rate = c(5, 15, 30),
duration = c(100, 200, 100)))
plot(x, 1:1e5,
main = "Piecewise uniform enrollment simulation",
xlab = "Time",
ylab = "Enrollment")
# Example 2
# exponential enrollment
x <- rpw_enroll(n = 1e5,
enroll_rate = tibble(rate = .03, duration = 1))
plot(x, 1:1e5,
main = "Simulated exponential inter-arrival times",
xlab = "Time",
ylab = "Enrollment")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.