Accelerated Failure-Time Models › Example

Michael BrenndoerferOctober 26, 20263 min read
Machine Learning from ScratchAll chapters
Part 6 of 15Survival Analysis
Chapter 51Accelerated Failure-Time Models › Example
Reading section 6 of 10 · Example · 3 minSection 6 of 10 · 3 min

Section 6 of 10 · 3 min read

Accelerated Failure-Time Models › ExampleSection view · Sections in this chapter6 / 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

The censored likelihood can look abstract until we evaluate it with actual numbers. The example below computes it by hand for two observations, one event and one censored, and then shows how adding a treatment covariate changes the picture. Working through the numbers rather than trusting the optimizer makes each piece of the formula visible: the standardized residual ww, the density contribution of an event, the survival contribution of a censored observation, and the time ratio of a covariate.

Suppose the log-normal AFT parameters are β0=1.0\beta_0=1.0 and σ=0.5\sigma=0.5, and for the moment there are no covariates, so μ=1.0\mu=1.0. One subject experiences an event at t=3t=3. Another subject is censored at t=2t=2. We compute each contribution separately and then multiply them.

For the event at t=3t=3, we first standardize:

w=log⁡3−1.00.5=1.0986−1.00.5=0.1972.w = \frac{\log 3-1.0}{0.5} = \frac{1.0986-1.0}{0.5} = 0.1972.

The log-normal log density is

log⁡fT(3)=−log⁡3−log⁡0.5−12log⁡(2π)−12(0.1972)2.\log f_T(3) = -\log 3-\log 0.5-\frac{1}{2}\log(2\pi)-\frac{1}{2}(0.1972)^2.

Evaluating each term,

−log⁡3=−1.0986,−log⁡0.5=0.6931,-\log 3=-1.0986,\qquad -\log 0.5=0.6931, −12log⁡(2π)=−0.9189,−12(0.1972)2=−0.0194.-\frac{1}{2}\log(2\pi)=-0.9189,\qquad -\frac{1}{2}(0.1972)^2=-0.0194.

The displayed intermediate terms are rounded; the final values use full precision. Adding the unrounded terms gives log⁡fT(3)≈−1.3439\log f_T(3)\approx -1.3439, so fT(3)≈0.2608f_T(3)\approx 0.2608. This is the density contribution of the observed event.

For the censored subject at t=2t=2,

w=log⁡2−1.00.5=0.6931−1.00.5=−0.6137.w = \frac{\log 2-1.0}{0.5} = \frac{0.6931-1.0}{0.5} = -0.6137.

The survival contribution is

ST(2)=1−Φ(−0.6137)=Φ(0.6137)≈0.7303.S_T(2) = 1-\Phi(-0.6137) = \Phi(0.6137) \approx 0.7303.

The likelihood for these two subjects is therefore

L=fT(3) ST(2)≈0.2608×0.7303≈0.1905.L = f_T(3)\,S_T(2) \approx 0.2608 \times 0.7303 \approx 0.1905.

Using the unrounded likelihood L≈0.19048934L\approx0.19048934, the log-likelihood is log⁡L≈−1.6582\log L\approx -1.6582. Notice the asymmetry in how censoring enters: the event contributes a density, while the censored subject contributes a probability of surviving past the censoring time.

Now add a binary treatment covariate with coefficient β1=0.2\beta_1=0.2. The time ratio is

exp⁡(0.2)=1.2214,\exp(0.2)=1.2214,

so treatment multiplies the event time by about 1.22. Without treatment, the median is exp⁡(1.0)=2.7183\exp(1.0)=2.7183. With treatment, the median is exp⁡(1.2)=3.3201\exp(1.2)=3.3201. The entire distribution shifts by the same factor, not just the median.

For comparison, suppose we used a Weibull AFT model with the same μ=1.0\mu=1.0 and σ=0.5\sigma=0.5. At t=3t=3, the standardized value is still w=0.1972w=0.1972, but the survival probability is

ST(3)=exp⁡(−e0.1972)=exp⁡(−1.2180)≈0.2958,S_T(3) = \exp(-e^{0.1972}) = \exp(-1.2180) \approx 0.2958,

which is lower than the log-normal survival probability at the same time; the log-normal survival at t=3t=3 is 1−Φ(0.1972)≈0.42181-\Phi(0.1972)\approx 0.4218. The likelihood contributions would differ accordingly. This is the practical meaning of a distributional assumption: it changes how much probability mass is assigned to events and censoring times, especially in the tails.

PythonIn [11]
CollapseExpand
mu_ex = 1.0
sigma_ex = 0.5
t_event = 3.0
t_censored = 2.0

w_event = (np.log(t_event) - mu_ex) / sigma_ex
w_censored = (np.log(t_censored) - mu_ex) / sigma_ex

log_density_event = (
    -np.log(t_event)
    - np.log(sigma_ex)
    - 0.5 * np.log(2 * np.pi)
    - 0.5 * w_event**2
)
log_survival_censored = stats.norm.logcdf(-w_censored)
likelihood_example = np.exp(log_density_event + log_survival_censored)
ConsoleOut [12]
CollapseExpand
Standardized event value: 0.1972
Standardized censoring value: -0.6137
Event density contribution: 0.2608
Censored survival contribution: 0.7303
Two-subject likelihood: 0.1905
Log-likelihood: -1.6582

The printed values reproduce the hand calculation: the standardized event value is about 0.20, the censored survival contribution is about 0.73, and the two-subject likelihood is about 0.19. Agreement between the printed numbers and the algebra above is the intended check; a mismatch would point to an error in the standardized residual, the density, or the survival contribution.

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