| Title: | Extended Chen-Poisson Lifetime Distribution |
|---|---|
| Description: | Computes the Chen and the Extended Chen-Poisson (ecp) distribution, survival, density, hazard, cumulative hazard and quantile functions. It also allows to generate a pseudo-random sample from these distributions. The corresponding graphics are available. Functions to obtain measures of skewness and kurtosis, k-th raw moments, conditional k-th moments and mean residual life function were added. For details about ecp distribution, see Sousa-Ferreira, I., Abreu, A.M. & Rocha, C. (2023). <doi:10.57805/revstat.v21i2.405>. |
| Authors: | Ana Abreu [aut, cre, cph] (ORCID: <https://orcid.org/0000-0002-6155-8492>), Ivo Sousa-Ferreira [aut] (ORCID: <https://orcid.org/0000-0001-5526-3594>), Cristina Rocha [ctb] |
| Maintainer: | Ana Abreu <[email protected]> |
| License: | GPL-3 |
| Version: | 0.3.0 |
| Built: | 2026-05-24 07:47:40 UTC |
| Source: | https://github.com/abreu-uma/ecpdist |
Computes the k-th raw moment of the Chen distribution.
chen_kmoment(k, lambda, gamma)chen_kmoment(k, lambda, gamma)
k |
a positive integer. |
lambda, gamma
|
parameter values > 0. |
To obtain the value of k-th raw moment of the Chen distribution, it is necessary to use numerical integration. For that purpose, the R function 'integrate()' can be used, which returns the estimated value of the integral and also the integral absolute error (see details about function 'integrate()'). Therefore, to obtain the variance, the first component of each k-th raw moments must be selected.
Estimated value of k-th raw moment, based on numerical integration, as well as integral absolute error obtained from the function integrate.
chen_kmoment(k = 1, lambda = .1, gamma = .5) # First raw moment. chen_kmoment(k = 2, lambda = .1, gamma = .5) # Second raw moment. chen_kmoment(k = 2, lambda = .1, gamma = .5)[1] - chen_kmoment(k = 1, lambda = .1, gamma = .5)[1]^2 # Variance.chen_kmoment(k = 1, lambda = .1, gamma = .5) # First raw moment. chen_kmoment(k = 2, lambda = .1, gamma = .5) # Second raw moment. chen_kmoment(k = 2, lambda = .1, gamma = .5)[1] - chen_kmoment(k = 1, lambda = .1, gamma = .5)[1]^2 # Variance.
Computes the conditional k-th moment of the Chen distribution.
chen_kmoment_cond(x, k, lambda, gamma)chen_kmoment_cond(x, k, lambda, gamma)
x |
vector of quantiles. |
k |
a positive integer. |
lambda, gamma
|
parameter values > 0. |
The conditional k-th moment of a distribution is given by E(X^k | X > x). To obtain this value for the Chen distribution, it is necessary to use numerical integration. For that purpose, the R function 'integrate()'can be used (see details about function 'integrate()'). Note that when k = 1 and x = 0, the conditional moment is equal to the expected value, i.e., E(X | X > 0) = E(X).
Estimated value of conditional k-th moment, based on numerical integration, using the function integrate.
chen_kmoment_cond(x = 0, k = 1, lambda = .1, gamma = .5)chen_kmoment_cond(x = 0, k = 1, lambda = .1, gamma = .5)
Computes the mean residual life function of the Chen distribution.
chen_mrl(x, lambda, gamma)chen_mrl(x, lambda, gamma)
x |
vector of quantiles. |
lambda, gamma
|
parameter values > 0. |
Estimated value of mean residual life function, based on numerical integration.
chen_mrl(x = 5, lambda = .1, gamma = .5)chen_mrl(x = 5, lambda = .1, gamma = .5)
Plots the density, cumulative distribution, hazard, cumulative hazard, survival and quantile functions of the Chen distribution.
chen_plot( data_type, from = NULL, to = NULL, xlim = NULL, ylim = NULL, x = NULL, lambda, gamma, log = FALSE, func_type, title, col = "blue", lty = 1 )chen_plot( data_type, from = NULL, to = NULL, xlim = NULL, ylim = NULL, x = NULL, lambda, gamma, log = FALSE, func_type, title, col = "blue", lty = 1 )
data_type |
specifies whether the input is a x vector of data values or an expression. Possible types are - 'data' for data values, - 'expression' for expression. |
from |
lower x axis limit, by default from = 0. |
to |
upper x axis limit, by default to = 1. |
xlim |
x axis limits, by default xlim = c(from, to). |
ylim |
y axis limits. |
x |
vector of data values when data_type = "data". |
lambda, gamma
|
parameter values > 0. |
log |
logical value. |
func_type |
specifies the type of function to be plotted. Possible types are - 'density' for density plot, - 'hazard' for hazard plot, - 'cumulative hazard' for cumulative hazard plot, - 'survival' for survival plot, - 'cumulative distribution' for cumulative distribution plot, - 'quantile' for quantile plot. |
title |
title of the graphic. |
col |
to set the color of the graphic. |
lty |
to set the line type. |
If log = TRUE, numeric value of the logarithm of the function.
If cum_haz = TRUE, numeric value of the cumulative hazard function.
graphic of the chosen chen function.
# Example of plotting cumulative distribution using an expression chen_plot(data_type = "expression", from = 0, to = 6, lambda = 2, gamma = 0.3, func_type = "cumulative distribution", title = "Chen cumulative distribution function (expression)") # Example of plotting a bathtub-shaped hazard function using an expression chen_plot(data_type = "expression", lambda = 2, gamma = 0.3, func_type = "hazard", title = "Chen hazard function (expression)", to = 100, ylim = c(0.8, 1.8)) # Example of plotting a bathtub-shaped hazard function using data points x_data <- seq(0.0000001, 100, by = 0.1) chen_plot(data_type = "data", x = x_data, lambda = 2, gamma = 0.3, func_type = "hazard", title = "Chen hazard function (data points)", to = 100, ylim = c(0.8, 1.8))# Example of plotting cumulative distribution using an expression chen_plot(data_type = "expression", from = 0, to = 6, lambda = 2, gamma = 0.3, func_type = "cumulative distribution", title = "Chen cumulative distribution function (expression)") # Example of plotting a bathtub-shaped hazard function using an expression chen_plot(data_type = "expression", lambda = 2, gamma = 0.3, func_type = "hazard", title = "Chen hazard function (expression)", to = 100, ylim = c(0.8, 1.8)) # Example of plotting a bathtub-shaped hazard function using data points x_data <- seq(0.0000001, 100, by = 0.1) chen_plot(data_type = "data", x = x_data, lambda = 2, gamma = 0.3, func_type = "hazard", title = "Chen hazard function (data points)", to = 100, ylim = c(0.8, 1.8))
Computes robust skewness and kurtosis measures based on quantile function of the Chen distribution.
chen_shape(lambda, gamma, measure)chen_shape(lambda, gamma, measure)
lambda, gamma
|
parameter values > 0. |
measure |
Specifies the type of measure to be computed. Possible types are: - 'bowley' for Bowley skewness, - 'moors' for Moors kurtosis. |
The Chen distribution has no closed-form expression for the moments. Therefore, the classical measures of skewness and kurtosis based on moments are intractable. In such cases, quantile-based measures are often considered, namely the Bowley skewness and Moors kurtosis.
Numeric value of the Bowley skewness or the Moors kurtosis.
chen_shape(2, 0.3, measure = 'bowley') # Bowley skewnesschen_shape(2, 0.3, measure = 'bowley') # Bowley skewness
Compute the density function of the Chen distribution.
dchen(x, lambda, gamma, log = FALSE)dchen(x, lambda, gamma, log = FALSE)
x |
vector of quantiles. |
lambda, gamma
|
parameter values > 0. |
log |
logical value |
Numeric value of the density function.
If log = TRUE, numeric value of the logarithm of the function.
dchen(2, 1, 1, log = FALSE) # density functiondchen(2, 1, 1, log = FALSE) # density function
Compute the density function of the extended Chen-Poisson (ecp) distribution.
decp(x, lambda, gamma, phi, log = FALSE)decp(x, lambda, gamma, phi, log = FALSE)
x |
vector of quantiles. |
lambda, gamma
|
parameter values > 0. |
phi |
parameter value != 0. |
log |
logical value |
Numeric value of the density function.
If log = TRUE, numeric value of the logarithm of the function.
decp(2, 1, 1, 1, log = FALSE) # density functiondecp(2, 1, 1, 1, log = FALSE) # density function
Computes the k-th raw moment of the extended Chen-Poisson (ecp) distribution.
ecp_kmoment(k, lambda, gamma, phi)ecp_kmoment(k, lambda, gamma, phi)
k |
a positive integer. |
lambda, gamma
|
parameter values > 0. |
phi |
parameter value != 0. |
To obtain the value of k-th raw moment of the Extended Chen-Poisson distribution, it is necessary to use numerical integration. For that purpose, the R function 'integrate()' can be used, which returns the estimated value of the integral and also the integral absolute error (see details about function 'integrate()'). Therefore, to obtain the variance, the first component of each k-th raw moments must be selected.
Estimated value of k-th raw moment, based on numerical integration, as well as integral absolute error obtained from the function integrate.
ecp_kmoment(k = 1, lambda = .1, gamma = .5, phi = - .2) # First raw moment. ecp_kmoment(k = 2, lambda = .1, gamma = .5, phi = - .2) # Second raw moment. ecp_kmoment(k = 2, lambda = .1, gamma = .5, phi = - .2)[1] - ecp_kmoment(k = 1, lambda = .1, gamma = .5, phi = - .2)[1]^2 # Variance.ecp_kmoment(k = 1, lambda = .1, gamma = .5, phi = - .2) # First raw moment. ecp_kmoment(k = 2, lambda = .1, gamma = .5, phi = - .2) # Second raw moment. ecp_kmoment(k = 2, lambda = .1, gamma = .5, phi = - .2)[1] - ecp_kmoment(k = 1, lambda = .1, gamma = .5, phi = - .2)[1]^2 # Variance.
Computes the conditional k-th moment of the extended Chen-Poisson (ecp) distribution.
ecp_kmoment_cond(x, k, lambda, gamma, phi)ecp_kmoment_cond(x, k, lambda, gamma, phi)
x |
vector of quantiles. |
k |
a positive integer. |
lambda, gamma
|
parameter values > 0. |
phi |
parameter value != 0. |
The conditional k-th moment of a distribution is given by E(X^k | X > x). To obtain this value for the Extended Chen-Poisson distribution, it is necessary to use numerical integration. For that purpose, the R function 'integrate()' can be used (see details about function 'integrate()'). Note that when k = 1 and x = 0, the conditional moment is equal to the expected value, i.e., E(X | X > 0) = E(X).
Estimated value of conditional k-th moment, based on numerical integration, using the function integrate.
ecp_kmoment_cond(x = 0, k = 1, lambda = .1, gamma = .5, phi = - .2)ecp_kmoment_cond(x = 0, k = 1, lambda = .1, gamma = .5, phi = - .2)
Computes the mean residual life function of the extended Chen-Poisson (ecp) distribution.
ecp_mrl(x, lambda, gamma, phi)ecp_mrl(x, lambda, gamma, phi)
x |
vector of quantiles. |
lambda, gamma
|
parameter values > 0. |
phi |
parameter value != 0. |
Estimated value of mean residual life function, based on numerical integration.
ecp_mrl(x = 5, lambda = .1, gamma = .5, phi = - .2)ecp_mrl(x = 5, lambda = .1, gamma = .5, phi = - .2)
Plots the density, cumulative distribution, hazard, cumulative hazard, survival and quantile functions of the extended Chen-Poisson (ecp) distribution.
ecp_plot( data_type, from = NULL, to = NULL, xlim = NULL, ylim = NULL, x = NULL, lambda, gamma, phi, log = FALSE, func_type, title, col = "black", lty = 1 )ecp_plot( data_type, from = NULL, to = NULL, xlim = NULL, ylim = NULL, x = NULL, lambda, gamma, phi, log = FALSE, func_type, title, col = "black", lty = 1 )
data_type |
specifies whether the input is a x vector of data values or an expression. Possible types are - 'data' for data values, - 'expression' for expression. |
from |
lower x axis limit, by default from = 0. |
to |
upper x axis limit, by default to = 1. |
xlim |
x axis limits, by default xlim = c(from, to). |
ylim |
y axis limits. |
x |
vector of data values when data_type = "data". |
lambda, gamma
|
parameter values > 0. |
phi |
parameter value != 0. |
log |
logical value. |
func_type |
specifies the type of function to be plotted. Possible types are - 'density' for density plot, - 'hazard' for hazard plot, - 'cumulative hazard' for cumulative hazard plot, - 'survival' for survival plot, - 'cumulative distribution' for cumulative distribution plot, - 'quantile' for quantile plot. |
title |
title of the graphic. |
col |
to set the color of the graphic. |
lty |
to set the line type. |
If log = TRUE, numeric value of the logarithm of the function.
If cum_haz = TRUE, numeric value of the cumulative hazard function.
graphic of the chosen ecp function.
# Example of plotting cumulative distribution using an expression ecp_plot(data_type = "expression", from = 0, to = 6, lambda = 2, gamma = 0.3, phi = 30, func_type = "cumulative distribution", title = "ecp cumulative distribution function (expression)") # Example of plotting an unimodal hazard function using an expression ecp_plot(data_type = "expression", lambda = 2, gamma = 0.3, phi = 30, func_type = "hazard", title = "ecp hazard function (expression)", to = 10) # Example of plotting an unimodal hazard function using data points x_data <- seq(0.0000001, 10, by = 0.01) ecp_plot(data_type = "data", x = x_data, lambda = 2, gamma = 0.3, phi = 30, func_type = "hazard", title = "ecp hazard function (data points)", to = 10)# Example of plotting cumulative distribution using an expression ecp_plot(data_type = "expression", from = 0, to = 6, lambda = 2, gamma = 0.3, phi = 30, func_type = "cumulative distribution", title = "ecp cumulative distribution function (expression)") # Example of plotting an unimodal hazard function using an expression ecp_plot(data_type = "expression", lambda = 2, gamma = 0.3, phi = 30, func_type = "hazard", title = "ecp hazard function (expression)", to = 10) # Example of plotting an unimodal hazard function using data points x_data <- seq(0.0000001, 10, by = 0.01) ecp_plot(data_type = "data", x = x_data, lambda = 2, gamma = 0.3, phi = 30, func_type = "hazard", title = "ecp hazard function (data points)", to = 10)
Computes robust skewness and kurtosis measures based on quantile function of the extended Chen-Poisson (ecp) distribution.
ecp_shape(lambda, gamma, phi, measure)ecp_shape(lambda, gamma, phi, measure)
lambda, gamma
|
parameter values > 0. |
phi |
parameter value != 0. |
measure |
Specifies the type of measure to be computed. Possible types are: - 'bowley' for Bowley skewness, - 'moors' for Moors kurtosis. |
The Extended Chen-Poisson distribution has no closed-form expression for the moments. Therefore, the classical measures of skewness and kurtosis based on moments are intractable. In such cases, quantile-based measures are often considered, namely the Bowley skewness and Moors kurtosis.
Numeric value of the Bowley skewness or the Moors kurtosis.
ecp_shape(2, 0.3, 30, measure = 'bowley') # Bowley skewnessecp_shape(2, 0.3, 30, measure = 'bowley') # Bowley skewness
Compute the hazard function of the Chen distribution.
hchen(x, lambda, gamma, log = FALSE)hchen(x, lambda, gamma, log = FALSE)
x |
vector of quantiles. |
lambda, gamma
|
parameter values > 0. |
log |
logical value |
Numeric value of the hazard function.
If log = TRUE, numeric value of the logarithm of the function.
hchen(2, 1, 1, log = FALSE) # hazard functionhchen(2, 1, 1, log = FALSE) # hazard function
Compute the hazard function of the extended Chen-Poisson (ecp) distribution.
hecp(x, lambda, gamma, phi, log = FALSE)hecp(x, lambda, gamma, phi, log = FALSE)
x |
vector of quantiles. |
lambda, gamma
|
parameter values > 0. |
phi |
parameter value != 0. |
log |
logical value |
Numeric value of the hazard function.
If log = TRUE, numeric value of the logarithm of the function.
hecp(2, 1, 1, 1, log = FALSE) # hazard functionhecp(2, 1, 1, 1, log = FALSE) # hazard function
Compute the cumulative distribution function of the Chen distribution.
pchen(q, lambda, gamma, lower_tail = TRUE, log_p = FALSE)pchen(q, lambda, gamma, lower_tail = TRUE, log_p = FALSE)
q |
vector of quantiles. |
lambda, gamma
|
parameter values > 0. |
lower_tail |
similar to lower.tail |
log_p |
logical value |
Numeric value of the distribution function.
If lower_tail = FALSE, numeric value of the survival function.
If log_p = TRUE, numeric value of the logarithm of the function.
pchen(2, 1, 1, lower_tail = TRUE, log_p = FALSE) # distribution function pchen(2, 1, 1, lower_tail = FALSE, log_p = FALSE) # survival functionpchen(2, 1, 1, lower_tail = TRUE, log_p = FALSE) # distribution function pchen(2, 1, 1, lower_tail = FALSE, log_p = FALSE) # survival function
Compute the cumulative distribution function of the extended Chen-Poisson (ecp) distribution.
pecp(q, lambda, gamma, phi, lower_tail = TRUE, log_p = FALSE)pecp(q, lambda, gamma, phi, lower_tail = TRUE, log_p = FALSE)
q |
vector of quantiles. |
lambda, gamma
|
parameter values > 0. |
phi |
parameter value != 0. |
lower_tail |
similar to lower.tail |
log_p |
logical value |
Numeric value of the distribution function.
If lower_tail = FALSE, numeric value of the survival function.
If log_p = TRUE, numeric value of the logarithm of the function.
pecp(2, 1, 1, 1, lower_tail = TRUE, log_p = FALSE) # distribution function pecp(2, 1, 1, 1, lower_tail = FALSE, log_p = FALSE) # survival functionpecp(2, 1, 1, 1, lower_tail = TRUE, log_p = FALSE) # distribution function pecp(2, 1, 1, 1, lower_tail = FALSE, log_p = FALSE) # survival function
Compute the quantile function of the Chen distribution.
qchen(p, lambda, gamma, lower_tail = TRUE, log_p = FALSE)qchen(p, lambda, gamma, lower_tail = TRUE, log_p = FALSE)
p |
vector of probabilities. |
lambda, gamma
|
parameter values > 0. |
lower_tail |
similar to lower.tail. |
log_p |
logical value. |
Numeric value of the quantile function.
If lower_tail = FALSE, numeric value of the logarithm of the function.
If log_p = TRUE, numeric value of the logarithm of the function.
qchen(0.5, 2, 1, lower_tail = TRUE, log_p = FALSE) # quantile functionqchen(0.5, 2, 1, lower_tail = TRUE, log_p = FALSE) # quantile function
Compute the quantile function of the extended Chen-Poisson (ecp) distribution.
qecp(p, lambda, gamma, phi, lower_tail = TRUE, log_p = FALSE)qecp(p, lambda, gamma, phi, lower_tail = TRUE, log_p = FALSE)
p |
vector of probabilities. |
lambda, gamma
|
parameter values > 0. |
phi |
parameter value != 0. |
lower_tail |
similar to lower.tail. |
log_p |
logical value. |
Numeric value of the quantile function.
If lower_tail = FALSE, numeric value of the logarithm of the function.
If log_p = TRUE, numeric value of the logarithm of the function.
qecp(0.5, 2, 1, 1, lower_tail = TRUE, log_p = FALSE) # quantile functionqecp(0.5, 2, 1, 1, lower_tail = TRUE, log_p = FALSE) # quantile function
Generate a pseudo-random sample, without censoring, from the Chen distribution.
rchen(n, lambda, gamma)rchen(n, lambda, gamma)
n |
sample size. |
lambda, gamma
|
parameter values > 0. |
A vector of randomly generated numbers from the extended Chen-Poisson distribution.
rchen(10,1,1) # random sample of size 10rchen(10,1,1) # random sample of size 10
Generate a pseudo-random sample, without censoring, from the extended Chen-Poisson (ecp) distribution.
recp(n, lambda, gamma, phi)recp(n, lambda, gamma, phi)
n |
sample size. |
lambda, gamma
|
parameter values > 0. |
phi |
parameter value != 0. |
A vector of randomly generated numbers from the extended Chen-Poisson distribution.
recp(10,1,1,1) # random sample of size 10recp(10,1,1,1) # random sample of size 10
Compute the survival function of the Chen distribution.
schen(q, lambda, gamma, lower_tail = FALSE, cum_haz = FALSE)schen(q, lambda, gamma, lower_tail = FALSE, cum_haz = FALSE)
q |
vector of quantiles. |
lambda, gamma
|
parameter values > 0. |
lower_tail |
similar to lower.tail |
cum_haz |
logical value |
Numeric value of the survival function.
If lower_tail = TRUE, numeric value of the distribution function.
If cum_haz = TRUE, numeric value of the cumulative hazard function.
schen(2, 1, 1, lower_tail = FALSE, cum_haz = FALSE) # survival function schen(2, 1, 1, lower_tail = TRUE, cum_haz = FALSE) # distribution function schen(2, 1, 1, lower_tail = FALSE, cum_haz = TRUE) # cumulative hazard # functionschen(2, 1, 1, lower_tail = FALSE, cum_haz = FALSE) # survival function schen(2, 1, 1, lower_tail = TRUE, cum_haz = FALSE) # distribution function schen(2, 1, 1, lower_tail = FALSE, cum_haz = TRUE) # cumulative hazard # function
Compute the survival function of the extended Chen-Poisson (ecp) distribution.
secp(q, lambda, gamma, phi, lower_tail = FALSE, cum_haz = FALSE)secp(q, lambda, gamma, phi, lower_tail = FALSE, cum_haz = FALSE)
q |
vector of quantiles. |
lambda, gamma
|
parameter values > 0. |
phi |
parameter value != 0. |
lower_tail |
similar to lower.tail |
cum_haz |
logical value |
Numeric value of the survival function.
If lower_tail = TRUE, numeric value of the distribution function.
If cum_haz = TRUE, numeric value of the cumulative hazard function.
secp(2, 1, 1, 1, lower_tail = FALSE, cum_haz = FALSE) # survival function secp(2, 1, 1, 1, lower_tail = TRUE, cum_haz = FALSE) # distribution function secp(2, 1, 1, 1, lower_tail = FALSE, cum_haz = TRUE) # cumulative # hazard functionsecp(2, 1, 1, 1, lower_tail = FALSE, cum_haz = FALSE) # survival function secp(2, 1, 1, 1, lower_tail = TRUE, cum_haz = FALSE) # distribution function secp(2, 1, 1, 1, lower_tail = FALSE, cum_haz = TRUE) # cumulative # hazard function