PDF version (NAG web site
, 64bit version, 64bit version)
NAG Toolbox Chapter Introduction
G12 — Survival Analysis
Scope of the Chapter
This chapter is concerned with statistical techniques used in the analysis of survival/reliability/failure time data.
Other chapters contain functions which are also used to analyse this type of data.
Chapter G02 contains generalized linear models,
Chapter G07
contains functions to fit distribution models, and
Chapter G08 contains rank based methods.
Background to the Problems
Introduction to Terminology
This chapter is concerned with the analysis on the time,
t$t$, to a single event. This type of analysis occurs commonly in two areas. In medical research it is known as survival analysis and is often the time from the start of treatment to the occurrence of a particular condition or of death. In engineering it is concerned with reliability and the analysis of failure times, that is how long a component can be used until it fails. In this chapter the time t$t$ will be referred to as the failure time.
Let the probability density function of the failure time be
f(t)$f\left(t\right)$, then the
survivor function,
S(t)$S\left(t\right)$, which is the probability of surviving to at least time
t$t$, is given by
where
F(t)$F\left(t\right)$ is the cumulative density function. The
hazard function,
λ(t)$\lambda \left(t\right)$, is the probability that failure occurs at time
t$t$ given that the individual survived up to time
t$t$, and is given by
The
cumulative hazard rate is defined as
hence
S(t) = e^{ − Λ(t)}$S\left(t\right)={e}^{\Lambda \left(t\right)}$.
It is common in survival analysis for some of the data to be
rightcensored. That is, the exact failure time is not known, only that failure occurred after a known time. This may be due to the experiment being terminated before all the individuals have failed, or an individual being removed from the experiment for a reason not connected with effects being tested in the experiment. The presence of censored data leads to complications in the analysis.
Rank Statistics
There are a number of different rank statistics described in the literature, the most common being the logrank statistic. All of these statistics are designed to test the null hypothesis

H_{0}
:
S_{1}
(t)
=
S_{2}
(t)
=
⋯
=
S_{g}
(t)
,
∀
t
≤
τ
${H}_{0}:{S}_{1}\left(t\right)={S}_{2}\left(t\right)=\cdots ={S}_{g}\left(t\right),\forall t\le \tau $
where
S_{j}${S}_{j}$ is the survivor function for group
j$j$,
g$g$ is the number of groups being tested and
τ$\tau $ is the largest observed time, against the alternative hypothesis

H_{1}
:
${H}_{1}:$ at least one of the
S_{j}
(t)
${S}_{j}\left(t\right)$ differ, for some
t
≤
τ
$t\le \tau $.
A rank statistics T$T$ is calculated as follows:
Let
t_{i}
${t}_{i}$, for
i
=
1
,
2
,
…
,
n_{d}
$i=1,2,\dots ,{n}_{d}$, denote the list of distinct failure times across all g$g$ groups and w_{i}${w}_{i}$ a series of n_{d}${n}_{d}$ weights.
Let d_{ij}${d}_{ij}$ denote the number of failures at time t_{i}${t}_{i}$ in group j$j$ and n_{ij}${n}_{ij}$ denote the number of observations in the group j$j$ that are known to have not failed prior to time t_{i}${t}_{i}$, i.e., the size of the risk set for group j$j$ at time t_{i}${t}_{i}$. If a censored observation occurs at time t_{i}${t}_{i}$ then that observation is treated as if the censoring had occurred slightly after t_{i}${t}_{i}$ and therefore the observation is counted as being part of the risk set at time t_{i}${t}_{i}$.
The (weighted) number of observed failures in the
j$j$th group,
O_{j}${O}_{j}$, is therefore given by
and the (weighted) number of expected failures in the
j$j$th group,
E_{j}${E}_{j}$, by
and if
x$x$ denote the vector of differences
x
=
(O_{1} − E_{1},O_{2} − E_{2}, … ,O_{g} − E_{g})
$x=({O}_{1}{E}_{1},{O}_{2}{E}_{2},\dots ,{O}_{g}{E}_{g})$
where
I_{jk}
=
1
${I}_{jk}=1$ if
j = k$j=k$ and
0$0$ otherwise, then the rank statistic,
T$T$, is calculated as
where
V^{−}${V}^{}$ denotes a generalized inverse of the matrix
V$V$.
Under the null hypothesis,
T
∼
χ_{ν}^{2}
$T\sim {\chi}_{\nu}^{2}$ where the degrees of freedom, ν$\nu $, is taken as the rank of the matrix V$V$.
The different rank statistics are defined by using different weights in the above calculations, for example
logrank statistic 
w_{i} = 1${w}_{i}=1$ 
Wilcoxon rank statistic 
w_{i} = n_{i}${w}_{i}={n}_{i}$ 
Tarone–Ware rank statistic 
w_{i} = sqrt(n_{i})${w}_{i}=\sqrt{{n}_{i}}$ 
Peto–Peto rank statistic 
w_{i}
=
S̃
(t_{i})
${w}_{i}=\stackrel{~}{S}\left({t}_{i}\right)$ where
S̃
(t_{i})
=
∏ _{
tj
≤
ti
}
(
n_{j}
−
d_{j}
+
1
)/(n_{j} + 1)
$\stackrel{~}{S}\left({t}_{i}\right)={\displaystyle \prod _{{t}_{j}\le {t}_{i}}}\phantom{\rule{0.25em}{0ex}}\frac{{n}_{j}{d}_{j}+1}{{n}_{j}+1}$ 
Estimating the Survivor Function and Hazard Plotting
The most common estimate of the survivor function for censored data is the
Kaplan–Meier or
productlimit
estimate,
where
d_{j}${d}_{j}$ is the number of failures occurring at time
t_{j}${t}_{j}$ out of
n_{j}${n}_{j}$ surviving to
t_{j}${t}_{j}$. This is a step function with steps at each failure time but not at censored times.
As
S(t) = e^{ − Λ(t)}$S\left(t\right)={e}^{\Lambda \left(t\right)}$ the cumulative hazard rate can be estimated by
A plot of
Λ̂(t)$\hat{\Lambda}\left(t\right)$ or
log(Λ̂(t))$\mathrm{log}\left(\hat{\Lambda}\left(t\right)\right)$ against
t$t$ or
logt$\mathrm{log}t$ is often useful in identifying a suitable parametric model for the survivor times. The following relationships can be used in the identification.
(a) 
Exponential distribution: Λ(t) = λt$\Lambda \left(t\right)=\lambda t$. 
(b) 
Weibull distribution: log(Λ(t)) = logλ + γlogt$\mathrm{log}\left(\Lambda \left(t\right)\right)=\mathrm{log}\lambda +\gamma \mathrm{log}t$. 
(c) 
Gompertz distribution: log(Λ(t)) = logλ + γt$\mathrm{log}\left(\Lambda \left(t\right)\right)=\mathrm{log}\lambda +\gamma t$. 
(d) 
Extreme value (smallest) distribution: log(Λ(t)) = λ(t − γ)$\mathrm{log}\left(\Lambda \left(t\right)\right)=\lambda (t\gamma )$. 
Proportional Hazard Models
Often in the analysis of survival data the relationship between the hazard function and the number of explanatory variables or covariates is modelled. The covariates may be, for example, group or treatment indicators or measures of the state of the individual at the start of the observational period. There are two types of covariate time independent covariates such as those described above which do not change value during the observational period and time dependent covariates. The latter can be classified as either external covariates, in which case they are not directly involved with the failure mechanism, or as internal covariates which are time dependent measurements taken on the individual.
The most common function relating the covariates to the hazard function is the proportional hazard function
where
λ_{0}(t)${\lambda}_{0}\left(t\right)$ is a baseline hazard function,
z$z$ is a vector of covariates and
β$\beta $ is a vector of unknown parameters. The assumption is that the covariates have a multiplicative effect on the hazard.
The form of
λ_{0}(t)${\lambda}_{0}\left(t\right)$ can be one of the distributions considered above or a nonparametric function. In the case of the exponential, Weibull and extreme value distributions the proportional hazard model can be fitted to censored data using the method described by
Aitkin and Clayton (1980) which uses a generalized linear model with Poisson errors. Other possible models are the gamma distribution and the lognormal distribution.
Cox's Proportional Hazard Model
Rather than using a specified form for the hazard function,
Cox (1972) considered the case when
λ_{0}(t)${\lambda}_{0}\left(t\right)$ was an unspecified function of time. To fit such a model assuming fixed covariates a marginal likelihood is used. For each of the times at which a failure occurred,
t_{i}${t}_{i}$, the set of those who were still in the study is considered this includes any that were censored at
t_{i}${t}_{i}$. This set is known as the risk set for time
t_{i}${t}_{i}$ and denoted by
R(t_{i})$R\left({t}_{i}\right)$. Given the risk set the probability that out of all possible sets of
d_{i}${d}_{i}$ subjects that could have failed the actual observed
d_{i}${d}_{i}$ cases failed can be written as
where
s_{i}${s}_{i}$ is the sum of the covariates of the
d_{i}${d}_{i}$ individuals observed to fail at
t_{i}${t}_{i}$ and the summation is over all distinct sets of
n_{i}${n}_{i}$ individuals drawn from
R(t_{i})$R\left({t}_{i}\right)$. This leads to a complex likelihood. If there are no ties in failure times the likelihood reduces to
where
n_{d}${n}_{d}$ is the number of distinct failure times. For cases where there are ties the following approximation, due to
Peto [2], can be used:
Having fitted the model an estimate of the baseline survivor function (derived from λ_{0}(t)${\lambda}_{0}\left(t\right)$ and the residuals) can be computed to examine the suitability of the model, in particular the proportional hazard assumption.
Recommendations on Choice and Use of Available Functions
The following functions are available.
Depending on the rank statistic required, it may be necessary to call
nag_surviv_logrank (g12ab) twice, once to calculate the number of failures (
d_{i}${d}_{i}$) and the total number of observations (
n_{i}${n}_{i}$) at time
t_{i}${t}_{i}$, to facilitate in the computation of the required weights, and once to calculate the required rank statistics.
The following functions from other chapters may also be useful in the analysis of survival data.
Functionality Index
Cox's proportional hazard model,   
References
Aitkin M and Clayton D (1980) The fitting of exponential, Weibull and extreme value distributions to complex censored survival data using GLIM Appl. Statist. 29 156–163
Cox D R (1972) Regression models in life tables (with discussion) J. Roy. Statist. Soc. Ser. B 34 187–220
Gross A J and Clark V A (1975) Survival Distributions: Reliability Applications in the Biomedical Sciences Wiley
Kalbfleisch J D and Prentice R L (1980) The Statistical Analysis of Failure Time Data Wiley
PDF version (NAG web site
, 64bit version, 64bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013