Time-to-Event Data, Censoring, and Hazard Functions › Formula

Michael BrenndoerferOctober 25, 202612 min read
Machine Learning from ScratchAll chapters
Part 6 of 15Survival Analysis
Chapter 48Time-to-Event Data, Censoring, and Hazard Functions › Formula
Reading section 4 of 10 · Formula · 12 minSection 4 of 10 · 12 min

Section 4 of 10 · 12 min read

Time-to-Event Data, Censoring, and Hazard Functions › FormulaSection view · Sections in this chapter4 / 10 ↓
Reading tools Definitions, links & notes

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Notes & comments

In this section we build the notation from scratch. The destination is a single likelihood expression that correctly handles censored records, but the route matters. We first describe what a censored observation tells us, then introduce the three functions that describe a time-to-event distribution, then connect those functions through the hazard, and only then write the likelihood. Keeping that order in mind makes the formulas feel inevitable rather than arbitrary.

Event times, observation windows, and censoring

Let T>0T>0 be the true time until an event, measured from a defined origin t=0t=0. For a pump, it could be working lifetime measured from installation. We assume here that TT is finite almost surely and has an absolutely continuous distribution, with F(t)=Pr⁡(T≤t)F(t)=\Pr(T\le t) and density f(t)f(t). This excludes a point mass at zero and a permanently event-free fraction. Discrete event times and cure models require corresponding changes to the formulas.

We do not observe every subject's event time directly. Instead, each subject ii is followed over an observation window. Denote by Ci≥0C_i \ge 0 the time, measured from the same origin, at which observation of subject ii ends if the event has not yet occurred. CiC_i can come from an administrative cutoff ("the study ends in December"), from a dropout ("the patient moves to a different hospital"), or from a loss to follow-up. Whatever the mechanism, the data we record is the pair

Yi=min⁡(Ti,Ci),Δi=1{Ti≤Ci}.Y_i = \min(T_i, C_i), \qquad \Delta_i = \mathbf{1}\{T_i \le C_i\}.

where:

  • TiT_i: the true (latent) event time for subject ii, measured from the time origin t=0t = 0
  • CiC_i: the potential censoring time for subject ii, the time observation would end if no event had occurred
  • YiY_i: the observed time, the smaller of the event and censoring times, so Yi≤TiY_i \le T_i always
  • Δi\Delta_i: the event indicator, equal to one when the event is observed and zero when the record is censored
  • 1{⋅}\mathbf{1}\{\cdot\}: the indicator function, which equals one when its argument is true and zero otherwise

Here YiY_i is the observed time and Δi\Delta_i is the event indicator, equal to one if we saw the event and zero if the observation ended first. This single binary flag encodes a lot of information. Δi=1\Delta_i = 1 means we know the exact event time, and Δi=0\Delta_i = 0 means we only know Ti>YiT_i > Y_i. The pair (Yi,Δi)(Y_i,\Delta_i) is therefore the fundamental data unit of survival analysis. It is not a pair of unrelated numbers. It is a compressed statement about an event that either happened exactly at YiY_i or had not yet happened by YiY_i.

Right censoring means the event is later than a known bound. Left censoring means the event has already occurred but its exact time is unknown, so only an upper bound Ti≤yiT_i\le y_i is recorded. Interval censoring gives bounds such as ai<Ti≤bia_i<T_i\le b_i. Under an appropriate independent observation process, these contribute S(yi)S(y_i), F(yi)F(y_i), and F(bi)−F(ai)F(b_i)-F(a_i) respectively. They are different observation schemes, not interchangeable inputs to a right-censoring estimator. Ordinary missingness, with neither a known event time nor a valid bound, supplies less information than these records.

Delayed entry, or left truncation, is different from left censoring. A subject enters at age Li>0L_i>0 only if still event-free then: subjects with Ti≤LiT_i\le L_i are absent from the observed cohort. For example, a registry that enrolls only patients alive several months after diagnosis selects survivors. We observe their entry ages and subsequent follow-up, and must account for the selection. Merely starting otherwise fully observed subjects on different calendar dates is not left truncation when each is followed from its own relevant time origin.

Survival, density, and hazard functions

With the data unit fixed, we need a way to describe how durations are distributed. Three functions do the job, and each answers a different practical question. The first is the survival function

S(t)=P(T>t)=1−F(t),S(t) = P(T > t) = 1 - F(t),

This is the probability that the subject is event-free at time tt. We have S(0)=1S(0) = 1, and as t→∞t \to \infty, S(t)→0S(t) \to 0. The survival function is non-increasing. It is the natural first object in survival analysis because a censored record does not tell us when the event happened. It tells us that the event had not happened before the observation ended. The survival function is exactly the probability of that kind of statement.

The second is the probability density function f(t)=F′(t)=−S′(t)f(t) = F'(t) = -S'(t), which is the familiar object from Probability Distributions. The density is the derivative of the CDF, so integrating ff over an interval gives the probability that TT falls in that interval. It answers a different question from the survival function. Rather than "has the event happened yet?" it asks "how much probability mass sits near this particular time?" If every duration were fully observed, the density would be the most direct object to model.

The third is the hazard function

h(t)=lim⁡Δt→0+P(t≤T<t+Δt∣T≥t)Δt.h(t) = \lim_{\Delta t \to 0^{+}} \frac{P(t \le T < t + \Delta t \mid T \ge t)}{\Delta t}.

where:

  • h(t)h(t): the hazard function, the instantaneous event rate at time tt among those still at risk
  • TT: the event time for a generic subject
  • Δt\Delta t: a small positive time increment taken to zero in the limit
  • P(t≤T<t+Δt∣T≥t)P(t \le T < t + \Delta t \mid T \ge t): the conditional probability that the event occurs in the next increment, given survival to time tt
  • the denominator Δt\Delta t converts that probability into a rate per unit time

Read this out loud: the hazard is the instantaneous rate at which the event occurs in the next tiny slice of time, given that it has not occurred yet. The conditioning event {T≥t}\{T \ge t\} is what distinguishes the hazard from the density. The density measures the unconditional probability of the event near tt. The hazard measures the conditional intensity, so it captures how risky the next instant is for a subject who has survived up to tt. This conditional view is what makes censored data manageable. A censored subject contributes information about surviving up to the censoring time, and the hazard is the function that describes risk among exactly those survivors.

To express the hazard in terms of ff and SS, start from the definition of conditional probability. For small positive Δt\Delta t,

P(t≤T<t+Δt∣T≥t)=P(t≤T<t+Δt)P(T≥t).P(t \le T < t + \Delta t \mid T \ge t) = \frac{P(t \le T < t + \Delta t)}{P(T \ge t)}.

The numerator is approximately f(t) Δtf(t)\, \Delta t because the density integrates to the probability over a short interval, and the denominator is P(T≥t)=S(t)P(T \ge t) = S(t) for a continuous TT (equality holds because the point mass at tt is zero). Divide by Δt\Delta t and take the limit:

h(t)=f(t)S(t)=−S′(t)S(t)=−ddtlog⁡S(t).h(t) = \frac{f(t)}{S(t)} = \frac{-S'(t)}{S(t)} = -\frac{d}{dt} \log S(t).

These equalities hold where S(t)>0S(t)>0 and the required derivatives exist. The hazard is the negative log-derivative of the survival function. Here S′(t)S'(t) denotes the derivative of SS with respect to tt, and the final equality uses the chain rule for the logarithm, ddtlog⁡S(t)=S′(t)/S(t)\frac{d}{dt}\log S(t) = S'(t)/S(t).

Because −ddtlog⁡S(t)=h(t)-\frac{d}{dt} \log S(t) = h(t), integrating both sides from zero to tt gives

log⁡S(t)−log⁡S(0)=−∫0th(u) du.\log S(t) - \log S(0) = -\int_0^t h(u)\, du.

Since S(0)=1S(0) = 1, we have log⁡S(0)=0\log S(0) = 0 and

S(t)=exp⁡ ⁣(−∫0th(u) du).S(t) = \exp\!\left( -\int_0^t h(u)\, du \right).

Define the cumulative hazard H(t)=∫0th(u) duH(t) = \int_0^t h(u)\, du, so the identity becomes

S(t)=exp⁡(−H(t)).S(t) = \exp(-H(t)).

This identity connects survival probabilities and cumulative hazards for the continuous-time models considered here. It says that if we know the hazard at every time, we know the survival function by integration and exponentiation, and vice versa. It is also the reason hazard-based modeling is practical. We can write a model in terms of the hazard when event rates are the scientific target, and still evaluate the survival probability that the likelihood needs.

For a right-censored record, the event-time likelihood contribution is fθ(yi)f_\theta(y_i) for an observed event and Sθ(yi)S_\theta(y_i) for censoring, after removing factors from an independent censoring mechanism that do not depend on θ\theta. A density is not a point probability: for continuous times, Pr⁡(T=yi)=0\Pr(T=y_i)=0, whereas fθ(yi)f_\theta(y_i) measures density per unit time. Assuming independent subjects and the censoring conditions detailed next, the event-time likelihood, up to a parameter-free factor, is

L(θ)=∏i=1nfθ(yi)δiSθ(yi)1−δi.L(\theta) = \prod_{i=1}^n f_\theta(y_i)^{\delta_i} S_\theta(y_i)^{1 - \delta_i}.

Substituting fθ(y)=hθ(y)Sθ(y)f_\theta(y) = h_\theta(y) S_\theta(y),

L(θ)=∏i=1nhθ(yi)δiSθ(yi)=∏i=1nhθ(yi)δiexp⁡(−Hθ(yi)).L(\theta) = \prod_{i=1}^n h_\theta(y_i)^{\delta_i} S_\theta(y_i) = \prod_{i=1}^n h_\theta(y_i)^{\delta_i} \exp(-H_\theta(y_i)).

Taking logarithms turns the product into a sum:

ℓ(θ)=∑i=1n[δilog⁡hθ(yi)−Hθ(yi)].\ell(\theta) = \sum_{i=1}^n \Big[ \delta_i \log h_\theta(y_i) - H_\theta(y_i) \Big].

where:

  • ℓ(θ)\ell(\theta): the log-likelihood as a function of the parameter vector θ\theta
  • δilog⁡hθ(yi)\delta_i \log h_\theta(y_i): the event contribution, present only when δi=1\delta_i = 1
  • −Hθ(yi)-H_\theta(y_i): the negative cumulative hazard contribution, paid by every record whether event or censoring

This full log-likelihood is the starting point for the parametric right-censoring fits below; other estimators and observation schemes modify the objective. Every event contributes the log of the hazard at its event time. Every record contributes the negative cumulative hazard at its observed time, whether it was an event or a censoring. The formula is compact because the event indicator does exactly the bookkeeping we need. It switches on the density term for observed events and leaves only the survival term for censored records.

Censoring assumptions and delayed entry

The single likelihood in the previous section relies on one key factorization. If the event and censoring are independent random variables given covariates xix_i, that is,

Ti⊥ ⁣⊥Ci∣xi,T_i \perp\!\perp C_i \mid x_i,

where xix_i contains the conditioning covariates. For continuous censoring times, the joint density of (Yi,Δi)(Y_i,\Delta_i), with respect to time and the binary indicator, is

pθ(yi,δi∣xi)=[fT(yi∣xi)SC(yi∣xi)]δi[ST(yi∣xi)fC(yi∣xi)]1−δi.p_\theta(y_i,\delta_i\mid x_i)=\big[f_T(y_i\mid x_i)S_C(y_i\mid x_i)\big]^{\delta_i}\big[S_T(y_i\mid x_i)f_C(y_i\mid x_i)\big]^{1-\delta_i}.

Here fCf_C and SCS_C are the censoring density and survival function. If their parameters are distinct from θ\theta, their factor SC(yi∣xi)δifC(yi∣xi)1−δiS_C(y_i\mid x_i)^{\delta_i}f_C(y_i\mid x_i)^{1-\delta_i} can be removed when estimating θ\theta. It depends on the event indicator as well as on time. Fixed administrative censoring has atoms rather than a continuous density, but conditioning on a predetermined independent follow-up schedule gives the same event-density and event-survival contributions. The product likelihood also assumes subjects are independent. Estimation beyond the observed follow-up range remains dependent on the model and on available support.

If conditional independence fails, removing the censoring mechanism is generally unjustified. Selective loss of subjects with poor prognoses can conceal early events, but the size and direction of distortion depend on the joint process and the target. Inverse-probability-of-censoring weights require conditional independence given measured history, positive probabilities of remaining observed over the target horizon, and an adequate censoring model. They do not identify unobserved dependence automatically. Joint models or sensitivity analyses address different additional assumptions. A dropout is not automatically a competing event; a competing event must preclude the event of interest under the chosen definition.

For delayed entry, suppose a subject is included only if Ti>LiT_i>L_i, and is observed to Yi≥LiY_i\ge L_i. Under non-informative entry and censoring conditional on the relevant covariates, the event-time likelihood is conditioned on survival to entry. Its contribution is

fθ(yi)δiSθ(yi)1−δiSθ(Li),\frac{f_\theta(y_i)^{\delta_i} S_\theta(y_i)^{1 - \delta_i}}{S_\theta(L_i)},

where:

  • LiL_i: the delayed-entry (left-truncation) time at which subject ii first becomes observable, with Li>0L_i > 0
  • Sθ(Li)=Pr⁡(Ti>Li)S_\theta(L_i) = \Pr(T_i > L_i): the probability that a subject with parameters θ\theta survives to the entry time, the conditioning term
  • the numerator is the ordinary density or survival contribution evaluated at yiy_i from the original time origin; division by Sθ(Li)S_\theta(L_i) conditions it on survival to entry

The denominator conditions on the selection Ti>LiT_i>L_i. Non-parametric methods implement this by admitting subjects to risk sets only after entry. It matters even for an exponential model: S(yi)/S(Li)=exp⁡[−λ(yi−Li)]S(y_i)/S(L_i)=\exp[-\lambda(y_i-L_i)], giving exposure yi−Liy_i-L_i and, when D>0D>0 and total post-entry exposure is positive, rate estimate D/∑i(Yi−Li)D/\sum_i(Y_i-L_i), rather than D/∑iYiD/\sum_iY_i. With no events and positive exposure there is no positive interior rate estimate; zero exposure also needs a separate report. For the six durations below, entry at Li=0.5L_i=0.5 would change exposure from 2121 to 1818 and the rate from 4/214/21 to 4/184/18. Memorylessness preserves the exponential family for residual lifetime; it does not justify ignoring entry. Independence of entry and event time, possibly conditional on covariates, is an additional assumption and can fail in survivor cohorts.

Mathematical properties

Several properties follow directly from the definitions and are worth pinning down before we start estimating. They are not decoration. Each one will be used either to check an estimate or to simplify a likelihood.

  • The survival function S(t)S(t) is non-increasing, right-continuous, satisfies S(0)=1S(0) = 1, and tends to zero as t→∞t \to \infty. Accumulated failures can only reduce the probability of being event-free.
  • The hazard is non-negative where it is defined, with S(t)>0S(t)>0. At a finite endpoint where survival reaches zero, the ratio f(t)/S(t)f(t)/S(t) is not defined.
  • The cumulative hazard is non-decreasing with H(0)=0H(0)=0. As survival approaches zero, H=−log⁡SH=-\log S diverges; this can occur at a finite upper endpoint as well as in an infinite-time limit.
  • The three representations (F,S,h)(F, S, h) are equivalent. Knowing any one determines the other two via f=−S′f = -S' and h=f/Sh = f/S, or via S=exp⁡(−H)S = \exp(-H).
  • The expected event time satisfies E[T]=∫0∞S(t) dt\mathbb{E}[T] = \int_0^{\infty} S(t)\, dt, provided the integral is finite. This is the "survival-curve area" formula, and it is useful for comparing estimators.
  • For ordered discrete event times, define hs=Pr⁡(T=s∣T≥s)h_s=\Pr(T=s\mid T\ge s). Then S(t)=∏s≤t(1−hs)S(t)=\prod_{s\le t}(1-h_s). The log cumulative hazard −log⁡S(t)=∑s≤t−log⁡(1−hs)-\log S(t)=\sum_{s\le t}-\log(1-h_s) differs from the sum of discrete hazards ∑s≤ths\sum_{s\le t}h_s; one cannot substitute the latter into the continuous-time exponential identity exactly.
  • If a covariate xx acts on the hazard as h(t∣x)=h0(t)eβxh(t \mid x) = h_0(t) e^{\beta x}, where h0(t)h_0(t) is the baseline hazard (the hazard when x=0x = 0) and β\beta is a regression coefficient, then β\beta is the log hazard ratio and S(t∣x)=S0(t)eβxS(t \mid x) = S_0(t)^{e^{\beta x}}. This is the proportional hazards structure we will develop in Cox proportional hazards.

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy