I am trying to formulate the computation between the Hazard function and probability density function.

Given an example: pdf_arr = [0.2, 0.2, 0.2, 0.2, 0.2].

My computations are not matching up from: PDF -> Hazard -> PDF.

So I am trying from to convert from PDF -> CDF -> Survival Function-> Cum Hazard -> Hazard -> PDF.

Following are the values I computed:
PDF to CDF gives me CDF: [0.2, 0.4, 0.6, 0.8, 1. ].
CDF to Survival gives me Survival: [1. , 0.8, 0.6, 0.4, 0.2].
Survival to Cumulative Hazard Func gives me [0, 0.223, 0.511, 0.916, 1.609].
Cumulative Hazard Func to Hazard gives me [0, 0.223, 0.287, 0.405, 0.693]).
Hazard to PDF gives me [0.2, 0.205, 0.213, 0.228, 0.277]


1 Answer 1


This question, which seems at first to be about coding, actually gets to an important statistical issue: the distinction between discrete-time and continuous-time survival models.

The example in this question starts with a probability mass function (not a continuous density function) having a mass of 0.2 at each of 5 points in time after time 0. For a discrete-time model like this, with $T$ representing the random variable for event time and potential event times indexed by $i$, the hazard at time $t$ is

$$ \lambda(t)= P(T=t|T \ge t),$$

with survival function

$$S(t) = P(T>t) = \prod_{i=1}^t \left(1-\lambda(i)\right). $$

See for example Section 3.1 of Tutz and Schmid, "Modeling Discrete Time-to-Event Data" (Springer, 2016).

Although you can sum those discrete hazards to get a cumulative hazard $H(t)$, in this discrete case

the relationship $S(t)= 􏰃 exp\left(-􏱜􏰘H(t)\right)$ for this definition no longer holds true. Some authors ... prefer to define the cumulative hazard for discrete lifetimes as

$$H(t) = \sum_{i\le t} \ln \left[1-\lambda(i) \right]$$

because the relationship for continuous lifetimes $S(t)= 􏰃 exp\left(-􏱜􏰘H(t)\right)$ will be preserved for discrete lifetimes.*

So if you are using software for continuous-time survival modeling that assumes $S(t)= 􏰃 exp\left(-􏱜􏰘H(t)\right)$, this discrepancy is expected.

*Klein and Moeschberger, "Survival Analysis: Techniques for Censored and Truncated Data," Second Edition (Springer, 2003) page 32, with the time variable represented here as $t$ and potential event times indexed by $i$.


Not the answer you're looking for? Browse other questions tagged or ask your own question.