Usage
cum_hazard_fun(
distr,
support = NULL,
method = c("log_sf", "integration"),
routine = NULL
)
Arguments
- distr
a length-one character vector with the name of density/mass function of interest.
- support
a list with the following entries:
interval
: a two dimensional atomic vector indicating the set of possible values of a random variable having the distribution specified iny_dist
.type
: character indicating if distribution has adiscrete
or acontinous
random variable.
- method
a character or function; if
"log_sf"
, the cumulative hazard function (CHF) is computed using the expression \(H(t) = -\log (S(t))\); if"integrate_hf"
, the CHF is computed with the integral of the hazard function.- routine
a character specifying the integration routine.
integrate
andgauss_quad
are available for continuous distributions, andsummate
for discrete ones. Custom routines can be defined but they must be compatible with theintegration
API.
Value
A function with the following input arguments:
- x
vector of (non-negative) quantiles.
- ...
Arguments of the probability density/mass function.
See also
Other distributions utilities:
expected_value()
,
hazard_fun()
Author
Jaime Mosquera Gutiérrez, jmosquerag@unal.edu.co
Examples
library(EstimationTools)
#----------------------------------------------------------------------------
# Example 1: Cumulative hazard function of the Weibull distribution.
support <- list(interval=c(0, Inf), type='continuous')
# Cumuative hazard function in the 'maxlogL' framework
Hweibull1 <- cum_hazard_fun(
distr = 'dweibull',
support = support,
method = "integration"
)
Hweibull2 <- cum_hazard_fun(
distr = 'dweibull',
method = "log_sf"
)
# Compute cumulative hazard function from scratch
# Recall h(x) = shape/scale * (x/scale)^(shape - 1), then
# H(x) = (x/scale)^shape
Hweibull3 <- function(x, scale, shape){
(x/scale)^shape
}
# Comparison
Hweibull1(0.2, shape = 2, scale = 1) # using H(t) = -log(S(t))
#> [1] 0.04
Hweibull2(0.2, shape = 2, scale = 1) # integrating h(t)
#> [1] 0.04
Hweibull3(0.2, shape = 2, scale = 1) # raw version
#> [1] 0.04
#----------------------------------------------------------------------------