---
title: "Parametric Survival Models"
format:
html: default
revealjs:
output-file: parametric-survival-models-slides.html
pdf:
output-file: parametric-survival-models-handout.pdf
docx:
output-file: parametric-survival-models-handout.docx
---
{{< include shared-config.qmd >}}
# Parametric Survival Models
## Exponential Distribution
The exponential distribution is the baseline parametric model in survival analysis.
It assumes a constant hazard rate $\lambda > 0$ over time.
This constant hazard implies that the event probability in any short interval depends only on the interval duration and not on elapsed time (the memoryless property).
$$
\ba
\pdf(t) &\eqdef \lambda \ef{-\lambda t} && \text{(probability density function definition for $t \ge 0$)} \\
\logf{\pdf(t)} &= \logf{\lambda} - \lambda t && \text{(taking natural logarithm of density)} \\
\cdf(t) &\eqdef \int_{0}^{t} \pdf(u) du && \text{(cumulative distribution function definition)} \\
&= \int_{0}^{t} \lambda \ef{-\lambda u} du && \text{(substituting probability density function)} \\
&= \left[ -\ef{-\lambda u} \right]_{0}^{t} && \text{(evaluating antiderivative)} \\
&= 1 - \ef{-\lambda t} && \text{(evaluating limits of integration)} \\
\surv(t) &\eqdef 1 - \cdf(t) && \text{(survival function definition)} \\
&= 1 - \left(1 - \ef{-\lambda t}\right) && \text{(substituting cumulative distribution function)} \\
&= \ef{-\lambda t} && \text{(simplifying terms)} \\
\cuhaz(t) &\eqdef -\logf{\surv(t)} && \text{(cumulative hazard function definition)} \\
&= -\logf{\ef{-\lambda t}} && \text{(substituting survival function)} \\
&= \lambda t && \text{(simplifying logarithm of exponential)} \\
\haz(t) &\eqdef \deriv{t} \cuhaz(t) && \text{(hazard function definition as derivative of cumulative hazard)} \\
&= \deriv{t} (\lambda t) && \text{(substituting cumulative hazard)} \\
&= \lambda && \text{(differentiating linear term)} \\
\E{T} &\eqdef \int_{0}^{\infty} \surv(t) dt && \text{(expectation formula for non-negative continuous random variable)} \\
&= \int_{0}^{\infty} \ef{-\lambda t} dt && \text{(substituting survival function)} \\
&= \left[ -\frac{1}{\lambda} \ef{-\lambda t} \right]_{0}^{\infty} && \text{(evaluating antiderivative)} \\
&= \lambda^{-1} && \text{(evaluating limits of integration)}
\ea
$$
## Weibull Distribution
The Weibull distribution generalizes the exponential distribution by introducing a shape parameter $p > 0$ alongside the scale parameter $\lambda > 0$ [@kalbfleisch2011statistical].
This flexibility allows the hazard rate to change monotonically over time, accommodating situations where risk increases or decreases as time elapses.
Using the parameterization of @kalbfleisch2011statistical:
$$
\ba
\pdf(t) &\eqdef \lambda p (\lambda t)^{p-1} \ef{-(\lambda t)^p} && \text{(probability density function for $t \ge 0$)} \\
\cdf(t) &\eqdef \int_{0}^{t} \pdf(u) du && \text{(cumulative distribution function definition)} \\
&= \int_{0}^{t} \lambda p (\lambda u)^{p-1} \ef{-(\lambda u)^p} du && \text{(substituting density function)} \\
&= \left[ -\ef{-(\lambda u)^p} \right]_{0}^{t} && \text{(evaluating antiderivative via substitution $w = (\lambda u)^p$)} \\
&= 1 - \ef{-(\lambda t)^p} && \text{(evaluating limits of integration)} \\
\surv(t) &\eqdef 1 - \cdf(t) && \text{(survival function definition)} \\
&= 1 - \left(1 - \ef{-(\lambda t)^p}\right) && \text{(substituting cumulative distribution function)} \\
&= \ef{-(\lambda t)^p} && \text{(simplifying terms)} \\
\cuhaz(t) &\eqdef -\logf{\surv(t)} && \text{(cumulative hazard function definition)} \\
&= -\logf{\ef{-(\lambda t)^p}} && \text{(substituting survival function)} \\
&= (\lambda t)^p && \text{(simplifying logarithm of exponential)} \\
\logf{\cuhaz(t)} &= \logf{(\lambda t)^p} && \text{(taking natural logarithm of cumulative hazard)} \\
&= p \logf{\lambda t} && \text{(applying exponent rule for logarithms)} \\
&= p \logf{\lambda} + p \logf{t} && \text{(applying product rule for logarithms)} \\
\haz(t) &\eqdef \deriv{t} \cuhaz(t) && \text{(hazard function definition)} \\
&= \deriv{t} \left( (\lambda t)^p \right) && \text{(substituting cumulative hazard)} \\
&= p (\lambda t)^{p-1} \cdot \lambda && \text{(applying power and chain rules of differentiation)} \\
&= \lambda p (\lambda t)^{p-1} && \text{(rearranging factors)} \\
\E{T} &\eqdef \int_{0}^{\infty} \surv(t) dt && \text{(expectation formula for non-negative random variable)} \\
&= \int_{0}^{\infty} \ef{-(\lambda t)^p} dt && \text{(substituting survival function)} \\
&= \frac{1}{\lambda p} \int_{0}^{\infty} u^{\frac{1}{p}-1} \ef{-u} du && \text{(substituting $u = (\lambda t)^p \implies t = \lambda^{-1} u^{1/p}$)} \\
&= \lambda^{-1} \cdot \Gamma\left(1 + \frac{1}{p}\right) && \text{(applying definition of Gamma function $\Gamma(z)$)}
\ea
$$
::: callout-note
Recall from calculus:
- $\Gamma(t) \eqdef \int_{u=0}^{\infty}u^{t-1}\ef{-u}du$
- $\Gamma(t) = (t-1)!$ for integers $t \in \mathbb Z$
- It is implemented by the `gamma()` function in R.
```{r, echo = FALSE}
library(ggplot2)
ggplot() +
geom_function(fun = gamma) +
geom_point(aes(x = 1:5, y = gamma(1:5))) +
xlim(1, 5) +
xlab("t") +
ylab(expression(Gamma(t))) +
theme_bw() +
theme(axis.title.y = element_text(angle = 0)) +
expand_limits(y = 0)
```
:::
Here are some Weibull density functions, with $\lambda = 1$ and $p$
varying:
```{r}
#| fig-cap: "Density functions for Weibull distribution"
library(ggplot2)
lambda <- 1
ggplot() +
geom_function(
aes(col = "0.25"),
fun = \(x) dweibull(x, shape = 0.25, scale = 1 / lambda)
) +
geom_function(
aes(col = "0.5"),
fun = \(x) dweibull(x, shape = 0.5, scale = 1 / lambda)
) +
geom_function(
aes(col = "1"),
fun = \(x) dweibull(x, shape = 1, scale = 1 / lambda)
) +
geom_function(
aes(col = "1.5"),
fun = \(x) dweibull(x, shape = 1.5, scale = 1 / lambda)
) +
geom_function(
aes(col = "2"),
fun = \(x) dweibull(x, shape = 2, scale = 1 / lambda)
) +
geom_function(
aes(col = "5"),
fun = \(x) dweibull(x, shape = 5, scale = 1 / lambda)
) +
theme_bw() +
xlim(0, 2.5) +
ylab("f(t)") +
theme(axis.title.y = element_text(angle = 0)) +
theme(legend.position = "bottom") +
guides(
col =
guide_legend(
title = "p",
label.theme = element_text(size = 12)
)
)
```
### Properties of Weibull hazard functions
{{< slidebreak >}}
:::{#thm-weibull-props}
#### Properties of Weibull hazard functions
If $T$ has a Weibull distribution, then:
- When $p=1$, the Weibull distribution simplifies to the exponential distribution.
- When $p > 1$, the hazard is strictly increasing: $\haz'(t) > 0$.
- When $p < 1$, the hazard is strictly decreasing: $\haz'(t) < 0$.
- $\log{\cuhaz(t)}$ is a straight line relative to $\log{t}$:
$\log{\cuhaz(t)} = p \log{\lambda} + p \log{t}$.
:::
::: proof
We prove each property of the Weibull hazard function $\haz(t) = \lambda p (\lambda t)^{p-1}$:
1. **Simplification to Exponential distribution when $p=1$**:
Setting $p=1$ in the Weibull hazard function yields:
$$
\ba
\haz(t) &= \lambda (1) (\lambda t)^{1-1} && \text{(substituting $p=1$ into Weibull hazard formula)} \\
&= \lambda \cdot 1 \cdot (\lambda t)^0 && \text{(simplifying exponent $1-1 = 0$)} \\
&= \lambda && \text{(since $(\lambda t)^0 = 1$ for $t > 0$)}
\ea
$$
This constant value is the hazard function of the exponential distribution with parameter $\lambda$.
2. **Increasing hazard when $p > 1$**:
Differentiating $\haz(t) = \lambda^p p t^{p-1}$ with respect to $t$ gives:
$$
\ba
\haz'(t) &\eqdef \deriv{t} \left( \lambda^p p t^{p-1} \right) && \text{(definition of hazard derivative)} \\
&= \lambda^p p (p-1) t^{p-2} && \text{(applying power rule of differentiation)}
\ea
$$
Since $\lambda > 0$, $p > 0$, and $t > 0$, the sign of $\haz'(t)$ depends entirely on the factor $(p-1)$.
When $p > 1$, $(p-1) > 0$, so $\haz'(t) > 0$ for all $t > 0$, meaning the hazard function is strictly increasing over time.
3. **Decreasing hazard when $p < 1$**:
Using the derivative $\haz'(t) = \lambda^p p (p-1) t^{p-2}$:
When $p < 1$, $(p-1) < 0$, so $\haz'(t) < 0$ for all $t > 0$, meaning the hazard function is strictly decreasing over time.
4. **Linear relationship between $\log \cuhaz(t)$ and $\log t$**:
Taking the natural logarithm of the cumulative hazard function $\cuhaz(t) = (\lambda t)^p$:
$$
\ba
\logf{\cuhaz(t)} &\eqdef \logf{(\lambda t)^p} && \text{(substituting Weibull cumulative hazard)} \\
&= p \logf{\lambda t} && \text{(applying logarithm exponent rule $\log(a^b) = b \log a$)} \\
&= p \logf{\lambda} + p \logf{t} && \text{(applying logarithm product rule $\log(ab) = \log a + \log b$)}
\ea
$$
Defining $y \eqdef \logf{\cuhaz(t)}$ and $x \eqdef \logf{t}$, this equation takes the linear form $y = a + b x$ with intercept $a = p \logf{\lambda}$ and slope $b = p$.
:::
{{< slidebreak >}}
:::{#exm-weibull-props}
#### Evaluating Weibull hazard shapes under different shape parameters
Consider a clinical trial evaluating time to relapse in months following cancer treatment, modeled using a Weibull distribution with scale parameter $\lambda = 0.1$.
We evaluate the hazard rate $\haz(t)$ at months $t = 1, 6, 12$ under three distinct shape parameters:
1. **Decreasing hazard ($p = 0.5$)**:
The hazard rate formula gives:
$$
\haz(t) = (0.1)(0.5)(0.1 t)^{-0.5} = \frac{0.05}{\sqrt{0.1 t}}
$$
- At $t = 1$ month: $\haz(1) = \frac{0.05}{\sqrt{0.1}} \approx 0.1581$ events per month.
- At $t = 6$ months: $\haz(6) = \frac{0.05}{\sqrt{0.6}} \approx 0.0645$ events per month.
- At $t = 12$ months: $\haz(12) = \frac{0.05}{\sqrt{1.2}} \approx 0.0456$ events per month.
The risk of relapse is highest immediately following treatment and declines over time.
2. **Constant hazard ($p = 1.0$)**:
The hazard rate formula reduces to $\haz(t) = \lambda = 0.1000$ events per month for all $t$.
The risk of relapse remains constant regardless of time elapsed.
3. **Increasing hazard ($p = 2.0$)**:
The hazard rate formula gives:
$$
\haz(t) = (0.1)(2.0)(0.1 t)^{1.0} = 0.02 t
$$
- At $t = 1$ month: $\haz(1) = 0.02(1) = 0.0200$ events per month.
- At $t = 6$ months: $\haz(6) = 0.02(6) = 0.1200$ events per month.
- At $t = 12$ months: $\haz(12) = 0.02(12) = 0.2400$ events per month.
The risk of relapse increases linearly over time.
:::
{{< slidebreak >}}
:::{#exr-weibull}
Verify the calculations in @exm-weibull-props and explain how the shape parameter $p$ affects cumulative hazard curves.
:::
{{< slidebreak >}}
::: notes
The Weibull distribution provides more flexibility than the exponential.
@fig-exm-weibull-hazards shows some Weibull hazard functions,
with $\lambda = 1$ and $p$ varying:
:::
```{r}
#| label: fig-exm-weibull-hazards
#| fig-cap: "Hazard functions for Weibull distribution"
library(ggplot2)
library(eha)
lambda <- 1
ggplot() +
geom_function(
aes(col = "0.25"),
fun = \(x) hweibull(x, shape = 0.25, scale = 1 / lambda)
) +
geom_function(
aes(col = "0.5"),
fun = \(x) hweibull(x, shape = 0.5, scale = 1 / lambda)
) +
geom_function(
aes(col = "1"),
fun = \(x) hweibull(x, shape = 1, scale = 1 / lambda)
) +
geom_function(
aes(col = "1.5"),
fun = \(x) hweibull(x, shape = 1.5, scale = 1 / lambda)
) +
geom_function(
aes(col = "2"),
fun = \(x) hweibull(x, shape = 2, scale = 1 / lambda)
) +
theme_bw() +
xlim(0, 2.5) +
ylab(expr(lambda)) +
theme(axis.title.y = element_text(angle = 0)) +
theme(legend.position = "bottom") +
guides(
col =
guide_legend(
title = "p",
label.theme = element_text(size = 12)
)
)
```
---
```{r}
#| label: fig-surv-weibull
#| fig-cap: "Survival functions for Weibull distribution"
library(ggplot2)
lambda <- 1
ggplot() +
geom_function(
aes(col = "0.25"),
fun = pweibull,
args = list(shape = 0.25, scale = 1 / lambda, lower.tail = FALSE)
) +
geom_function(
aes(col = "0.5"),
fun = pweibull,
args = list(shape = 0.5, scale = 1 / lambda, lower.tail = FALSE)
) +
geom_function(
aes(col = "1"),
fun = pweibull,
args = list(shape = 1, scale = 1 / lambda, lower.tail = FALSE)
) +
geom_function(
aes(col = "1.5"),
fun = pweibull,
args = list(shape = 1.5, scale = 1 / lambda, lower.tail = FALSE)
) +
geom_function(
aes(col = "2"),
fun = pweibull,
args = list(shape = 2, scale = 1 / lambda, lower.tail = FALSE)
) +
theme_bw() +
xlim(0, 2.5) +
ylab("S(t)") +
theme(axis.title.y = element_text(angle = 0)) +
theme(legend.position = "bottom") +
guides(
col =
guide_legend(
title = "p",
label.theme = element_text(size = 12)
)
)
```
## Exponential Regression
For each subject $i$, define a linear predictor $\eta(\vx) \eqdef \beta_0 + (\beta_1 x_1 + \dots + \beta_p x_p) = \vx \cdot \vb$.
Exponential regression models the hazard rate using a log link function:
$$
\ba
\haz(t \mid \vx) &\eqdef \expf{\eta(\vx)} && \text{(exponential regression hazard specification)} \\
\haz_0(t) &\eqdef \haz(t \mid \vzero) && \text{(baseline hazard rate definition at $\vx = \vzero$)} \\
&= \expf{\eta(\vzero)} && \text{(substituting $\vx = \vzero$ into hazard function)} \\
&= \expf{\beta_0 + (\beta_1 \cdot 0 + \dots + \beta_p \cdot 0)} && \text{(evaluating linear predictor at zero vector)} \\
&= \expf{\beta_0} && \text{(simplifying exponent)}
\ea
$$
When there are no additional predictors ($\vx = \vzero$), the baseline hazard is constant: $\lambda = \expf{\beta_0}$.
This model uses a log link as in a generalized linear model for Poisson or rate outcomes.
Because the hazard rate does not depend on time $t$, the hazard ratio comparing two covariate vectors $\vx$ and $\vxs$ is constant over time:
$$
\ba
\hr(t \mid \vx : \vxs) &\eqdef \frac{\haz(t \mid \vx)}{\haz(t \mid \vxs)} && \text{(hazard ratio definition)} \\
&= \frac{\expf{\eta(\vx)}}{\expf{\eta(\vxs)}} && \text{(substituting exponential regression hazard rates)} \\
&= \expf{\eta(\vx) - \eta(\vxs)} && \text{(applying quotient rule for exponentials)} \\
&= \expf{(\vx - \vxs) \cdot \vb} && \text{(expressing difference in linear predictors)}
\ea
$$
Thus, exponential regression models possess proportional hazards trivially.
## Accelerated Failure Time
In a proportional hazards (PH) model, covariates act multiplicatively on the baseline hazard function:
$$
\ba
\haz(t \mid \vx) &\eqdef \haz_0(t) \cdot \hazfactor(\vx) && \text{(proportional hazards hazard rate definition)} \\
\cuhaz(t \mid \vx) &\eqdef \int_{0}^{t} \haz(u \mid \vx) du && \text{(cumulative hazard function definition)} \\
&= \int_{0}^{t} \haz_0(u) \cdot \hazfactor(\vx) du && \text{(substituting proportional hazard rate)} \\
&= \hazfactor(\vx) \cdot \cuhaz_0(t) && \text{(factoring constant hazard multiplier out of integral)} \\
\surv(t \mid \vx) &\eqdef \expf{-\cuhaz(t \mid \vx)} && \text{(survival function in terms of cumulative hazard)} \\
&= \expf{-\hazfactor(\vx) \cdot \cuhaz_0(t)} && \text{(substituting cumulative hazard)} \\
&= \left[ \expf{-\cuhaz_0(t)} \right]^{\hazfactor(\vx)} && \text{(applying exponent laws)} \\
&= \left[ \surv_0(t) \right]^{\hazfactor(\vx)} && \text{(substituting baseline survival function $\surv_0(t)$)}
\ea
$$
An alternative modeling framework is the **Accelerated Failure Time (AFT)** model.
Rather than multiplying the hazard rate, covariates accelerate or decelerate the progression of time itself:
$$
\surv(t \mid \vx) \eqdef \surv_0\left( t \cdot \hazfactor(\vx) \right)
$$
where $\hazfactor(\vx) \eqdef \expf{\eta(\vx)}$, $\eta(\vx) \eqdef \beta_1 x_1 + \dots + \beta_p x_p$, and $\surv_0(t) \eqdef \P(T \ge t \mid \vx = \vzero)$ is the baseline survival function.
We derive the expected survival time under the AFT model using change-of-variables integration:
$$
\ba
\E{T \mid \vx} &\eqdef \int_{0}^{\infty} \surv(t \mid \vx) dt && \text{(expectation formula for non-negative random variable)} \\
&= \int_{0}^{\infty} \surv_0\left( t \cdot \hazfactor(\vx) \right) dt && \text{(substituting AFT survival function)} \\
&= \int_{0}^{\infty} \surv_0(u) \cdot \frac{du}{\hazfactor(\vx)} && \text{(substituting $u = t \cdot \hazfactor(\vx) \implies dt = \frac{du}{\hazfactor(\vx)}$)} \\
&= \hazfactor(\vx)^{-1} \cdot \int_{0}^{\infty} \surv_0(u) du && \text{(factoring constant $\hazfactor(\vx)^{-1}$ out of integral)} \\
&= \hazfactor(\vx)^{-1} \cdot \E{T \mid \vx = \vzero} && \text{(substituting baseline expectation formula)}
\ea
$$
Thus, the mean survival time for a subject with covariates $\vx$ equals the baseline mean survival time divided by the acceleration factor $\hazfactor(\vx) = \expf{\eta(\vx)}$.
We also derive the cumulative hazard and hazard rate functions under the AFT formulation:
$$
\ba
\cuhaz(t \mid \vx) &\eqdef -\logf{\surv(t \mid \vx)} && \text{(cumulative hazard function definition)} \\
&= -\logf{\surv_0\left( t \cdot \hazfactor(\vx) \right)} && \text{(substituting AFT survival function)} \\
&= \cuhaz_0\left( t \cdot \hazfactor(\vx) \right) && \text{(substituting baseline cumulative hazard)} \\
\haz(t \mid \vx) &\eqdef \deriv{t} \cuhaz(t \mid \vx) && \text{(hazard function definition)} \\
&= \deriv{t} \left( \cuhaz_0\left( t \cdot \hazfactor(\vx) \right) \right) && \text{(substituting AFT cumulative hazard)} \\
&= \cuhaz_0'\left( t \cdot \hazfactor(\vx) \right) \cdot \deriv{t} \left( t \cdot \hazfactor(\vx) \right) && \text{(applying chain rule of differentiation)} \\
&= \haz_0\left( t \cdot \hazfactor(\vx) \right) \cdot \hazfactor(\vx) && \text{(since $\cuhaz_0'(u) = \haz_0(u)$)} \\
&= \hazfactor(\vx) \cdot \haz_0\left( t \cdot \hazfactor(\vx) \right) && \text{(rearranging factors)}
\ea
$$
### Relationship between PH and AFT models
If the baseline distribution is exponential with parameter $\lambda$, substituting $\surv_0(t) = \expf{-\lambda t}$ into the AFT model yields:
$$
\ba
\surv(t \mid \vx) &= \expf{-\lambda \cdot t \cdot \hazfactor(\vx)} && \text{(substituting exponential baseline into AFT formula)} \\
&= \left[ \expf{-\lambda t} \right]^{\hazfactor(\vx)} && \text{(applying exponent laws)} \\
&= \left[ \surv_0(t) \right]^{\hazfactor(\vx)} && \text{(substituting exponential baseline survival function)}
\ea
$$
This derivation demonstrates that the exponential AFT model is mathematically identical to the exponential PH model.
For a Weibull baseline distribution with scale $\lambda$ and shape $p$, the hazard and survival functions are $\haz(t) = \lambda p (\lambda t)^{p-1}$ and $\surv(t) = \expf{-(\lambda t)^p}$.
Specifying a proportional hazards model with subject-specific multiplier $\theta_i \eqdef \expf{\eta_i}$ gives hazard rate $\haz(t) = \lambda p (\lambda t)^{p-1} \theta_i$.
Defining an adjusted scale parameter $\lambda^* \eqdef \lambda \theta_i^{1/p}$, the resulting survival function is:
$$
\ba
\surv^*(t) &\eqdef \expf{-(\lambda^* t)^p} && \text{(Weibull survival formula with scale parameter $\lambda^*$)} \\
&= \expf{-\left(\lambda \theta_i^{1/p} t\right)^p} && \text{(substituting $\lambda^* = \lambda \theta_i^{1/p}$)} \\
&= \expf{-(\lambda t)^p \cdot \theta_i} && \text{(simplifying exponent $\left(\theta_i^{1/p}\right)^p = \theta_i$)} \\
&= \left[ \expf{-(\lambda t)^p} \right]^{\theta_i} && \text{(applying exponent laws)} \\
&= \left[ \surv_0(t) \right]^{\theta_i} && \text{(substituting baseline Weibull survival function)} \\
&= \surv_0\left( t \cdot \theta_i^{1/p} \right) && \text{(expressing as AFT model with acceleration factor $\theta_i^{1/p}$)}
\ea
$$
This derivation proves that the Weibull model is simultaneously a proportional hazards model and an accelerated failure time model.
In terms of log survival time $Y \eqdef \log T$, the Weibull AFT model takes a log-linear regression form:
$$
\ba
Y &= \alpha - \sigma \eta + \sigma W && \text{(log-linear AFT regression formulation)} \\
\alpha &\eqdef -\logf{\lambda} && \text{(intercept parameter definition)} \\
\sigma &\eqdef \frac{1}{p} && \text{(scale parameter definition as inverse shape $p$)}
\ea
$$
where $W$ follows the standard Gumbel (extreme value) distribution.
The estimated AFT regression coefficients $\eb_{\text{AFT}}$ produced by R's `survreg()` function relate directly to the PH regression coefficients $\eb_{\text{PH}}$ produced by `coxph()` via the identity $\eb_{\text{AFT}} = -\sigma \eb_{\text{PH}}$.
The exponential and Weibull distributions are the only continuous distributions that are simultaneously proportional hazards models and accelerated failure time models.
Other parametric families commonly used for survival data
(log-logistic, log-normal, and generalized gamma)
are AFT families rather than PH families;
the log-logistic distribution is additionally a proportional-odds model.
## Dataset: Leukemia treatments
To illustrate semi-parametric and parametric survival models, we analyze remission survival times from a clinical trial of 42 pediatric leukemia patients [@kalbfleisch2011statistical].
Half of the patients received a new therapy (6-mercaptopurine, 6-MP) and half received a standard control treatment.
The variables in this dataset include:
- `survt`: Remission duration in weeks ($T$).
- `status`: Relapse status (`relapse` = 1 or `censored` = 0).
- `rx`: Treatment assignment (`new` vs `standard`).
- `sex`: Patient sex (`female` vs `male`).
- `surv`: Survival outcome object created with `Surv(time = survt, event = (status == "relapse"))`.
```{r}
#| eval: false
library(haven)
library(survival)
anderson <-
paste0(
"http://web1.sph.emory.edu/dkleinb/allDatasets",
"/surv2datasets/anderson.dta"
) |>
read_dta() |>
mutate(
status = status |>
case_match(
1 ~ "relapse",
0 ~ "censored"
),
sex = sex |>
case_match(
0 ~ "female",
1 ~ "male"
),
rx = rx |>
case_match(
0 ~ "new",
1 ~ "standard"
),
surv = Surv(time = survt, event = (status == "relapse"))
)
print(anderson)
```
```{r}
#| include: false
#| label: anderson-load-local
library(haven)
library(survival)
anderson <-
fs::path_package(
"rme", "extdata/anderson.dta"
) |>
read_dta() |>
mutate(
status = status |>
case_match(
1 ~ "relapse",
0 ~ "censored"
),
sex = sex |>
case_match(
0 ~ "female",
1 ~ "male"
),
rx = rx |>
case_match(
0 ~ "new",
1 ~ "standard"
),
surv = Surv(time = survt, event = (status == "relapse"))
)
print(anderson)
```
### Cox semi-parametric model
We fit a Cox proportional hazards model comparing standard therapy to new therapy:
```{r}
anderson_cox0 <- coxph(
formula = surv ~ rx,
data = anderson
)
summary(anderson_cox0)
```
The estimated log hazard ratio $\eb_{\text{PH}}$ for standard treatment relative to new treatment is positive, indicating that standard therapy is associated with a higher hazard of relapse (shorter remission duration).
### Weibull parametric model
We next fit a parametric Weibull accelerated failure time model using `survreg()`:
```{r}
anderson_weib <- survreg(
formula = surv ~ rx,
data = anderson,
dist = "weibull"
)
summary(anderson_weib)
```
In `survreg()`, regression parameters are reported on the log-time scale ($Y = \log T = \alpha + \vb_{\text{AFT}} \vx + \sigma W$).
The estimated coefficient $\eb_{\text{AFT}}$ for standard treatment is negative, indicating a reduction in log survival time (faster progression to relapse).
The scale estimate $\es$ corresponds to $1 / p$, and satisfies $\eb_{\text{AFT}} = -\es \eb_{\text{PH}}$.
### Exponential parametric model
Setting the scale parameter to $\sigma = 1$ ($p = 1$) yields the exponential parametric model:
```{r}
anderson_exp <- survreg(
formula = surv ~ rx,
data = anderson,
dist = "exp"
)
summary(anderson_exp)
```
In the exponential model, $\eb_{\text{AFT}} = -\eb_{\text{PH}}$, so the AFT coefficient is equal in magnitude and opposite in sign to the Cox proportional hazards coefficient.
### Diagnostic: complementary log-log survival plot
To check whether a Weibull proportional hazards assumption is reasonable, we inspect the complementary log-log transformation of the Kaplan-Meier survival curves, $\log(-\log \esurv(t)) = p \log \lambda + p \log t$:
```{r}
#| fig-cap: "Complementary log-log survival curves by treatment group"
library(survminer)
survfit(
formula = surv ~ rx,
data = anderson
) |>
ggsurvplot(fun = "cloglog")
```
If the complementary log-log curves are approximately linear and parallel across treatment groups, then a Weibull proportional hazards model is appropriate.
# Combining left-truncation and interval-censoring
In observational studies and clinical trials, complex observation schemes can introduce both **left-truncation** (delayed entry) and **interval-censoring**.
Left-truncation occurs when subjects enter the risk set only after surviving past an entry time $L_{\text{entry}} > 0$.
Interval-censoring occurs when the exact event time $T_i$ is unknown, but is known to fall within an interval $(L_i, R_i]$.
Standard software tools in R make distinct trade-offs between these two observation mechanisms:
> `coxph` does left truncation but not left (or interval) censoring;
> `survreg` does interval censoring but not left truncation (or time dependent covariates).
>
> --- Terry Therneau,
> [R-help, August 31, 2015](https://stat.ethz.ch/pipermail/r-help/2015-August/431733.html)
In particular, `coxph()` constructs risk sets dynamically at each observed failure time $t_j$ using counting process format (`time1 = entry`, `time2 = exit`), enabling seamless handling of left-truncation.
However, because partial likelihood relies on ordered exact failure times, standard Cox models cannot easily accommodate interval-censored data.
Conversely, `survreg()` accommodates interval-censored outcomes via `Surv(time1 = L, time2 = R, type = "interval")` by maximizing the interval parametric likelihood $\P(L_i < T_i \le R_i) = \cdf_0(R_i) - \cdf_0(L_i)$.
However, standard `survreg()` assumes all subjects enter observation at time 0, and does not condition likelihood terms on surviving past a delayed entry time $L_{\text{entry}}$.
When a study contains both delayed entry and interval-censored event times,
specialized tooling is needed.
Of the packages below, only `flexsurv` handles both features together;
the other two are listed because they cover interval censoring well
and are the usual starting points, not because they solve the truncation half:
- `flexsurv`: Fits flexible parametric survival models and allows custom likelihood specifications that incorporate both left-truncation conditioning and interval-censored bounds.
- `icenReg`: Fits regression models for interval-censored data:
Cox proportional-hazards, proportional-odds, and accelerated failure time.
Semi-parametric and fully parametric forms are both available,
but the fully parametric option covers the AFT models only.
It does not itself provide left-truncation conditioning.
- `interval`: Fits nonparametric survival curves (NPMLE) for interval-censored data
and provides weighted logrank and Wilcoxon-type tests [@fay2010exact].
It is nonparametric throughout,
so it supports neither regression nor truncation.