Title: | Piecewise Exponential Distribution with Random Time Grids |
---|---|
Description: | Fits the Piecewise Exponential distribution with random time grids using the clustering structure of the Product Partition Models. Details of the implemented model can be found in Demarqui et al. (2008) <doi:10.1007/s10985-008-9086-0>. |
Authors: | Fabio Demarqui [aut, cre] |
Maintainer: | Fabio Demarqui <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.0.1 |
Built: | 2025-01-26 03:55:20 UTC |
Source: | https://github.com/fndemarqui/peppm |
Function to identify the times' intervals
findInt(time, tgrid)
findInt(time, tgrid)
time |
vector of times. |
tgrid |
time grid of the PE distribution. |
indicator of times's intervals
data(telecom) tgrid <- with(telecom, timeGrid(time, status)) tgrid findInt(telecom$time, tgrid)
data(telecom) tgrid <- with(telecom, timeGrid(time, status)) tgrid findInt(telecom$time, tgrid)
Computes the time grid from the auxiliary vector U.
getGrid(U, ftgrid)
getGrid(U, ftgrid)
U |
vector of change point indicators |
ftgrid |
vector with the finest time grid (distinct observed failure times) |
the time grid associated with the auxiliary vector U.
Runs the Gibbs sampler
gibbs( U0, ftgrid, time, status, a_rates, b_rates, cohesion, a_beta, b_beta, npost, nburnin, nlag )
gibbs( U0, ftgrid, time, status, a_rates, b_rates, cohesion, a_beta, b_beta, npost, nburnin, nlag )
U0 |
vector of change point indicators |
ftgrid |
vector of indexes of distinct failure times |
time |
vector of observed failure times. |
status |
vector of failure indicators |
a_rates |
shape parameter of the gamma distribution (prior for failure rates). |
b_rates |
scale parameter of the gamma distribution (prior for failure rates). |
cohesion |
type of prior cohesion (1 to 4). |
a_beta |
shape1 parameter of the beta distribution (prior for p - cohesion 4). |
b_beta |
shape2 parameter of the beta distribution (prior for p - cohesion 4). |
npost |
desired posterior sample size |
nburnin |
number of iterations to be discarded. |
nlag |
number of jumps to eliminate autocorrelation of the chain. |
posterior sample
Hazard and cumulative hazard functions of the PE distribution
hpexp(x, tgrid, rates) Hpexp(x, tgrid, rates)
hpexp(x, tgrid, rates) Hpexp(x, tgrid, rates)
x |
vector of time points. |
tgrid |
vector of time grid knots. |
rates |
vector of failure rates. |
hpexp gives the hazard function and Hpexp gives the cumulative hazard function of the PE distribution.
Piecewise Exponential Product Partition Model
peppm( time, status, a_rates = 1, b_rates = 1, cohesion = 1, a_beta = 1, b_beta = 1, nburnin = 10000, npost = 20000, nlag = 10 )
peppm( time, status, a_rates = 1, b_rates = 1, cohesion = 1, a_beta = 1, b_beta = 1, nburnin = 10000, npost = 20000, nlag = 10 )
time |
vector of observed failure times. |
status |
vector of failure indicators |
a_rates |
shape parameter of the gamma distribution (prior for failure rates). |
b_rates |
scale parameter of the gamma distribution (prior for failure rates). |
cohesion |
type of prior cohesion (1 to 4). |
a_beta |
shape1 parameter of the beta distribution (prior for p - cohesion 4). |
b_beta |
shape2 parameter of the beta distribution (prior for p - cohesion 4). |
nburnin |
number of iterations to be discarded. |
npost |
desired posterior sample size |
nlag |
number of jumps to eliminate autocorrelation of the chain. |
Posterior sample of the number of intervals, failure rates, the auxiliary vector U, and the logarithm of the prior predictive distribution (log data factor).
# Small chain used here due to time constraints. data(telecom) # Prior cohesion 1: fit1 <- with(telecom, peppm(time, status, cohesion=1, nburnin = 0, nlag = 1, npost = 100)) # Prior cohesion 2: fit2 <- with(telecom, peppm(time, status, cohesion=2, nburnin = 0, nlag = 1, npost = 100)) # Prior cohesion 3: fit3 <- with(telecom, peppm(time, status, cohesion=3, nburnin = 0, nlag = 1, npost = 100)) # Prior cohesion 4: fit4 <- with(telecom, peppm(time, status, cohesion=4, nburnin = 0, nlag = 1, npost = 100))
# Small chain used here due to time constraints. data(telecom) # Prior cohesion 1: fit1 <- with(telecom, peppm(time, status, cohesion=1, nburnin = 0, nlag = 1, npost = 100)) # Prior cohesion 2: fit2 <- with(telecom, peppm(time, status, cohesion=2, nburnin = 0, nlag = 1, npost = 100)) # Prior cohesion 3: fit3 <- with(telecom, peppm(time, status, cohesion=3, nburnin = 0, nlag = 1, npost = 100)) # Prior cohesion 4: fit4 <- with(telecom, peppm(time, status, cohesion=4, nburnin = 0, nlag = 1, npost = 100))
Probability function, distribution function, quantile function and random generation for the Piecewise Exponential (PE) distribution.
dpexp(x, tgrid, rates, log = FALSE) ppexp(q, tgrid, rates, lower.tail = TRUE, log.p = FALSE) qpexp(p, tgrid, rates, lower.tail = TRUE, log.p = FALSE) rpexp(n, tgrid, rates)
dpexp(x, tgrid, rates, log = FALSE) ppexp(q, tgrid, rates, lower.tail = TRUE, log.p = FALSE) qpexp(p, tgrid, rates, lower.tail = TRUE, log.p = FALSE) rpexp(n, tgrid, rates)
x |
vector of time points. |
tgrid |
vector of time grid knots. |
rates |
vector of failure rates. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
q |
vector of quantiles. |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of random values to return. |
dpexp gives the (log) probability function, ppexp gives the (log) distribution function, qpexp gives the quantile function, and rpexp generates random deviates.
n <- 10 tgrid <- c(0, 1, 3, 7, Inf) rates <- c(0.5, 4, 0.8, 0.1) x <- sort(rpexp(n, tgrid=tgrid, rates=rates)) Fx <- ppexp(x, tgrid, rates) y <- qpexp(Fx, tgrid, rates) # checking: x==y
n <- 10 tgrid <- c(0, 1, 3, 7, Inf) rates <- c(0.5, 4, 0.8, 0.1) x <- sort(rpexp(n, tgrid=tgrid, rates=rates)) Fx <- ppexp(x, tgrid, rates) y <- qpexp(Fx, tgrid, rates) # checking: x==y
Failure times (in days) of 125 installed telecommunication systems installed by GTE Corporation.
A data frame with 125 rows and 2 variables:
time: vector of failure times (in days)
status: vector of failure indicator
Fabio N. Demarqui [email protected]
Piecewise Exponential Estimator for the Survival Function. J. S. Kim and F. Proschan. IEEE TRANSACTIONS ON RELIABILITY, VOL. 40, NO. 2, 1991.
library(peppm) data(telecom) fit1 <- with(telecom, peppm(time, status, cohesion=1, nburnin=0, nlag=1, npost=100)) fit2 <- with(telecom, peppm(time, status, cohesion=2, nburnin=0, nlag=1, npost=100)) fit3 <- with(telecom, peppm(time, status, cohesion=3, nburnin=0, nlag=1, npost=100)) fit4 <- with(telecom, peppm(time, status, cohesion=4, nburnin=0, nlag=1, npost=100)) # time grid associated with the first line of the matrix U:
library(peppm) data(telecom) fit1 <- with(telecom, peppm(time, status, cohesion=1, nburnin=0, nlag=1, npost=100)) fit2 <- with(telecom, peppm(time, status, cohesion=2, nburnin=0, nlag=1, npost=100)) fit3 <- with(telecom, peppm(time, status, cohesion=3, nburnin=0, nlag=1, npost=100)) fit4 <- with(telecom, peppm(time, status, cohesion=4, nburnin=0, nlag=1, npost=100)) # time grid associated with the first line of the matrix U:
This function make use of the observed times and failure indicators to create a time grid for the PE distribution.
timeGrid(time, status, n.int = NULL)
timeGrid(time, status, n.int = NULL)
time |
Vector of failure times |
status |
Vector of failure indicators |
n.int |
Optional. Number of intervals. If |
the time grid needed to specify the PE distribution.
data(telecom) tgrid1 <- with(telecom, timeGrid(time, status)) tgrid1 tgrid2 <- with(telecom, timeGrid(time, status, n.int = 4)) tgrid2
data(telecom) tgrid1 <- with(telecom, timeGrid(time, status)) tgrid1 tgrid2 <- with(telecom, timeGrid(time, status, n.int = 4)) tgrid2