In many estimation problems it is inconvenient or impossible to make complete measurements on all members of a random sample. For example, in medical follow-up studies to determine the distribution of survival times after an operation, contact with some individuals will be lost before their death, and others will die from causes it is desired to exclude from consideration. Similarly, observation of the life of a vacuum tube may be ended by breakage of the tube, or a need to use the test facilities for other purposes. In both examples, incomplete observations may also result from a need to get out a report within a reasonable time. (Kaplan and Meier 1958)
In nonparametric survival analysis, we do not assume that the failure time distributions are defined by a small number of parameters, such as the rate parameter in an exponential model for times to events or a Poisson model for the number of events. Whenever possible, it is good to incorporate existing knowledge into the estimation of unknown parameters, and the use of parametric models and Bayesian methods accomplishes this. When such knowledge is not available, nonparametric methods allow us to avoid making assumptions we cannot defend.
However, this flexibility comes at a price. For example, suppose we know that our time-to-event has an exponential distribution. If we use a nonparametric model anyway, then:
The nonparametric estimates of the survival, cumulative hazard, or hazard functions will be less precise than the estimates from an exponential model.
We might be unable to estimate mean or median survival times or other quantities that require extrapolation beyond the data used for estimation.
Parametric and nonparametric methods are at opposite ends of the bias-variance tradeoff. The assumptions of parametric models can induce bias, but they produce estimates with low variance when the assumptions are approximately correct. The flexibility of nonparametric models avoids bias, but they produce estimates with higher variance than an equivalent parametric method based on sound assumptions. Survival analysis has nonparametric estimators of the survival and cumulative hazard functions that can be used with relatively little loss of efficiency. Because of this combination of flexibility and efficiency, they are widely used in epidemiologic research.
6.1 Empirical cumulative distribution function
The cumulative distribution function (CDF) of a random variable \(X\) is the function \[F(x) = \Pr(X \leq x).\] For each value of \(x\), \(F(x)\) is a probability that we can estimate using methods for a binomial proportion. However, we can get a more complete picture of the distribution of \(X\) by linking the estimates for different \(x\) together to estimate the whole function \(F(x)\).
If \(x_1, \ldots, x_n\) are observations of a random variable \(X\), the empirical CDF is the function \[
\hat{F}_n(x) = \frac{1}{n} \sum_{i = 1}^n \indicator_{x_i \leq x}
\tag{6.1}\] where \(\indicator_{x_i \leq x} = 1\) if \(x_i \leq x\) is true and zero otherwise. For a fixed value of \(x\), \(\hat{F}_n(x)\) is just the proportion of the observations that are \(\leq x\). At each \(x\), the number of observations with \(X_i \leq x\) is a binomial(\(n\), \(F(x)\)) random variable with expected value \(n F(x)\) and variance \(n F(x) \big(1 - F(x)\big)\). Thus, \[
\E\bigl(\hat{F}_n(x)\bigr) = F(x)
\] and \[
\Var\bigl(\hat{F}_n(x)\bigr)
= \frac{1}{n} F(x) \big(1 - F(x)\big).
\tag{6.2}\] As \(n \rightarrow \infty\), we have \(\hat{F}_n(x) \rightarrow F(x)\) by the law of large numbers (LLN) and By the central limit theorem (CLT), \[
\frac{\sqrt{n}\big(\hat{F}_n(x) - F(x)\big)}{\sqrt{F(x) \big(1 - F(x)\big)}} \approxsim N(0, 1)
\tag{6.3}\] by the central limit theorem (CLT).1 Unlike a single proportion estimate \(\hat{p}\), the empirical CDF links all of these estimated probabilities together—like beads on a necklace—through the variable \(x\).
At any given \(x\), interval estimates for \(F(x)\) can be obtained using any of the methods we have discussed for probabilities, including the Wald, score (Wilson), likelihood ratio, exact (Clopper-Pearson), mid-p, or Jeffreys confidence intervals as well as Bayesian credible intervals. For example, \[
\hat{F}_n(x) \pm 1.96 \sqrt{\frac{1}{n} \hat{F}_n(x) \big(1 - \hat{F}_n(x)\big)}
\tag{6.4}\] is the 95% Wald confidence interval. To force this confidence interval to stay inside \((0, 1)\), we can use the delta method with a logit or log-log transformation. These are called pointwise confidence intervals because we have a separate confidence interval for \(F(x)\) at each \(x\).
6.2 Kaplan-Meier estimator
In data with right censoring and left truncation, we cannot calculate the empirical CDF directly. The Kaplan-Meier estimator(Kaplan and Meier 1958) uses conditional probabilities to estimate the survival function \(S(t) = 1 - F(t)\) for failure time data.2 The basic idea behind the Kaplan-Meier estimator is to solve the problems of right censoring and left truncation (delayed entry) by breaking analysis time into periods where no one enters or leaves the study. In each such interval \((t_a, t_b]\), we can estimate the conditional probability of surviving to time \(t_b\) given that you were at risk of disease at time \(t_a\).
If there are \(n\) individuals at risk throughout the interval $(t_a, t_b], then the number of events at time \(t_b\) can be treated like a binomial(\(n, p\)) random variable where \(p\) is the risk of the event in \((t_a, t_b]\). Our point estimate of this conditional probability is \[
\hat{p} = \frac{d}{n}
\] where \(d\) is the number of failures at time \(t_b\). Its variance is approximately \[
\Var(\hat{p}) = \frac{1}{n} \hat{p} (1 - \hat{p}).
\] Given that you were at risk of disease at time \(t_a\), \[
\hat{q} = 1 - \hat{p}
\] is the conditional probability of surviving past time \(t_b\).
6.2.1 At-risk process and risk sets
To estimate the risk in an interval \((t_a, t_b]\), it is critical to define who is at risk of failure at time \(t_a\). We assume that all times are defined relative to a time origin that can differ between individuals. The at-risk process for individual \(i\) is \[
Y_i(t) =
\begin{cases}
1 &\text{ if $i$ is at risk and under observation at time $t$},\\
0 &\text{ otherwise}.
\end{cases}
\] The at-risk process is assumed to be predictable (i.e., its value at \(t\) is determined just before time \(t\)), so \(Y_i(t) = 1\) even if \(i\) fails or is censored at time \(t\). Note that a person is only at risk if they are both at risk of failure and under observation. If person \(i\) is not under observation until an entry time \(\tentry_i > 0\), then \(Y_i(t) = 0\) when \(t \leq \tentry_i\).
The set of individuals under observation and at risk of failure at time \(t\) is called the risk set at time \(t\) and written \[
\mathcal{R}(t) = \{i : Y_i(t) = 1\}
\] The risk set \(\mathcal{R}(t)\) includes everyone under observation who fails at time \(t\), who is censored at time \(t\), or who survives past time \(t\).
6.2.2 Survival via multiplication of conditional probabilities
Let \(T\) denote the random failure time in the analysis time scale (i.e., with the origin as time zero), and suppose we have times \(0 < t_1 < t_2\). To have \(T > t_2\), we must also have \(T > t_1\), so \[
\begin{aligned}
\Pr\bigl(T > t_2\bigr)
&= \Pr\bigl(T > t_2 \text{ and } T > t_1\bigr) \\
&= \Pr\bigl(T > t_2 \,\big|\, T > t_1\bigr) \Pr\bigl(T > t_1\bigr).
\end{aligned}
\] In other words, the probability of survival in \((0, t_2]\) is the product of the survival probabilities in the intervals \((0, t_1]\) and \((t_1, t_2]\). If \(t_3 > t_2\), then \[
\begin{aligned}
\Pr\bigl(T > t_3\bigr)
&= \Pr\bigl(T > t_3 \,\big|\, T > t_2\bigr) \Pr\bigl(T > t_2\bigr) \\
&= \Pr\bigl(T > t_3 \,\big|\, T > t_2\bigr)
\Pr\bigl(T > t_2 \,\big|\, T > t_1\bigr) \Pr\bigl(T > t_1\bigr)
\end{aligned}
\] which is the product of the survival probabilities in the intervals \((0, t_1]\), \((t_1, t_2]\), and \((t_2, t_3]\). This logic extends to any number of intervals. If we have distinct times \(0 = t_0 < t_1 < \cdots < t_m\), then \[
\Pr(T > t_m)
= \prod_{i = 1}^{m} \Pr\big(T > t_i \,\big|\, T > t_{i - 1}\big).
\] This uses the multiplication rule for conditional probabilities, so it does not assume that failures in different intervals are independent. In single-failure data, an individual who fails in one interval cannot fail in a later interval, so failures in different intervals cannot be independent.
Let \(0 = t_0 < t_1 < t_2 < \ldots < t_m\) be the endpoints of intervals \((t_{i-1}, t_i]\) within which there are no entries or exits from the study. Let \(n_j = \sum_{i = 1}^n Y_i(t_j)\) be the number of people in the risk set \(\mathcal{R}(t_j)\) and let \(d_j \geq 0\) be the number of failures that occur at time \(t_j\). The estimated conditional probability \(q_j\) of surviving through the interval \((t_{j - 1}, t_j]\) given survival to \(t_{j - 1}\) is \[
\hat{q}_j = 1 - \frac{d_j}{n_j},
\] and the Kaplan-Meier estimator of \(S(t)\) is \[
\hat{S}(t)
= \prod_{j: t_j \leq t} \hat{q}_j
= \prod_{j: t_j \leq t} \bigg(1 - \frac{d_j}{n_j}\bigg).
\tag{6.5}\] This is the product of the conditional survival probabilities in \((t_{j - 1}, t_j]\) for all intervals such that \(t_j \leq t\). To survive to time \(t\), you need to survive through all intervals up to and including time \(t\). This makes it easier to calculate the survival function than to calculate cumulative incidence directly. The Kaplan-Meier estimator is a consistent and asymptotically normal estimator of the true survival function (Fleming and Harrington 2005; Aalen, Borgan, and Gjessing 2008). Figure 6.1 shows an example based on a right-censored sample of size 500 from a log-logistic distribution with shape \(\alpha = 1\) and rate \(\lambda = 2\).
## Fitting a log-logistic distribution# To sample a log-logistic random variable in R, you sample a logistic random# variable with location = -log(rate) and scale = 1 / shape.# The exponential of the logistic variable has a log-logistic distribution# with the correct rate and shape parameters.library(survival)# Log-logistic distribution and regression (rate = 2, shape = 3)llsample <-exp(rlogis(1000, location =-log(2), scale =1/3))llogdat <-data.frame(time = llsample, event =1)llogreg <-survreg(Surv(time, event) ~1, data = llogdat,dist ="loglogistic")exp(-coef(llogreg)) # point estimate of rateexp(-confint(llogreg)) # 95% confidence interval for rate1/ llogreg$scale # point estimate of shape# log-transformed 95% confidence interval for the shape parameterexp(-log(llogreg$scale) +c(-1, 1)*qnorm(.975) *sqrt(vcov(llogreg)["Log(scale)", "Log(scale)"]))# plot of true and estimated log-logistic hazard functionsllrate_est <-exp(-coef(llogreg))llshape_est <-1/ llogreg$scalellrate_true <-2llshape_true <-3h_llog <-function(time, rate, shape) {# returns last expression if there is no return() statement (rate * shape * (time * rate)^(shape -1) / (1+ (time* rate)^shape))}t <-seq(0, 4, by =0.01)plot(t, h_llog(t, llrate_true, llshape_true), type ="n",xlab ="Time", ylab ="Hazard (Log-logistic)")grid()lines(t, h_llog(t, llrate_est, llshape_est))lines(t, h_llog(t, llrate_true, llshape_true), lty ="dashed")legend("topright", lty =c("solid", "dashed"), bg ="white",legend =c("Estimated hazard function", "True hazard function"))
Figure 6.1: True log-logistic survival function and Kaplan-Meier estimate with complementary log-log 95% confidence limits.
6.2.3 Greenwood formula and confidence intervals
Calculating the variance of a product is difficult and tedious, but calculating the variance of a sum is easy. Taking logarithms in Equation 6.5, we get \[
\ln \hat{S}(t) = \sum_{j: t_j \leq t} \ln \hat{q}_j.
\] For each \(j\), the estimated variance of \(\hat{q}_j\) is \[
\Var(\hat{q}_j) = \frac{1}{n_j}\hat{q}_j \big(1 - \hat{q}_j\big).
\] Since \(\ln x\) has the derivative \(\frac{1}{x}\), \[
\Var(\ln \hat{q}_j)
\approx \frac{1}{\hat{q}_j^2} \Var\big(\hat{q}_j\big)
= \frac{d_j}{n_j(n_j - d_j)}.
\] by the delta method from Section 3.4.1.
The estimated survival probabilities in each time interval are conditionally independent, so \[
\Var\bigl(\ln \hat{S}(t)\bigr)
= \sum_{t_j \leq t} \Var(\ln \hat{q}_j)
= \sum_{t_j \leq t} \frac{d_j}{n_j(n_j - d_j)}.
\] by Equation 1.12. Since \(\hat{S}(t) = \exp\big(\ln \hat{S}(t)\big)\), we can use the delta method again to get an estimated variance for \(\hat{S}(t)\). The function \(\exp(x) = e^x\) is its own derivative, so we get \[
\Var\bigl(\hat{S}(t)\bigr)
= \hat{S}(t)^2 \Var\bigl(\ln \hat{S}(t)\bigr)
= \hat{S}(t)^2 \sum_{t_j \leq t} \frac{d_j}{n_j(n_j - d_j)}.
\tag{6.6}\] This is called the Greenwood formula(Greenwood 1926).3 It was developed originally for life tables and applied later to the Kaplan-Meier estimator.
For each \(t\), a pointwise Wald \(95\%\) confidence interval for \(S(t)\) is \[
\hat{S}(t) \pm 1.96 \sqrt{\Var\bigl(\hat{S}(t)\bigr)}.
\] This confidence interval can have a lower bound less than zero or an upper bound greater than one, outside the possible values of \(S(t)\). Better confidence intervals can be obtained using a complementary log-log transformation, which is \[
\ln\bigl(-\ln S(t)\bigr) = \ln H(t)
\] where \(H(t)\) is the cumulative hazard. The logit (log odds) transformation can also be used.
6.2.4 Cumulative incidence and cumulative hazard
The Kaplan-Meier estimator of the survival function can also be used to estimate the cumulative hazard function \(H(t) = -\ln S(t)\) and the cumulative incidence function \(F(t) = 1 - S(t)\), which is the CDF of the time-to-event distribution. The estimated cumulative hazard function is \[
\hat{H}_\text{KM}(t)
= -\ln \hat{S}(t),
\tag{6.7}\] which is defined whenever \(\hat{S}(t) > 0\). The estimated cumulative incidence function is \[
\hat{F}_\text{KM}(t)
= 1 - \hat{S}(t).
\] When there is no right censoring or left truncation (delayed entry), \(\hat{F}(t)\) equals the empirical CDF of the times to events as in Equation 6.1 and the Greenwood variance equals the corresponding variance in Equation 6.2. Confidence limits for \(F(t)\) or \(H(t)\) can be obtained from the corresponding confidence limits for \(S(t)\).
6.3 Nelson-Aalen estimator
The Kaplan-Meier estimator is based on estimating conditional survival probabilities in intervals within which there are no entries or exits. The Nelson-Aalen esimator uses the same time intervals, but it estimates an expected number of events in each interval (Nelson 1969, 1972; Altshuler 1970; Aalen 1978). It is based on the interpretation of the cumulative hazard \(H(t)\) as an expected number of events in \((0, t]\) if the event could be made repeatable, and it uses the fact that the expected number of events in different intervals can be added together by Equation 1.11. The at-risk process and risk sets are defined exactly as in Section 6.2.1.
6.3.1 Cumulative hazard via addition of expected values
As above, let \(0 = t_0 < t_1 < t_2 < \ldots < t_m\) be the endpoints of intervals \((t_{i-1}, t_i]\) within which there are no entries or exits from the study. Let \(n_j = \sum_{i = 1}^n Y_i(t_j)\) be the number of people in the risk set \(\mathcal{R}(t_j)\) and let \(d_j \geq 0\) be the number of failures that occur at time \(t_j\). The estimated expected number of events per individual under observation in this time interval is \[
\frac{1}{n_j} \sum_{i \in \mathcal{R}_j} \indicator_{\tevent_i \in (t_{j - 1}, t_j]}
= \frac{d_j}{n_j}.
\] Adding these up over all time intervals with endpoints at or before time \(t\), we get the Nelson-Aalen estimator \[
\hat{H}(t)
= \sum_{j: t_j \leq t} \frac{d_j}{n_j}.
\tag{6.8}\] The Nelson-Aalen estimator is an unbiased, consistent, and asymptotically normal estimator of the true cumulative hazard (Fleming and Harrington 2005; Aalen, Borgan, and Gjessing 2008). Figure 6.2 shows an example based on a right-censored sample of size 500 from a log-logistic distribution with shape \(\alpha = 1\) and rate \(\lambda = 2\).
The Fleming-Harrington correction for ties(Fleming and Harrington 1984) replaces each \(d_j / n_j\) in Equation 6.8 with \[
\frac{1}{n_j} + \frac{1}{n_j - 1} + \cdots + \frac{1}{n_j - (d_j - 1)}
> \frac{d_j}{n_j}.
\tag{6.9}\] The resulting estimator of the cumulative hazard is sometimes called the Fleming-Harrington estimator. It accounts for the fact that the \(d_j\) events did not really happen at the same time. They appear to be tied because the times were defined and measured with the limited precision possible in a real study. The example in Figure 6.2 uses this correction.
## Nelson-Aalen estimator# The Nelson-Aalen estimator is calculated using survival::survfit().# Use the argument "stype = 2" to get the survival function estimated from the# Nelson-Aalen estimate of the cumulative hazard.# Use the argument "ctype = 2" to get the Fleming-Harrington correction.library(survival)?survfit # get general help about survfit?survfit.formula # get help with the specific version we use below# right-censored sample from log-logistic dist with rate = 2 and shape = 1# Uses samples from logistic distribution with location = -log(rate) and# scale = 1 / shape.set.seed(42)llog_f <-exp(rlogis(500, location =-log(2), scale =1))llog_c <-exp(rlogis(500, location =-log(2), scale =2))t <-pmin(llog_f, llog_c)d <-ifelse(llog_c < llog_f, 0, 1)llogdat <-data.frame(time = t, delta = d)# Nelson-Aalen estimator with log-transformed confidence intervals# The log transformation of H is the log-log transformation of S, so we use# the argument conf.type = "log-log".llog_na <-survfit(Surv(time, delta) ~1, data = llogdat,conf.type ="log-log", stype =2, ctype =2)# point and interval estimates of the survival functionsummary(llog_na, times =1:15)# calculate point and interval estimates of the cumulative hazard functionnames(summary(llog_na, times =1:15))summary(llog_na, times =1:15)$cumhaz-log(summary(llog_na, times =1:15)$surv)-log(summary(llog_na, times =1:15)$lower)-log(summary(llog_na, times =1:15)$upper)
Code
NAcurve.R
## Nelson-Aalen cumulative hazard curvelibrary(survival)# right-censored sample from log-logistic dist with rate = 2 and shape = 1# Uses samples from logistic distribution with location = -log(rate) and# scale = 1 / shape.set.seed(42)llog_f <-exp(rlogis(500, location =-log(2), scale =1))llog_c <-exp(rlogis(500, location =-log(2), scale =2))t <-pmin(llog_f, llog_c)d <-ifelse(llog_c < llog_f, 0, 1)llogdat <-data.frame(time = t, delta = d)# Nelson-Aalen estimate of the survival function with FH correctionllog_na <-survfit(Surv(time, delta) ~1, data = llogdat,conf.type ="log-log", stype =2, ctype =2)# log-logistic cumulative hazard functionllog_cumhaz <-function(t, lambda, gamma) log(1+ (lambda * t)^gamma)# Nelson-Aalen curve and log-logistic cumulative hazard curvet <-seq(0, max(llogdat$time), .01)plot(llog_na, fun ="cumhaz", xlim =c(0, 20),xlab ="Time", ylab ="Cumulative hazard")grid()lines(t, llog_cumhaz(t, 2, 1), col ="darkgray")legend("bottomright", bg ="white", lty =c("solid", "dashed", "solid"),col =c("black", "black", "darkgray"),legend =c("Nelson-Aalen estimate", "95% confidence limits","True cumulative hazard function"))
Figure 6.2: True log-logistic cumulative hazard function and Nelson-Aalen estimate with log-transformed 95% confidence limits.
6.3.2 Variance and confidence intervals
Let \(D_j\) be the random number of events in the interval \((t_{j - 1}, t_j]\) whose observed value is \(d_j\). If an event is repeatable, the number of events per individual in any interval \((t_{j - 1}, t_j]\) has a Poisson distribution with mean \[
\Delta H_j
= H(t_j) - H(t_{j - 1}).
\] When an event cannot be repeated, this is true in an interval sufficiently small that \(\Delta H_j\) is much smaller than one (i.e., \(\Delta H_j \ll 1\)). Because our time intervals are defined to be small enough that no one leaves the study by having an event, \(\Delta H_j \ll 1\) in each interval where \(n_j\) is large.
Because we have \(n_j\) individuals at risk in this interval, \[
D_j \sim \text{Poisson}(n_j \Delta H_j).
\] because \(D_j\) is the sum of \(n_j\) Poisson(\(\Delta H_j\)) random variables. Because \(\Var(D_j) = n_j \Delta H_j\), \[
\Var\biggl(\frac{D_j}{n_j}\biggr)
= \frac{1}{n_j^2} \Var(D_j)
= \frac{\Delta H_j}{n_j}.
\] Replacing the unknown \(\Delta H_j\) with \[
\Delta \hat{H}_j
= \hat{H}(t_j) - \hat{H}(t_{j - 1})
= \frac{d_j}{n_j},
\] we get the estimated variance \[
\Var\bigl(\Delta \hat{H}_j\bigr)
= \frac{d_j}{n_j^2}.
\] The variance of \(\hat{H}(t)\) is the sum of these variances over all time intervals with endpoints on or before time \(t\), so \[
\Var\bigl(\hat{H}(t)\bigr)
= \sum_{j: t_j \leq t} \Var\bigl(\Delta \hat{H}_j\bigr)
= \sum_{j: t_j \leq t} \frac{d_j}{n_j^2}.
\] With the Fleming-Harrington correction for ties from Equation 6.9, each \(d_j / n_j^2\) is replaced by \[
\frac{1}{n_j^2} + \frac{1}{(n_j - 1)^2} + \cdots + \frac{1}{\big(n_j - (d_j - 1)\big)^2}
> \frac{d_j}{n_j^2}.
\] This estimator of the variance (with or without the Fleming-Harrington correction) can be justified more rigorously using the theory of counting processes and martingales(Fleming and Harrington 2005; Aalen, Borgan, and Gjessing 2008). For our purposes, it is enough to highlight its connection to the Poisson distribution.
For each \(t\), a pointwise Wald 95% confidence interval for \(H(t)\) is \[
\hat{H}(t) \pm 1.96 \sqrt{\Var\bigl(\hat{H}(t)\bigr)}.
\] This can produce confidence intervals with negative lower bounds, outside the possible values of \(H(t)\). A better confidence interval is produced using a log transformation. By the delta method, \[
\Var\bigl(\ln \hat{H}(t)\bigr) = \frac{1}{\hat{H}(t)^2} \Var\bigl(\hat{H}(t)\bigr).
\] The corresponding confidence interval for \(\hat{H}(t)\) has the endpoints \[
\hat{H}(t) e^{\pm 1.96 \sqrt{\Var\bigl(\ln \hat{H}(t)\bigr)}}.
\tag{6.10}\] Both endpoints of this confidence interval are nonnegative, and they are strictly positive for all \(t\) such that \(\hat{H}(t) > 0\). Because \(H(t) = -\ln S(t)\), the log transformation for the cumulative hazard function \(H(t)\) corresponds to the log-log transformation for the survival function \(S(t)\).
6.3.3 Survival and cumulative incidence functions
The Nelson-Aalen estimate \(\hat{H}(t)\) can be used to estimate the survival function \[
S(t) = e^{-H(t)},
\] and the cumulative incidence function \[
F(t) = 1 - S(t) = 1 - e^{-H(t)}.
\] The estimated survival function is \[
\hat{S}_\text{NA}(t) = e^{-\hat{H}(t)},
\] and the estimated cumulative incidence function is \[
\hat{F}_\text{NA}(t) = 1 - \hat{S}_\text{NA}(t) = 1 - e^{-\hat{H}(t)}.
\] In both of these estimators, \(\hat{H}(t)\) can incorporate the Fleming-Harrington correction for ties from Equation 6.9. Confidence limits for \(S(t)\) and \(F(t)\) can be obtained from the corresponding confidence limits for \(H(t)\).
If there is any \(t_j\) where all individuals at risk have an event, the Kaplan-Meier estimator \(\hat{S}(t) = 0\) for all \(t > t_j\). Once you multiply by zero, there is no going back. This never happens for the estimate of \(S(t)\) based on the Nelson-Aalen estimator. Because \(\hat{H}(t) < \infty\), we always have \[
\hat{S}_\text{NA}(t) = \exp\bigl(-\hat{H}(t)\bigr) > 0.
\] This is a practical advantage of the Nelson-Aalen estimator over the Kaplan-Meier estimator.
More generally, the Kaplan-Meier estimator produces smaller estimates of \(S(t)\) than the Nelson-Aalen estimator does. Similar inequalities exist for the estimated \(H(t)\) and \(F(t)\): \[
\begin{aligned}
\hat{S}(t) &\leq \hat{S}_\text{NA}(t) \\
\hat{H}_\text{KM}(t) &\geq \hat{H}(t) \\
\hat{F}_{KM}(t) &\geq \hat{F}_\text{NA}(t).
\end{aligned}
\] Each inequality implies the others, but the cumulative hazard inequality is the simplest. As shown in Figure 6.3, \[
-\ln\biggl(1 - \frac{d_j}{n_j}\biggr)
\geq \frac{d_j}{n_j}
\] with equality only if \(d_j > 0\). By Equation 6.5 and Equation 6.7, \[
\hat{H}_{KM}(t)
= -\sum_{j: t_j \leq t} \ln\biggl(1 - \frac{d_j}{n_j}\biggr)
\geq \sum_{j: t_j \leq t} \frac{d_j}{n_j}
= \hat{H}(t).
\] with equality only when all \(d_j = 0\) in the sums. The Nelson-Aalen estimate with the Fleming-Harrington correction for ties is greater than the uncorrected \(\hat{H}(t)\) and less than \(\hat{H}_\text{KM}(t)\). Although not equal, the Nelson-Aalen estimator and Kaplan-Meier estimators of the survival \(S(t)\), cumulative hazard \(H(t)\), and the cumulative incidence \(F(t)\) produce similar results in large samples, where \(d_j / n_j\) is small for each \(j\).
Figure 6.3: Increments in the estimated cumulative hazard in the interval \((t_{j - 1}, t_j]\) based on the Kaplan-Meier and Nelson-Aalen estimators.
6.4 Parametric failure time distributions
Many times to events that are important in epidemiology cannot be accurately described using an exponential distribution. In particular, it is important to allow the hazard function \(h(t)\) to change over time. Here, we introduce two simple failure time distributions where \(h(t)\) is not constant. They each have a shape parameter \(\alpha\) and a rate parameter \(\lambda\). As with the exponential distribution, the scale parameter is \(\sigma = 1 / \lambda\). The gamma distribution from equation Equation 5.19 is also used as a failure time distribution, but its survival and hazard functions do not have a simple closed form.
For all parametric failure time models, likelihoods are constructed as in Section 5.2.4. The rate parameter \(\lambda\) and shape parameter \(\alpha\) can be estimated using frequentist methods such as maximum likelihood or Bayesian methods. When using parametric methods, it is important to evaluate goodness-of-fit to check whether the underlying assumptions are reasonable.
6.4.1 Weibull distribution
The Weibull distribution (Weibull et al. 1951) is a two-parameter generalization of the exponential distribution.4 It has the survival function \[
S(t, \alpha, \lambda) = \exp\big(-(\lambda t)^\alpha\big),
\] where \(\alpha > 0\) is the shape parameter and \(\lambda > 0\) is the rate parameter. The Weibull cumulative hazard function is \[
H(t, \alpha, \lambda) = -\ln S(t) = (\lambda t)^\alpha,
\tag{6.11}\] and its hazard function is \[
h(t, \alpha, \lambda)
= \frac{\partial}{\partial t} H(t, \alpha, \lambda)
= \alpha \lambda^\alpha t^{\alpha - 1}.
\tag{6.12}\] The notation \(\partial / \partial t\) means that we take a derivative with respect to \(t\) while holding the other arguments, \(\alpha\) and \(\lambda\), constant. Figure 6.4 shows examples of these hazard functions. The exponential distribution is a special case of the Weibull distribution with shape \(\alpha = 1\).
## Fitting a Weibull distribution# In R, the shape is 1 / the "scale" parameter.# In standard terminology, the scale is 1 / rate.library(survival)# Weibull distribution and regression (rate = 2, shape = 3)# Weibull is the default distribution for survival::survreg().wsample <-rweibull(1000, shape =3, scale =1/2)weibdat <-data.frame(time = wsample, event =1)weibreg <-survreg(Surv(time, event) ~1, data = weibdat)summary(weibreg)exp(-coef(weibreg)) # point estimate of rateexp(-confint(weibreg)) # 95% confidence interval for rate1/ weibreg$scale # point estimate of shape# log-transformed Wald confidence interval for the shape parameter# vcov() returns the estimated covariance matrix from the modelexp(-log(weibreg$scale) +c(-1, 1)*qnorm(.975) *sqrt(vcov(weibreg)["Log(scale)", "Log(scale)"]))# plot of true and estimated Weibull hazard functionswrate_est <-exp(-coef(weibreg))wshape_est <-1/ weibreg$scalewrate_true <-2wshape_true <-3h_weib <-function(time, rate, shape) rate * shape * (time * rate)^(shape -1)t <-seq(0, 4, by =0.01)plot(t, h_weib(t, wrate_true, wshape_true), type ="n",xlab ="Time", ylab ="Hazard (Weibull)")grid()lines(t, h_weib(t, wrate_est, wshape_est))lines(t, h_weib(t, wrate_true, wshape_true), lty ="dashed")legend("topleft", lty =c("solid", "dashed"), bg ="white",legend =c("Estimated hazard function", "True hazard function"))
6.4.2 Log-logistic distribution
The exponential distribution has a constant hazard, and the Weibull hazard function is increasing, decreasing, or constant. The log-logistic distribution has a more flexible hazard function. Its survival function is \[
S(t) = \frac{1}{1 + (\lambda t)^\alpha}.
\] where \(\lambda > 0\) is the rate pameter and \(\alpha > 0\) is the shape parameter. Its cumulative hazard function is \[
H(t, \alpha, \lambda) = -\ln S(t) = \ln \big(1 + (\lambda t)^\alpha\big),
\] and its the hazard function is \[
h(t, \alpha, \lambda)
= \frac{\partial}{\partial t} H(t, \alpha, \lambda)
= \frac{\lambda \alpha (\lambda t)^{\alpha - 1}}{1 + (\lambda t)^\alpha}.
\] As before, we differentiate \(H(t, \alpha, \lambda)\) with respect to \(t\) while holding \(\alpha\) and \(\lambda\) constant. There are three general shapes that the hazard function can take depending on the shape parameter \(\alpha\): \[
h(t)
\begin{cases}
\text{decreases from } \infty &\text{if } \alpha < 1, \\
\text{decreases from } \lambda &\text{if } \alpha = 1, \\
\text{increases then decreases} &\text{if } \alpha > 1.
\end{cases}
\]Figure 6.5 shows examples of these hazard functions. The exponential distribution is not a special case of the log-logistic distribution for any shape \(\alpha\).
Figure 6.5: Hazard functions for the log-logistic distribution with different shape parameters \(\alpha\). All have rate \(\lambda = 1\).
The name of the log-logistic distribution comes from the fact that the logarithm of a log-logistic random variable has a logistic distribution (just like the logarithm of a log-normal random variable has a normal distribution). The log-logistic distribution is used in economics to model the distribution of wealth or income (Fisk 1961), where it is known as the Fisk distribution.
## Fitting a log-logistic distribution# To sample a log-logistic random variable in R, you sample a logistic random# variable with location = -log(rate) and scale = 1 / shape.# The exponential of the logistic variable has a log-logistic distribution# with the correct rate and shape parameters.library(survival)# Log-logistic distribution and regression (rate = 2, shape = 3)llsample <-exp(rlogis(1000, location =-log(2), scale =1/3))llogdat <-data.frame(time = llsample, event =1)llogreg <-survreg(Surv(time, event) ~1, data = llogdat,dist ="loglogistic")exp(-coef(llogreg)) # point estimate of rateexp(-confint(llogreg)) # 95% confidence interval for rate1/ llogreg$scale # point estimate of shape# log-transformed 95% confidence interval for the shape parameterexp(-log(llogreg$scale) +c(-1, 1)*qnorm(.975) *sqrt(vcov(llogreg)["Log(scale)", "Log(scale)"]))# plot of true and estimated log-logistic hazard functionsllrate_est <-exp(-coef(llogreg))llshape_est <-1/ llogreg$scalellrate_true <-2llshape_true <-3h_llog <-function(time, rate, shape) {# returns last expression if there is no return() statement (rate * shape * (time * rate)^(shape -1) / (1+ (time* rate)^shape))}t <-seq(0, 4, by =0.01)plot(t, h_llog(t, llrate_true, llshape_true), type ="n",xlab ="Time", ylab ="Hazard (Log-logistic)")grid()lines(t, h_llog(t, llrate_est, llshape_est))lines(t, h_llog(t, llrate_true, llshape_true), lty ="dashed")legend("topright", lty =c("solid", "dashed"), bg ="white",legend =c("Estimated hazard function", "True hazard function"))
6.4.3 Cox-Snell residuals
One way to check goodness-of-fit for a parametric failure time model is to use Cox-Snell residuals(Cox and Snell 1968). For an observation \((\tentry_i, \texit_i, \delta_i)\), the Cox-Snell residual is \[
\Big(\hat{H}\bigl(\tentry_i\bigr), \hat{H}\bigl(\texit_i\bigr), \delta_i\Big),
\] where the estimated cumulative hazards are playing the role of entry and exit times. When the parametric model is correct, the Cox-Snell residuals are a right-censored and left-truncated sample from an exponential distribution with rate \(\lambda = 1\). To check this, we can plot the Nelson-Aalen estimate of the cumulative hazard for the Cox-Snell residuals and compare it to the exponential(1) cumulative hazard, which is \(H(t) = t\).
Aalen, Odd. 1978. “Nonparametric Inference for a Family of Counting Processes.”The Annals of Statistics 6: 701–26.
Aalen, Odd, Ørnulf Borgan, and Håkon Gjessing. 2008. Survival and Event History Analysis: A Process Point of View. Springer Science & Business Media.
Altshuler, Bernard. 1970. “Theory for the Measurement of Competing Risks in Animal Experiments.”Mathematical Biosciences 6: 1–11.
Cox, David R, and E Joyce Snell. 1968. “A General Definition of Residuals.”Journal of the Royal Statistical Society: Series B (Methodological) 30 (2): 248–65.
Fisk, Peter R. 1961. “The Graduation of Income Distributions.”Econometrica: Journal of the Econometric Society 29 (2): 171–85.
Fleming, Thomas R, and David P Harrington. 1984. “Nonparametric Estimation of the Survival Distribution in Censored Data.”Communications in Statistics-Theory and Methods 13 (20): 2469–86.
———. 2005. Counting Processes and Survival Analysis. Vol. 625. John Wiley & Sons.
Greenwood, Major. 1926. “The Natural Duration of Cancer.”Reports on Public Health and Medical Subjects 33: 1–26.
Kaplan, Edward L, and Paul Meier. 1958. “Nonparametric Estimation from Incomplete Observations.”Journal of the American Statistical Association 53 (282): 457–81.
Nelson, Wayne. 1969. “Hazard Plotting for Incomplete Failure Data.”Journal of Quality Technology 1: 27–52.
———. 1972. “Theory and Applications of Hazard Plotting for Censored Failure Data.”Technometrics 14 (4): 945–66.
Van der Vaart, Aad W. 2000. Asymptotic Statistics. Cambridge University Press.
Weibull, Waloddi et al. 1951. “A Statistical Distribution Function of Wide Applicability.”Journal of Applied Mechanics 18 (3): 293–97.
The Glivenko-Cantelli theorem guarantees that \(\sup_{x \in \mathbb{R}} |\hat{F}_n(x) - F(x)| \rightarrow 0\) as \(n \rightarrow \infty\), so the convergence happens simultaneously for all \(x\)(Van der Vaart 2000).↩︎
Named after American statisticians Edward L. Kaplan (1920–2006) and Paul Meier (1924–2011). Kaplan worked at Bell Telephone Laboratories, the Lawrence Radiation Laboratory (now the Lawrence Berkeley National Laboratory), and Oregon State University. Meier worked at Johns Hopkins and the University of Chicago and was an early advocate for the use of randomization in clinical trials. Both were doctoral students of John Tukey at Princeton. Their 1958 paper is one of the most-cited papers in statistics, with 66,740 citations as of 22 January 2025.↩︎
Major Greenwood (1880–1949) was an English epidemiologist and statistician. He worked at the Lister Institute (now part of the University of London) and joined the newly-created Ministry of Health after serving in the Royal Army Medical Corps in World War I. He studied the health effects of factory work and developed early models of infectious disease transmission. In 1928, he became the first professor of epidemiology at the London School of Hygiene and Tropical Medicine. In an obituary, Austin Bradford Hill wrote that one of Greenwood’s greatest contributions “lay merely in his outlook, in his statistical approach to medicine, then a new approach and one long regarded with suspicion. And he fought this fight continuously and honestly.”↩︎
Named after Waloddi Weibull (1887-1979), a Swedish engineer and applied mathematician who was a member of the Swedish Coast Guard and invented a technique of using explosives to determine the type and thickness of sediments beneath the sea floor.↩︎