Package 'ecpdist'

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

Help Index


The k-th raw moment of the Chen distribution

Description

Computes the k-th raw moment of the Chen distribution.

Usage

chen_kmoment(k, lambda, gamma)

Arguments

k

a positive integer.

lambda, gamma

parameter values > 0.

Details

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.

Value

Estimated value of k-th raw moment, based on numerical integration, as well as integral absolute error obtained from the function integrate.

Examples

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.

The conditional k-th moment of the Chen distribution

Description

Computes the conditional k-th moment of the Chen distribution.

Usage

chen_kmoment_cond(x, k, lambda, gamma)

Arguments

x

vector of quantiles.

k

a positive integer.

lambda, gamma

parameter values > 0.

Details

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).

Value

Estimated value of conditional k-th moment, based on numerical integration, using the function integrate.

Examples

chen_kmoment_cond(x = 0, k = 1, lambda = .1, gamma = .5)

Mean residual life function of the Chen distribution

Description

Computes the mean residual life function of the Chen distribution.

Usage

chen_mrl(x, lambda, gamma)

Arguments

x

vector of quantiles.

lambda, gamma

parameter values > 0.

Value

Estimated value of mean residual life function, based on numerical integration.

Examples

chen_mrl(x = 5, lambda = .1, gamma = .5)

Plot function of the Chen distribution

Description

Plots the density, cumulative distribution, hazard, cumulative hazard, survival and quantile functions of the Chen distribution.

Usage

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
)

Arguments

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.

Value

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.

Examples

#  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))

Bowley skewness and Moors kurtosis of the Chen distribution

Description

Computes robust skewness and kurtosis measures based on quantile function of the Chen distribution.

Usage

chen_shape(lambda, gamma, measure)

Arguments

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.

Details

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.

Value

Numeric value of the Bowley skewness or the Moors kurtosis.

Examples

chen_shape(2, 0.3, measure = 'bowley') # Bowley skewness

Density function of the Chen distribution

Description

Compute the density function of the Chen distribution.

Usage

dchen(x, lambda, gamma, log = FALSE)

Arguments

x

vector of quantiles.

lambda, gamma

parameter values > 0.

log

logical value

Value

Numeric value of the density function.

If log = TRUE, numeric value of the logarithm of the function.

Examples

dchen(2, 1, 1, log = FALSE) # density function

Density function of the ecp distribution

Description

Compute the density function of the extended Chen-Poisson (ecp) distribution.

Usage

decp(x, lambda, gamma, phi, log = FALSE)

Arguments

x

vector of quantiles.

lambda, gamma

parameter values > 0.

phi

parameter value != 0.

log

logical value

Value

Numeric value of the density function.

If log = TRUE, numeric value of the logarithm of the function.

Examples

decp(2, 1, 1, 1, log = FALSE) # density function

The k-th raw moment of the extended Chen-Poisson distribution

Description

Computes the k-th raw moment of the extended Chen-Poisson (ecp) distribution.

Usage

ecp_kmoment(k, lambda, gamma, phi)

Arguments

k

a positive integer.

lambda, gamma

parameter values > 0.

phi

parameter value != 0.

Details

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.

Value

Estimated value of k-th raw moment, based on numerical integration, as well as integral absolute error obtained from the function integrate.

Examples

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.

The conditional k-th moment of the extended Chen-Poisson distribution

Description

Computes the conditional k-th moment of the extended Chen-Poisson (ecp) distribution.

Usage

ecp_kmoment_cond(x, k, lambda, gamma, phi)

Arguments

x

vector of quantiles.

k

a positive integer.

lambda, gamma

parameter values > 0.

phi

parameter value != 0.

Details

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).

Value

Estimated value of conditional k-th moment, based on numerical integration, using the function integrate.

Examples

ecp_kmoment_cond(x = 0, k = 1, lambda = .1, gamma = .5, phi = - .2)

Mean residual life function of the ecp distribution

Description

Computes the mean residual life function of the extended Chen-Poisson (ecp) distribution.

Usage

ecp_mrl(x, lambda, gamma, phi)

Arguments

x

vector of quantiles.

lambda, gamma

parameter values > 0.

phi

parameter value != 0.

Value

Estimated value of mean residual life function, based on numerical integration.

Examples

ecp_mrl(x = 5, lambda = .1, gamma = .5, phi = - .2)

Plot function of the ecp distribution

Description

Plots the density, cumulative distribution, hazard, cumulative hazard, survival and quantile functions of the extended Chen-Poisson (ecp) distribution.

Usage

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
)

Arguments

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.

Value

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.

Examples

#  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)

Bowley skewness and Moors kurtosis of the ecp distribution

Description

Computes robust skewness and kurtosis measures based on quantile function of the extended Chen-Poisson (ecp) distribution.

Usage

ecp_shape(lambda, gamma, phi, measure)

Arguments

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.

Details

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.

Value

Numeric value of the Bowley skewness or the Moors kurtosis.

Examples

ecp_shape(2, 0.3, 30, measure = 'bowley') # Bowley skewness

Hazard function of the Chen distribution

Description

Compute the hazard function of the Chen distribution.

Usage

hchen(x, lambda, gamma, log = FALSE)

Arguments

x

vector of quantiles.

lambda, gamma

parameter values > 0.

log

logical value

Value

Numeric value of the hazard function.

If log = TRUE, numeric value of the logarithm of the function.

Examples

hchen(2, 1, 1, log = FALSE) # hazard function

Hazard function of the ecp distribution

Description

Compute the hazard function of the extended Chen-Poisson (ecp) distribution.

Usage

hecp(x, lambda, gamma, phi, log = FALSE)

Arguments

x

vector of quantiles.

lambda, gamma

parameter values > 0.

phi

parameter value != 0.

log

logical value

Value

Numeric value of the hazard function.

If log = TRUE, numeric value of the logarithm of the function.

Examples

hecp(2, 1, 1, 1, log = FALSE) # hazard function

Distribution function of the Chen distribution

Description

Compute the cumulative distribution function of the Chen distribution.

Usage

pchen(q, lambda, gamma, lower_tail = TRUE, log_p = FALSE)

Arguments

q

vector of quantiles.

lambda, gamma

parameter values > 0.

lower_tail

similar to lower.tail

log_p

logical value

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.

Examples

pchen(2, 1, 1, lower_tail = TRUE, log_p = FALSE) # distribution function
pchen(2, 1, 1, lower_tail = FALSE, log_p = FALSE) # survival function

Distribution function of the ecp distribution

Description

Compute the cumulative distribution function of the extended Chen-Poisson (ecp) distribution.

Usage

pecp(q, lambda, gamma, phi, lower_tail = TRUE, log_p = FALSE)

Arguments

q

vector of quantiles.

lambda, gamma

parameter values > 0.

phi

parameter value != 0.

lower_tail

similar to lower.tail

log_p

logical value

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.

Examples

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

Quantile function of the Chen distribution

Description

Compute the quantile function of the Chen distribution.

Usage

qchen(p, lambda, gamma, lower_tail = TRUE, log_p = FALSE)

Arguments

p

vector of probabilities.

lambda, gamma

parameter values > 0.

lower_tail

similar to lower.tail.

log_p

logical value.

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.

Examples

qchen(0.5, 2, 1, lower_tail = TRUE, log_p = FALSE) # quantile function

Quantile function of the ecp distribution

Description

Compute the quantile function of the extended Chen-Poisson (ecp) distribution.

Usage

qecp(p, lambda, gamma, phi, lower_tail = TRUE, log_p = FALSE)

Arguments

p

vector of probabilities.

lambda, gamma

parameter values > 0.

phi

parameter value != 0.

lower_tail

similar to lower.tail.

log_p

logical value.

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.

Examples

qecp(0.5, 2, 1, 1, lower_tail = TRUE, log_p = FALSE)
# quantile function

Function to generate a pseudo-random sample of the Chen distribution

Description

Generate a pseudo-random sample, without censoring, from the Chen distribution.

Usage

rchen(n, lambda, gamma)

Arguments

n

sample size.

lambda, gamma

parameter values > 0.

Value

A vector of randomly generated numbers from the extended Chen-Poisson distribution.

Examples

rchen(10,1,1) # random sample of size 10

Function to generate a pseudo-random sample of the ecp distribution

Description

Generate a pseudo-random sample, without censoring, from the extended Chen-Poisson (ecp) distribution.

Usage

recp(n, lambda, gamma, phi)

Arguments

n

sample size.

lambda, gamma

parameter values > 0.

phi

parameter value != 0.

Value

A vector of randomly generated numbers from the extended Chen-Poisson distribution.

Examples

recp(10,1,1,1) # random sample of size 10

Survival function of the Chen distribution

Description

Compute the survival function of the Chen distribution.

Usage

schen(q, lambda, gamma, lower_tail = FALSE, cum_haz = FALSE)

Arguments

q

vector of quantiles.

lambda, gamma

parameter values > 0.

lower_tail

similar to lower.tail

cum_haz

logical value

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.

Examples

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
# function

Survival function of the ecp distribution

Description

Compute the survival function of the extended Chen-Poisson (ecp) distribution.

Usage

secp(q, lambda, gamma, phi, lower_tail = FALSE, cum_haz = FALSE)

Arguments

q

vector of quantiles.

lambda, gamma

parameter values > 0.

phi

parameter value != 0.

lower_tail

similar to lower.tail

cum_haz

logical value

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.

Examples

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