hazard_fun: Hazard functions for any distribution

View source: R/hazard_fun.R

hazard_funR Documentation

Hazard functions for any distribution

Description

[Experimental]

This function takes the name of a probability density/mass function as an argument and creates a hazard function.

Usage

hazard_fun(distr, log = FALSE)

Arguments

distr

a length-one character vector with the name of density/mass function of interest.

log

logical; if TRUE, the natural logarithm of the hazard values are returned.

Value

A function with the folling input arguments:

x

vector of (non-negative) quantiles.

...

Arguments of the probability density/mass function.

Author(s)

Jaime Mosquera GutiƩrrez, jmosquerag@unal.edu.co

See Also

Other distributions utilities: cum_hazard_fun(), expected_value()

Examples

library(EstimationTools)

#----------------------------------------------------------------------------
# Example 1: Hazard function of the Weibull distribution.

# Hazard function in the 'maxlogL' framework
hweibull1 <- hazard_fun('dweibull')

# Hazard function from scratch
hweibull2 <- function(x, shape, scale){
  shape/scale * (x/scale)^(shape - 1)
}

# Comparison
hweibull1(0.2, shape = 2, scale = 1)
hweibull2(0.2, shape = 2, scale = 1)


#----------------------------------------------------------------------------


Jaimemosg/EstimationTools documentation built on Oct. 23, 2023, 10 a.m.