# Hazard function and survival analysis

I have a function $$\lambda(t)$$ which returns the instant probability of dying at a time $$t$$. I'd like to compute the function $$F(t)$$ which returns the probability of being dead at a certain time $$t$$.

Using some reliability theory, I have obtained the following relation: $$F(t) = 1-e^{- \int_{0}^{t} \lambda(u) \,du }$$

But when I do a numerical application I obtain strange results: Here is the shape of the function $$\lambda(t)$$:

It can be seen that just after 60 seconds, the probability of dying is above $$0.2$$. But then when I try to compute the probability of beeing dead at $$t=100s$$, I obtain: $$F(t) = 1-e^{- \int_{0}^{100} \lambda(u) \,du }=0.051$$ What am I doing wrong?

• You mistakenly interpret the values of $\lambda$ as probabilities. They are not: when multiplied by times, they will be the negative logarithms of probabilities. Notice that the area under this curve is approximately that of a triangle of width $60.5-60$ and height $0.22,$ roughly equal to $1/2\times 0.5\times 0.22=0.055.$ This is small, so its exponential is $e^{-0.055}\approx 1 - 0.055,$ very close to $1-0.051.$ As far as doing anything wrong, consider how strange this functional shape for $\lambda$ is! Death can occur essentially only between 60 and 60.5 seconds, never before or after.
– whuber
May 24, 2022 at 22:12
• (Continued) Consequently, I would like to suggest that the most productive way to pursue this problem would be to discuss how you obtained $\lambda,$ because it looks like your calculation is correct.
– whuber
May 24, 2022 at 22:13
• The plotted curve is the probability of death at any given time (as you said in this case, death can only occur around t=60sec and is very small everywhere else). What I probably did wrong is to call this probability function $\lambda$ which is the symbol used for the hazard function. How can I convert this probability function into a hazard one? Or simply, how can I obtain the probability of being dead at $t=100s$ for example?
– bfgt
May 24, 2022 at 23:38
• The probability that death occurs at an exact instant will be zero (consider a very small interval around that instant with small enough that the truncated distribution over that interval is close to uniform. Divide it into say 5 sub-intervals, and then focus on the one containing your specific point; divide in similar fashion again and again until the probability of being in the 'right' interval is below any chosen $\epsilon>0$). We can speak of the death-rate at an instant, but the probability is 0. May 24, 2022 at 23:48
• Your results might be consistent with a cure model, in which only a fraction of those at risk for an event ever experience it. See this page among others on this site. If that doesn't describe your situation, then there is some problem in how you obtained $\lambda (t)$.
– EdM
May 25, 2022 at 14:53

Given that your $$\lambda(t)$$ actually represents the instantaneous probability to die at time $$t$$ (the hazard), your function $$F(t)$$ computes the probability to die before a certain time $$t$$. In other words, $$F(t)$$ is the cumulative distribution function (CDF) of the time of death.

Following the discussion in the comments, your function represents the probability density function (pdf) $$f(t)$$ of time of death. From there you can compute the CDF as $$F(t) = \int_0^T f(u) du$$

with $$T$$ either infinity or the largest possible time.

### Some Background on Survival Models / Distributions

The following derivations are largely based on this material

Survival models can be based on the hazard rate $$\lambda(t)$$ (the instantaneous probability to die at time $$t$$) or on the distribution of times of death $$f(t)$$ (which is the pdf of the random variable time of death).

\begin{align} \text{Hazard function} && \lambda(t) &= \underset{\mathrm{d}t \rightarrow 0}{\lim} \frac{P(t \leq T \leq t + \mathrm{d}t | T\geq t)}{\mathrm{d}t} = \frac{f(t)}{S(t)} = - \frac{\mathrm{d}}{\mathrm{d}t}\ln \big[S(t)\big] \nonumber \\ \text{Cumulative Hazard} && M(t) &= \int_0^t \lambda(x) \mathrm{d}x \label{eq:cum_hazard} \\ \text{pdf} && f(t) &= \lambda(t) S(t) \nonumber \\ \text{cdf} && F(t) &= P(T < t) = \int_{0}^t f(x) \mathrm{d}x \nonumber \\ \text{Survival function} && S(t) &= 1- F(t) = \int_t^{\omega}f(x) \mathrm{d}x = e^{-M(t)} \label{eq:surv}\\ \text{Life Expectancy} && e(t) &= \frac{1}{S(t)} \int_t^\omega S(x) \mathrm{d}x \quad \text{with } e(0) = \int_0^\omega S(x) \mathrm{d}x \quad \text{since} \quad S(0) = 1 \label{eq:lexp} \end{align} where $$\omega$$ denotes the highest age.

If your plot is intended to be the probability density function for an event over time, $$f(t)$$ in the terminology of the answer from @Martin Georg Haas, then you technically have an improper distribution as it does not integrate to 1 over its support. Your numerical evaluation of the integral, consistent with $$F(\infty) = 0.051$$, agrees well with the area of a roughly corresponding isosceles triangle having height 0.2 and base 0.5.

If that's what you intend, you have a cure model in which about 95% of the cases never experience the event: $$S(\infty)= 1 - 0.051=0.949.$$ If that matches your data, you haven't done anything "wrong."

If that's not what you intend and all individuals eventually experience the event, then you have done something wrong and you need to scale your $$f(t)$$ by a factor of about 20 so that it integrates to $$F(\infty)=1$$.