Accelerated Failure-Time Models › Example
Machine Learning from ScratchAll chapters 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
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 , 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 and , and for the moment there are no covariates, so . One subject experiences an event at . Another subject is censored at . We compute each contribution separately and then multiply them.
For the event at , we first standardize:
The log-normal log density is
Evaluating each term,
The displayed intermediate terms are rounded; the final values use full precision. Adding the unrounded terms gives , so . This is the density contribution of the observed event.
For the censored subject at ,
The survival contribution is
The likelihood for these two subjects is therefore
Using the unrounded likelihood , the log-likelihood is . 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 . The time ratio is
so treatment multiplies the event time by about 1.22. Without treatment, the median is . With treatment, the median is . The entire distribution shifts by the same factor, not just the median.
For comparison, suppose we used a Weibull AFT model with the same and . At , the standardized value is still , but the survival probability is
which is lower than the log-normal survival probability at the same time; the log-normal survival at is . 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]Expand
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]Expand
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!