View source: R/helper_functions.R
ppwe | R Documentation |
ppwe
computes the cumulative distribution function (CDF) or survival rate
for a piecewise exponential distribution.
ppwe( x = 0:20, failRates = tibble::tibble(duration = c(3, 100), rate = log(2)/c(9, 18)), lower.tail = FALSE )
x |
times at which distribution is to be computed. |
failRates |
Piecewise constant failure rates in |
lower.tail |
Indicator of whether lower (TRUE) or upper tail (FALSE; default) of CDF is to be computed. |
Suppose λ_i is the failure rate in the interval (t_{i-1},t_i], i=1,2,…,M where 0=t_0<t_i…,t_M=∞. The cumulative hazard function at an arbitrary time t>0 is then:
Λ(t)=∑_{i=1}^M δ(t≤ t_i)(\min(t,t_i)-t_{i-1})λ_i.
The survival at time t is then
S(t)=\exp(-Λ(t)).
A vector with cumulative distribution function or survival values
The contents of this section are shown in PDF user manual only.
# Example: default ppwe(seq(0:10)) # Example: plot a survival function with 2 different sets of time values # to demonstrate plot precision corresponding to input parameters. fr <- tibble::tibble(duration=c(3,3,1),rate=c(.2,.1,.005)) Time <- seq(0,10,10/pi) Survival <- ppwe(Time,fr) plot(Time,Survival,type="l",ylim=c(0,1)) Time <- seq(0,10,.25) Survival <- ppwe(Time,fr) lines(Time,Survival,col=2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.