Hazard Based Distributions
Abstract type describing a distribution based on the hazard function.
JointSurvivalModels.HazardBasedDistribution — TypeHazardBasedDistribution <: ContinuousUnivariateDistributionHazardBasedDistribution 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 / α) ^ β)
endHazardBasedDistribution 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.
The functionalities implemented for HazardBasedDistribution.
JointSurvivalModels.support — MethodThis 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)JointSurvivalModels.hazard — Methodrepresents $h(t)$ needs to be implemented for any struct that subtypes HazardBasedDistribution
JointSurvivalModels.cumulative_hazard — Methodcalculates $H(t) = \int_0^t h(u) \; du$ numerically with a Gauss-Konrad procedure.
Base.rand — MethodGenerate a random sample $t \sim \text{dist}$ via inverse transform sampling.
Distributions.ccdf — MethodCalculation of the ccdf / survival function at time $t$ based on the cumulative hazard
$S(t) = \exp(-H(t)) = \exp(-\int h(u) du)$
Distributions.logpdf — MethodCalculation 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)$
Distributions.pdf — MethodCalculation of the pdf function at time $t$ based on the log pdf.