G12AAF (PDF version)
G12 Chapter Contents
G12 Chapter Introduction
NAG Library Manual

NAG Library Routine Document

G12AAF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

G12AAF computes the Kaplan–Meier, (or product-limit), estimates of survival probabilities for a sample of failure times.

2  Specification

SUBROUTINE G12AAF ( N, T, IC, FREQ, IFREQ, ND, TP, P, PSIG, IWK, IFAIL)
INTEGER  N, IC(N), IFREQ(*), ND, IWK(N), IFAIL
REAL (KIND=nag_wp)  T(N), TP(N), P(N), PSIG(N)
CHARACTER(1)  FREQ

3  Description

A survivor function, St, is the probability of surviving to at least time t with St=1-Ft, where Ft is the cumulative distribution function of the failure times. The Kaplan–Meier or product limit estimator provides an estimate of St, S^t, from sample of failure times which may be progressively right-censored.
Let ti, i=1,2,,nd, be the ordered distinct failure times for the sample of observed failure/censored times, and let the number of observations in the sample that have not failed by time ti be ni. If a failure and a loss (censored observation) occur at the same time ti, then the failure is treated as if it had occurred slightly before time ti and the loss as if it had occurred slightly after ti.
The Kaplan–Meier estimate of the survival probabilities is a step function which in the interval ti to ti+1 is given by
S^t=j=1i nj-djnj ,
where dj is the number of failures occurring at time tj.
G12AAF computes the Kaplan–Meier estimates and the corresponding estimates of the variances, var^S^t, using Greenwood's formula,
var^S^t=S^ t 2j=1idjnjnj-dj .

4  References

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

5  Parameters

1:     N – INTEGERInput
On entry: the number of failure and censored times given in T.
Constraint: N2.
2:     T(N) – REAL (KIND=nag_wp) arrayInput
On entry: the failure and censored times; these need not be ordered.
3:     IC(N) – INTEGER arrayInput
On entry: ICi contains the censoring code of the ith observation, for i=1,2,,N.
ICi=0
The ith observation is a failure time.
ICi=1
The ith observation is right-censored.
Constraint: ICi=0 or 1, for i=1,2,,N.
4:     FREQ – CHARACTER(1)Input
On entry: indicates whether frequencies are provided for each time point.
FREQ='F'
Frequencies are provided for each failure and censored time.
FREQ='S'
The failure and censored times are considered as single observations, i.e., a frequency of 1 is assumed.
Constraint: FREQ='F' or 'S'.
5:     IFREQ(*) – INTEGER arrayInput
Note: the dimension of the array IFREQ must be at least N if FREQ='F' and at least 1 if FREQ='S'.
On entry: if FREQ='F', IFREQi must contain the frequency of the ith observation.
If IFREQ='S', a frequency of 1 is assumed and IFREQ is not referenced.
Constraint: if FREQ='F', IFREQi0, for i=1,2,,N.
6:     ND – INTEGEROutput
On exit: the number of distinct failure times, nd.
7:     TP(N) – REAL (KIND=nag_wp) arrayOutput
On exit: TPi contains the ith ordered distinct failure time, ti, for i=1,2,,nd.
8:     P(N) – REAL (KIND=nag_wp) arrayOutput
On exit: Pi contains the Kaplan–Meier estimate of the survival probability, S^t, for time TPi, for i=1,2,,nd.
9:     PSIG(N) – REAL (KIND=nag_wp) arrayOutput
On exit: PSIGi contains an estimate of the standard deviation of Pi, for i=1,2,,nd.
10:   IWK(N) – INTEGER arrayWorkspace
11:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of IFAIL on exit.
On exit: IFAIL=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6  Error Indicators and Warnings

If on entry IFAIL=0 or -1, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
IFAIL=1
On entry,N<2.
IFAIL=2
On entry,FREQ'F' or 'S'.
IFAIL=3
On entry,ICi0 or 1, for some i=1,2,,N.
IFAIL=4
On entry,FREQ='F' and IFREQi<0, for some i=1,2,,N.

7  Accuracy

The computations are believed to be stable.

8  Further Comments

If there are no censored observations, S^t reduces to the ordinary binomial estimate of the probability of survival at time t.

9  Example

The remission times for a set of 21 leukaemia patients at 18 distinct time points are read in and the Kaplan–Meier estimate computed and printed. For further details see page 242 of Gross and Clark (1975).

9.1  Program Text

Program Text (g12aafe.f90)

9.2  Program Data

Program Data (g12aafe.d)

9.3  Program Results

Program Results (g12aafe.r)


G12AAF (PDF version)
G12 Chapter Contents
G12 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2012