Hazard Based Distributions

Abstract type describing a distribution based on the hazard function.

JointSurvivalModels.HazardBasedDistributionType
HazardBasedDistribution <: ContinuousUnivariateDistribution

HazardBasedDistribution is a type that builds a distribution based on a hazard function.

To use this type to formulate a distribution yourself: implement a struct and the hazard function.

struct LogLogistic <: HazardBasedDistribution
    α::Real
    β::Real
end

function JointSurvivalModels.hazard(dist::LogLogistic, t::Real)
    α, β  = dist.α, dist.β
    return ((β / α) * (t / α) ^ (β - 1)) / (1 + (t / α) ^ β)
end

HazardBasedDistribution implements numeric integration to calculate the cumulative hazard and builds a distribution based it. To generate samples it solves an ODE and applies inverse transform sampling.

source

The functionalities implemented for HazardBasedDistribution.

JointSurvivalModels.supportMethod

This function represents the numeric support of the distribution and return a tuple (float_start::Float, float_stop::Float). The default value is: (1e-4, 10_000). Note that some distributions are not defined at 0 i.e. Weibull with shape parameter less than 1.

The pdf and hazard are 0 before float_start and the numeric integration to calculate the integral over the haazrd in cumulative_hazard starts at beginning. When sampling with rand an ODE is solved over the support.

Usage

You should adjust the support according to your data

JointSurvivalModels.support(dist::HazardBasedDistribution) = (-100, 1000)
source
Base.randMethod

Generate a random sample $t \sim \text{dist}$ via inverse transform sampling.

source
Distributions.ccdfMethod

Calculation of the ccdf / survival function at time $t$ based on the cumulative hazard

$S(t) = \exp(-H(t)) = \exp(-\int h(u) du)$

source
Distributions.logpdfMethod

Calculation of the log pdf function at time $t$ based on the cumulative hazard

$\log (f(t)) = \log(h(t)\cdot S(t)) = \log( h(t)) - H(t)$

source