| Type: | Package |
| Title: | Piecewise Lifetime Models |
| Version: | 1.0 |
| Date: | 2026-02-02 |
| Maintainer: | Diego Gallardo <dgallardo@ubiobio.cl> |
| 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. |
| Depends: | R (≥ 4.0.0), stats |
| Imports: | survival, pracma, segmented, msm, nloptr |
| License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
| NeedsCompilation: | no |
| Packaged: | 2026-02-02 03:12:31 UTC; Diego |
| Author: | Diego Gallardo [aut, cre], Yolanda Gomez [aut], Hector Gomez [aut], Barry Arnold [aut] |
| Repository: | CRAN |
| Date/Publication: | 2026-02-04 18:10:02 UTC |
Choose a Partition for a Power Piecewise Weibull Model
Description
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 \lambda's are equal (default FALSE), whether the
\alpha's are equal (default FALSE), and whether \alpha is
fixed (default FALSE).
For choose2.pweibull, the procedure selects the best combination among:
-
\lambda's different and\alpha's different, -
\lambda's equal and\alpha's different, -
\lambda's different and\alpha's equal, -
\lambda's different and\alpha = 1(piecewise exponential distribution), -
\lambda's different and\alpha = 2(piecewise Rayleigh distribution).
Usage
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))
Arguments
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 |
Details
The hazard function of the power piecewise Weibull model is
h(t \mid \boldsymbol{\lambda}, \boldsymbol{\alpha})
= \lambda_\ell \alpha_\ell t^{\alpha_\ell - 1},
\qquad t \in (a_{\ell-1}, a_\ell),\; \ell = 1,\ldots,L,
where 0 = a_0 < a_1 < \cdots < a_L < \infty is the time partition,
\boldsymbol{\lambda} = (\lambda_1,\ldots,\lambda_L) and
\boldsymbol{\alpha} = (\alpha_1,\ldots,\alpha_L).
The special cases include:
-
\alpha_1 = \cdots = \alpha_L = 1: the piecewise exponential model (Feigl and Zelen, 1965; Friedman, 1982), -
\alpha_1 = \cdots = \alpha_L = 2: a piecewise Rayleigh model.
Value
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 |
Author(s)
Diego I. Gallardo, Yolanda M. Gomez, Hector W. Gomez, and Barry C. Arnold.
References
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.
Examples
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)
Parameter Estimation for the Power Piecewise Weibull Model
Description
Fits the power piecewise Weibull model and returns parameter estimates, standard errors, likelihood measures, and the selected time partition.
Usage
fit.pweibull(formula, data, L = 1, t = NULL, prec = 1e-04, max.iter = 1000,
lambda.identical = FALSE, alpha.identical = FALSE, alpha.fixed = FALSE)
Arguments
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 |
Details
The hazard function of the power piecewise Weibull model is given by
h(t \mid \boldsymbol{\lambda}, \boldsymbol{\alpha})
= \lambda_\ell \alpha_\ell t^{\alpha_\ell - 1},
\qquad t \in (a_{\ell-1}, a_\ell),\; \ell = 1, \ldots, L,
where 0 = a_0 < a_1 < \cdots < a_L < \infty defines the time partition,
\boldsymbol{\lambda} = (\lambda_1, \ldots, \lambda_L) and
\boldsymbol{\alpha} = (\alpha_1, \ldots, \alpha_L).
Special cases include:
-
\alpha_1 = \cdots = \alpha_L = 1: the piecewise exponential model (Feigl and Zelen, 1965; Friedman, 1982), -
\alpha_1 = \cdots = \alpha_L = 2: a piecewise Rayleigh model.
Value
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. |
Author(s)
Diego I. Gallardo, Yolanda M. Gomez, Hector W. Gomez, and Barry C. Arnold.
References
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.
Examples
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)
The Power Piecewise Weibull Distribution
Description
Density, distribution function, quantile function, and random generation for the power piecewise Weibull distribution.
Usage
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)
Arguments
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 |
Details
The hazard function of the power piecewise Weibull model is
h(t \mid \boldsymbol{\lambda}, \boldsymbol{\alpha})
= \lambda_\ell \alpha_\ell t^{\alpha_\ell - 1},
\qquad t \in (a_{\ell - 1}, a_\ell),\; \ell = 1, \ldots, L,
where 0 = a_0 < a_1 < \cdots < a_{L - 1} < a_L < \infty defines the partition of time,
\boldsymbol{\lambda} = (\lambda_1, \ldots, \lambda_L), and
\boldsymbol{\alpha} = (\alpha_1, \ldots, \alpha_L).
Special cases include:
-
\alpha_1 = \cdots = \alpha_L = 1: the piecewise exponential model (Feigl and Zelen, 1965; Friedman, 1982), -
\alpha_1 = \cdots = \alpha_L = 2: a piecewise Rayleigh model.
Value
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.
References
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.
Examples
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))