How to show the basic formula of the Mean Residual Life Function in survival analysis? The basic quantity employed to describe time-to-event phenomena is the survival function, the probability of an individual surviving beyond time x (experiencing the event after time x). If $T$ is time of death, survival at time $x$ is is defined as
$S(x) = Pr (T > x)$.
Also, the survival function is the integral of the probability density function, $f(x)$, that is,
$$ S(x)=Pr[T>x]=\int^\infty_x f(t)\,dt$$
The mean residual life function is defined as
$$\operatorname{mrl}(x):=E[T-x|T>x]$$
Can anyone tell me how to get the formula below?
$$
\operatorname{mrl}(x) =\frac{\int^\infty_x (t-x)f(t)\,dt}{S(x)}=\frac{\int^\infty_x S(t)\,dt}{S(x)}
$$
 A: Presumably $S$ is the survival function of a nonnegative random variable denoting time of death of a life, or time to event of somethig that has finite mean or expected life time. Then, by Chebyshev-Markov's inequality
$$t S(t)=t P[T>t]\leq E[T\mathbb{1}(T>t)]\xrightarrow{t\rightarrow\infty}0$$
One approach to you problem is integration by parts:
$$S'(t)=-f(t)$$
$$\int^\infty_x(t-x)f(t)\,dt=\int^\infty_x(t-x)d(-S(t))=-S(t)(t-x)|^\infty_x+\int^\infty_xS(t)\,dt=\int^\infty_xS(t)\,dt$$

In general, if $T$ is a nonnegative random variable with  $E[T]<\infty$ one may use Fubini's theorem to estimate $E[T-x|T>x]$, $x\geq0$, as follows
$$E[T-x|T>x]=\frac{E[(T-x)\mathbb{1}(T>x)]}{P[T>x]}$$
The numerator is
\begin{align}
E[(T-x)\mathbb{1}(T>x)]&=\int_\Omega (T(\omega)-x)\mathbb{1}_{\{T>x\}}(\omega)\,P(d\omega)\\
&=\int_\Omega\Big(\int^\infty_0\mathbb{1}_{(x,T(\omega)]}(t)\,dt\Big)\,P(d\omega)\\
&=\int^\infty_0\Big(\int_\Omega\mathbb{1}_{(x,\infty)}(t)\mathbb{1}_{\{T>t\}}(\omega)\,P(d\omega)\Big)\,dt\\
&=\int^\infty_0\mathbb{1}_{(x,\infty)}(t)\Big(\int_\Omega\mathbb{1}_{\{T>t\}}(\omega)\,P(d\omega)\Big)\,dt\\
&=\int^\infty_x P[T>t]\,dt=\int^\infty_x S(t)\,dt
\end{align}
