Description Usage Arguments Details Examples
The piecewise exponential distribution allows a simple method to specify a distribtuion
where the hazard rate changes over time. It is likely to be useful for conditions where
failure rates change, but also for simulations where there may be a delayed treatment
effect or a treatment effect that that is otherwise changing (e.g., decreasing) over time.
rpwexp()
is to support simulation 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
.
1 |
n |
Number of observations. If length(n) > 1, the length is taken to be the number required. |
rate |
Vector containing exponential failure rates in intervals described by
|
intervals |
Vector containing positive values indicating interval lengths where
the exponential rates provided in |
cumulative |
|
Using the cumulative=TRUE
option, enrollment times that piecewise constant over
time can be generated.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # get 10k piecewise exponential failure times
# failure rates are 1 for time 0-.5, 3 for time .5 - 1 and 10 for >1.
# intervals specifies duration of each failure rate interval
# with the final interval running to infinity
x <- rpwexp(10000, rate = c(1, 3, 10), intervals = c(.5,.5))
plot(sort(x),(10000:1)/10001,log="y", main="PW Exponential simulated survival curve",
xlab="Time",ylab="P{Survival}")
# 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 <- rpwexp(10000, rate = c(5, 15, 30), intervals = c(100,200), cumulative=TRUE)
plot(x,1:10000,
main="Piecewise uniform enrollment simulation",xlab="Time",
ylab="Enrollment")
# exponential enrollment
x <- rpwexp(10000, rate = .03, intervals = NULL, cumulative=TRUE)
plot(x,1:10000,main="Simulated exponential inter-arrival times",
xlab="Time",ylab="Enrollment")
# exponential failure times
x <- rpwexp(10000, rate = 5)
plot(sort(x),(10000:1)/10001,log="y", main="Exponential simulated survival curve",
xlab="Time",ylab="P{Survival}")
library(ggplot2)
qplot(sort(x),(10000:1)/10001,geom="line") + scale_y_log10(breaks=c(1,.1,.01)) +
ggtitle("Exponential simulated survival curve") +
xlab("Time")+ylab("P{Survival}")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.