PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_surviv_kaplanmeier (g12aa)
Purpose
nag_surviv_kaplanmeier (g12aa) computes the Kaplan–Meier, (or product-limit), estimates of survival probabilities for a sample of failure times.
Syntax
Description
A survivor function, , is the probability of surviving to at least time with , where is the cumulative distribution function of the failure times. The Kaplan–Meier or product limit estimator provides an estimate of , , from sample of failure times which may be progressively right-censored.
Let , , 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 be . If a failure and a loss (censored observation) occur at the same time , then the failure is treated as if it had occurred slightly before time and the loss as if it had occurred slightly after .
The Kaplan–Meier estimate of the survival probabilities is a step function which in the interval
to
is given by
where
is the number of failures occurring at time
.
nag_surviv_kaplanmeier (g12aa) computes the Kaplan–Meier estimates and the corresponding estimates of the variances,
, using Greenwood's formula,
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
Parameters
Compulsory Input Parameters
- 1:
– double array
-
The failure and censored times; these need not be ordered.
- 2:
– int64int32nag_int array
-
contains the censoring code of the
th observation, for
.
- The th observation is a failure time.
- The th observation is right-censored.
Constraint:
or , for .
- 3:
– string (length ≥ 1)
-
Indicates whether frequencies are provided for each time point.
- Frequencies are provided for each failure and censored time.
- The failure and censored times are considered as single observations, i.e., a frequency of is assumed.
Constraint:
or .
- 4:
– int64int32nag_int array
-
The dimension of the array
ifreq
must be at least
if
and at least
if
If
,
must contain the frequency of the
th observation.
If
, a frequency of
is assumed and
ifreq is not referenced.
Constraint:
if , , for .
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the arrays
ic,
t. (An error is raised if these dimensions are not equal.)
The number of failure and censored times given in
t.
Constraint:
.
Output Parameters
- 1:
– int64int32nag_int scalar
-
The number of distinct failure times, .
- 2:
– double array
-
contains the th ordered distinct failure time, , for .
- 3:
– double array
-
contains the Kaplan–Meier estimate of the survival probability, , for time , for .
- 4:
– double array
-
contains an estimate of the standard deviation of , for .
- 5:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
-
-
On entry, | or . |
-
-
On entry, | or , for some . |
-
-
On entry, | and , for some . |
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
The computations are believed to be stable.
Further Comments
If there are no censored observations, reduces to the ordinary binomial estimate of the probability of survival at time .
Example
The remission times for a set of
leukaemia patients at
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).
Open in the MATLAB editor:
g12aa_example
function g12aa_example
fprintf('g12aa example results\n\n');
t = [ 6; 6; 7; 9; 10; 10; 11; 13; 16;
17; 19; 20; 22; 23; 25; 32; 34; 35];
ic = [int64(1); 0; 0; 1; 0; 1; 1; 0; 0;
1; 1; 1; 0; 0; 1; 1; 1; 1];
freq = 'Frequencies';
ifreq = ones(numel(t),1,'int64');
ifreq(2) = 3;
ifreq(16) = 2;
[nd, tp, p, psig, ifail] = g12aa( ...
t, ic, freq, ifreq);
fprintf(' Time Survival Standard\n');
fprintf(' probability deviation\n\n');
fprintf('%6.1f%10.3f%12.3f\n', [tp(1:nd) p(1:nd) psig(1:nd)]');
fig1 = figure;
stp = [0; tp(1:nd)];
sp = [1; p(1:nd)];
stairs(stp,sp);
xlabel('Time');
ylabel('Survival probability');
title('Kaplan Meier plot');
legend('Off');
axis([0 tp(nd)+1 0 1.1]);
g12aa example results
Time Survival Standard
probability deviation
6.0 0.857 0.076
7.0 0.807 0.087
10.0 0.753 0.096
13.0 0.690 0.107
16.0 0.627 0.114
22.0 0.538 0.128
23.0 0.448 0.135
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015