NAG Library Routine Document

g12aaf (kaplanmeier)

1
Purpose

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

2
Specification

Fortran Interface
Subroutine g12aaf ( n, t, ic, freq, ifreq, nd, tp, p, psig, iwk, ifail)
Integer, Intent (In):: n, ic(n), ifreq(*)
Integer, Intent (Inout):: ifail
Integer, Intent (Out):: nd, iwk(n)
Real (Kind=nag_wp), Intent (In):: t(n)
Real (Kind=nag_wp), Intent (Out):: tp(n), p(n), psig(n)
Character (1), Intent (In):: freq
C Header Interface
#include <nagmk26.h>
void  g12aaf_ (const Integer *n, const double t[], const Integer ic[], const char *freq, const Integer ifreq[], Integer *nd, double tp[], double p[], double psig[], Integer iwk[], Integer *ifail, const Charlen length_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
Arguments

1:     n – IntegerInput
On entry: the number of failure and censored times given in t.
Constraint: n2.
2:     tn – Real (Kind=nag_wp) arrayInput
On entry: the failure and censored times; these need not be ordered.
3:     icn – 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:     tpn – Real (Kind=nag_wp) arrayOutput
On exit: tpi contains the ith ordered distinct failure time, ti, for i=1,2,,nd.
8:     pn – 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:     psign – Real (Kind=nag_wp) arrayOutput
On exit: psigi contains an estimate of the standard deviation of pi, for i=1,2,,nd.
10:   iwkn – Integer arrayWorkspace
11:   ifail – IntegerInput/Output
On entry: ifail must be set to 0, -1 or 1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation 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 argument, 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=value.
Constraint: n2.
ifail=2
On entry, freq=value.
Constraint: freq='F' or 'S'.
ifail=3
On entry, i=value and ici=value.
Constraint: ici=0 or 1.
ifail=4
On entry, i=value and ifreqi=value.
Constraint: ifreqi0.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

7
Accuracy

The computations are believed to be stable.

8
Parallelism and Performance

g12aaf is not threaded in any implementation.

9
Further Comments

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

10
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).

10.1
Program Text

Program Text (g12aafe.f90)

10.2
Program Data

Program Data (g12aafe.d)

10.3
Program Results

Program Results (g12aafe.r)

GnuplotProduced by GNUPLOT 4.6 patchlevel 3 0 0.2 0.4 0.6 0.8 1 5 10 15 20 Survival Probability Time Example Program Kaplan Meier Plot gnuplot_plot_1