| Title: | Piecewise Lifetime Models |
|---|---|
| Description: | Provides functions for estimation and data generation for several piecewise lifetime distributions. The package implements the power piecewise Weibull model, which includes the piecewise Rayleigh and piecewise exponential models as special cases. See Feigl and Zelen (1965) <doi:10.2307/2528247> for methodological details. |
| Authors: | Diego Gallardo [aut, cre], Yolanda Gomez [aut], Hector Gomez [aut], Barry Arnold [aut] |
| Maintainer: | Diego Gallardo <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 1.0 |
| Built: | 2026-06-04 07:44:09 UTC |
| Source: | https://github.com/cran/ppweibull |
Selects a time partition for the power piecewise Weibull model, given a maximum
number of allowed partitions. For choose.pweibull, the user may specify
whether the 's are equal (default FALSE), whether the
's are equal (default FALSE), and whether is
fixed (default FALSE).
For choose2.pweibull, the procedure selects the best combination among:
's different and 's different,
's equal and 's different,
's different and 's equal,
's different and (piecewise exponential distribution),
's different and (piecewise Rayleigh distribution).
choose.pweibull(formula, data, criteria = "AIC", L.max = 5, t = NULL, prec = 1e-04, max.iter = 1000, lambda.identical = FALSE, alpha.identical = FALSE, alpha.fixed = FALSE) choose2.pweibull(formula, data, criteria = "AIC", L.max = 5, t = NULL, prec = 1e-04, max.iter = 1000, alpha.fixed = c(1, 2))choose.pweibull(formula, data, criteria = "AIC", L.max = 5, t = NULL, prec = 1e-04, max.iter = 1000, lambda.identical = FALSE, alpha.identical = FALSE, alpha.fixed = FALSE) choose2.pweibull(formula, data, criteria = "AIC", L.max = 5, t = NULL, prec = 1e-04, max.iter = 1000, alpha.fixed = c(1, 2))
formula |
A model formula of class |
data |
An optional data frame, list, or environment containing the variables in the
model. If not found in |
criteria |
Model selection criterion: |
L.max |
Maximum number of partitions to consider (default |
t |
Optional fixed time partition. If provided, both |
prec |
Numerical tolerance for the estimation algorithm (default |
max.iter |
Maximum number of iterations for the estimation algorithm (default |
lambda.identical |
Logical; should the |
alpha.identical |
Logical; should the |
alpha.fixed |
If |
The hazard function of the power piecewise Weibull model is
where is the time partition,
and
.
The special cases include:
: the piecewise exponential model
(Feigl and Zelen, 1965; Friedman, 1982),
: a piecewise Rayleigh model.
A list with components:
estimate |
A matrix of parameter estimates and standard errors for the selected partition. |
logLik |
Log-likelihood evaluated at the parameter estimates. |
t |
Selected time partition. |
AIC |
Akaike Information Criterion. |
BIC |
Bayesian Information Criterion. |
L.sel |
Number of selected partitions. |
AIC.L |
AIC values for |
BIC.L |
BIC values for |
Diego I. Gallardo, Yolanda M. Gomez, Hector W. Gomez, and Barry C. Arnold.
Feigl P., Zelen M. (1965). Estimation of exponential survival probabilities with concomitant information. Biometrics, 21, 826-838.
Friedman M. (1982). Piecewise exponential models for survival data with covariates. Annals of Statistics, 10, 101-113.
Gomez Y. M., Gallardo D. I., Arnold B. C. (2018). The power piecewise exponential model. Journal of Statistical Computation and Simulation, 88, 825-840.
library(survival) set.seed(3100) n <- 200 x1 <- rnorm(n) x2 <- rnorm(n) ## drawing covariates lambda <- c(0.05, 0.03) rate <- exp(cbind(x1, x2) %*% c(0.5, -0.5)) time2 = c() for (i in 1:n) time2[i] <- rpweibull(1, rate = lambda * rate[i], alpha = c(1, 1), t = c(0, 10)) delta <- rbinom(n, size = 1, prob = 0.75) cc <- runif(n, 0, max(time2)) time <- ifelse(delta == 1, time2, cc) data <- data.frame(time = time, x1 = x1, x2 = x2, delta = delta) choose.pweibull(survival::Surv(time, delta) ~ x1 + x2, data = data, L.max = 3)library(survival) set.seed(3100) n <- 200 x1 <- rnorm(n) x2 <- rnorm(n) ## drawing covariates lambda <- c(0.05, 0.03) rate <- exp(cbind(x1, x2) %*% c(0.5, -0.5)) time2 = c() for (i in 1:n) time2[i] <- rpweibull(1, rate = lambda * rate[i], alpha = c(1, 1), t = c(0, 10)) delta <- rbinom(n, size = 1, prob = 0.75) cc <- runif(n, 0, max(time2)) time <- ifelse(delta == 1, time2, cc) data <- data.frame(time = time, x1 = x1, x2 = x2, delta = delta) choose.pweibull(survival::Surv(time, delta) ~ x1 + x2, data = data, L.max = 3)
Fits the power piecewise Weibull model and returns parameter estimates, standard errors, likelihood measures, and the selected time partition.
fit.pweibull(formula, data, L = 1, t = NULL, prec = 1e-04, max.iter = 1000, lambda.identical = FALSE, alpha.identical = FALSE, alpha.fixed = FALSE)fit.pweibull(formula, data, L = 1, t = NULL, prec = 1e-04, max.iter = 1000, lambda.identical = FALSE, alpha.identical = FALSE, alpha.fixed = FALSE)
formula |
A model formula of class |
data |
An optional data frame, list, or environment containing the variables in the
model. If not found in |
L |
Number of partitions to be used. Ignored if |
t |
A fixed time partition. Ignored if |
prec |
Numerical tolerance used in the estimation procedure (default |
max.iter |
Maximum number of iterations allowed in the estimation algorithm
(default |
lambda.identical |
Logical; should the |
alpha.identical |
Logical; should the |
alpha.fixed |
Should |
The hazard function of the power piecewise Weibull model is given by
where defines the time partition,
and
.
Special cases include:
: the piecewise exponential model
(Feigl and Zelen, 1965; Friedman, 1982),
: a piecewise Rayleigh model.
A list with components:
estimate |
A matrix containing parameter estimates and corresponding standard errors. |
logLik |
Log-likelihood evaluated at the estimated parameters. |
t |
The time partition used. |
AIC |
Akaike Information Criterion. |
BIC |
Bayesian Information Criterion. |
Diego I. Gallardo, Yolanda M. Gomez, Hector W. Gomez, and Barry C. Arnold.
Feigl P., Zelen M. (1965). Estimation of exponential survival probabilities with concomitant information. Biometrics, 21, 826-838.
Friedman M. (1982). Piecewise exponential models for survival data with covariates. Annals of Statistics, 10, 101-113.
Gomez Y. M., Gallardo D. I., Arnold B. C. (2018). The power piecewise exponential model. Journal of Statistical Computation and Simulation, 88, 825-840.
library(survival) set.seed(3100) n <- 200 x1 <- rnorm(n) x2 <- rnorm(n) ## design matrix x <- model.matrix(~ x1 + x2)[, -1] lambda <- c(0.05, 0.03) rate <- exp(cbind(x1, x2) %*% c(0.5, -0.5)) time <- numeric(n) for (i in 1:n) time[i] <- rpweibull(1, rate = lambda * rate[i], alpha = c(1, 1), t = c(0, 10)) delta <- rep(1, n) data <- data.frame(time = time, delta = delta, x1 = x1, x2 = x2) fit.pweibull(survival::Surv(time, delta) ~ x1 + x2, data = data, L = 2)library(survival) set.seed(3100) n <- 200 x1 <- rnorm(n) x2 <- rnorm(n) ## design matrix x <- model.matrix(~ x1 + x2)[, -1] lambda <- c(0.05, 0.03) rate <- exp(cbind(x1, x2) %*% c(0.5, -0.5)) time <- numeric(n) for (i in 1:n) time[i] <- rpweibull(1, rate = lambda * rate[i], alpha = c(1, 1), t = c(0, 10)) delta <- rep(1, n) data <- data.frame(time = time, delta = delta, x1 = x1, x2 = x2) fit.pweibull(survival::Surv(time, delta) ~ x1 + x2, data = data, L = 2)
Density, distribution function, quantile function, and random generation for the power piecewise Weibull distribution.
dpweibull(x, rate = 1, alpha = 1, t = 0, log = FALSE) ppweibull(q, rate = 1, alpha = 1, t = 0, lower.tail = TRUE, log.p = FALSE) qpweibull(p, rate = 1, alpha = 1, t = 0, lower.tail = TRUE, log.p = FALSE) rpweibull(n = 1, rate = 1, alpha = 1, t = 0)dpweibull(x, rate = 1, alpha = 1, t = 0, log = FALSE) ppweibull(q, rate = 1, alpha = 1, t = 0, lower.tail = TRUE, log.p = FALSE) qpweibull(p, rate = 1, alpha = 1, t = 0, lower.tail = TRUE, log.p = FALSE) rpweibull(n = 1, rate = 1, alpha = 1, t = 0)
x |
Vector of quantiles for the density function. |
q |
Vector of quantiles for the distribution function. |
p |
Vector of probabilities for the quantile function. |
n |
Number of observations to generate. If |
rate |
A numeric vector of length |
alpha |
A numeric vector of length |
t |
A non-decreasing vector defining the time partition
|
log |
Logical; if |
lower.tail |
Logical; if |
log.p |
Logical; if |
The hazard function of the power piecewise Weibull model is
where defines the partition of time,
, and
.
Special cases include:
:
the piecewise exponential model (Feigl and Zelen, 1965; Friedman, 1982),
:
a piecewise Rayleigh model.
dpweibull returns the density,
ppweibull returns the distribution function,
qpweibull returns the quantile function, and
rpweibull generates random deviates.
For rpweibull, the result has length n.
For the other functions, the result has length equal to the maximum of the
lengths of the numerical arguments. Arguments are recycled as needed.
Only the first elements of the logical arguments log, lower.tail,
and log.p are used.
Feigl P., Zelen M. (1965). Estimation of exponential survival probabilities with concomitant information. Biometrics, 21, 826-838.
Friedman M. (1982). Piecewise exponential models for survival data with covariates. Annals of Statistics, 10, 101-113.
Gomez Y. M., Gallardo D. I., Arnold B. C. (2018). The power piecewise exponential model. Journal of Statistical Computation and Simulation, 88, 825-840.
set.seed(3100) ## Random sample rpweibull(n = 10, rate = c(0.05, 0.03), alpha = c(1, 1.5), t = c(0, 10)) ## Distribution function ppweibull(c(5, 10, 20), rate = c(0.05, 0.03), alpha = c(1, 1.5), t = c(0, 10))set.seed(3100) ## Random sample rpweibull(n = 10, rate = c(0.05, 0.03), alpha = c(1, 1.5), t = c(0, 10)) ## Distribution function ppweibull(c(5, 10, 20), rate = c(0.05, 0.03), alpha = c(1, 1.5), t = c(0, 10))