Type: | Package |
Title: | Piecewise Exponential Distribution with Random Time Grids |
Version: | 0.0.1 |
Maintainer: | Fabio Demarqui <fndemarqui@est.ufmg.br> |
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>. |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
URL: | https://github.com/fndemarqui/peppm |
BugReports: | https://github.com/fndemarqui/peppm/issues |
Depends: | R (≥ 3.2.0) |
Imports: | Rcpp (≥ 1.0.1) |
LinkingTo: | Rcpp |
RoxygenNote: | 7.1.0 |
Suggests: | testthat |
NeedsCompilation: | yes |
Packaged: | 2020-06-24 22:16:27 UTC; fndemarqui |
Author: | Fabio Demarqui |
Repository: | CRAN |
Date/Publication: | 2020-06-25 08:50:02 UTC |
Probability function, distribution function, quantile function and random generation for the Piecewise Exponential (PE) distribution.
Description
Probability function, distribution function, quantile function and random generation for the Piecewise Exponential (PE) distribution.
Usage
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)
Arguments
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. |
Value
dpexp gives the (log) probability function, ppexp gives the (log) distribution function, qpexp gives the quantile function, and rpexp generates random deviates.
Examples
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
Function to identify the times' intervals
Description
Function to identify the times' intervals
Usage
findInt(time, tgrid)
Arguments
time |
vector of times. |
tgrid |
time grid of the PE distribution. |
Value
indicator of times's intervals
Examples
data(telecom)
tgrid <- with(telecom, timeGrid(time, status))
tgrid
findInt(telecom$time, tgrid)
Computes the time grid from the auxiliary vector U.
Description
Computes the time grid from the auxiliary vector U.
Usage
getGrid(U, ftgrid)
Arguments
U |
vector of change point indicators |
ftgrid |
vector with the finest time grid (distinct observed failure times) |
Value
the time grid associated with the auxiliary vector U.
Runs the Gibbs sampler
Description
Runs the Gibbs sampler
Usage
gibbs(
U0,
ftgrid,
time,
status,
a_rates,
b_rates,
cohesion,
a_beta,
b_beta,
npost,
nburnin,
nlag
)
Arguments
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. |
Value
posterior sample
Hazard and cumulative hazard functions of the PE distribution
Description
Hazard and cumulative hazard functions of the PE distribution
Usage
hpexp(x, tgrid, rates)
Hpexp(x, tgrid, rates)
Arguments
x |
vector of time points. |
tgrid |
vector of time grid knots. |
rates |
vector of failure rates. |
Value
hpexp gives the hazard function and Hpexp gives the cumulative hazard function of the PE distribution.
Piecewise Exponential Product Partition Model
Description
Piecewise Exponential Product Partition Model
Usage
peppm(
time,
status,
a_rates = 1,
b_rates = 1,
cohesion = 1,
a_beta = 1,
b_beta = 1,
nburnin = 10000,
npost = 20000,
nlag = 10
)
Arguments
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. |
Value
Posterior sample of the number of intervals, failure rates, the auxiliary vector U, and the logarithm of the prior predictive distribution (log data factor).
Examples
# 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))
GTE Corporation telecommunication systems
Description
Failure times (in days) of 125 installed telecommunication systems installed by GTE Corporation.
Format
A data frame with 125 rows and 2 variables:
time: vector of failure times (in days)
status: vector of failure indicator
Author(s)
Fabio N. Demarqui fndemarqui@est.ufmg.br
References
Piecewise Exponential Estimator for the Survival Function. J. S. Kim and F. Proschan. IEEE TRANSACTIONS ON RELIABILITY, VOL. 40, NO. 2, 1991.
Examples
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:
Time grid for the PE distribution
Description
This function make use of the observed times and failure indicators to create a time grid for the PE distribution.
Usage
timeGrid(time, status, n.int = NULL)
Arguments
time |
Vector of failure times |
status |
Vector of failure indicators |
n.int |
Optional. Number of intervals. If |
Value
the time grid needed to specify the PE distribution.
Examples
data(telecom)
tgrid1 <- with(telecom, timeGrid(time, status))
tgrid1
tgrid2 <- with(telecom, timeGrid(time, status, n.int = 4))
tgrid2