Title: | Extended Chen-Poisson Lifetime Distribution |
---|---|
Description: | Computes the Extended Chen-Poisson (ecp) distribution, survival, density, hazard, cumulative hazard and quantile functions. It also allows to generate a pseudo-random sample from this distribution. 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] |
Maintainer: | Ana Abreu <[email protected]> |
License: | GPL-3 |
Version: | 0.2.1.9000 |
Built: | 2025-03-11 05:16:05 UTC |
Source: | https://github.com/abreu-uma/ecpdist |
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 function
decp(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 = "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 = "Hazard Function (Expression)") # Example of plotting an unimodal hazard function using data points x_data <- seq(0.0000001, 1, by=0.0001) ecp_plot(data_type = "data", x = x_data, lambda = 2, gamma = 0.3, phi = 30, func_type = "hazard", title = "Hazard Function (Data Points)")
# 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 = "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 = "Hazard Function (Expression)") # Example of plotting an unimodal hazard function using data points x_data <- seq(0.0000001, 1, by=0.0001) ecp_plot(data_type = "data", x = x_data, lambda = 2, gamma = 0.3, phi = 30, func_type = "hazard", title = "Hazard Function (Data Points)")
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 skewness
ecp_shape(2, 0.3, 30, measure = 'bowley') # Bowley skewness
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 function
hecp(2, 1, 1, 1, log = FALSE) # hazard 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 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 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 function
qecp(0.5, 2, 1, 1, lower_tail = TRUE, log_p = FALSE) # quantile function
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 10
recp(10,1,1,1) # random sample of size 10
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 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 function