NAG Library Routine Document
G12ABF
1 Purpose
G12ABF calculates the rank statistics, which can include the logrank test, for comparing survival curves.
2 Specification
SUBROUTINE G12ABF ( |
N, T, IC, GRP, NGRP, FREQ, IFREQ, WEIGHT, WT, TS, DF, P, OBSD, EXPT, ND, DI, NI, LDN, IFAIL) |
INTEGER |
N, IC(N), GRP(N), NGRP, IFREQ(*), DF, ND, DI(LDN), NI(LDN), LDN, IFAIL |
REAL (KIND=nag_wp) |
T(N), WT(*), TS, P, OBSD(NGRP), EXPT(NGRP) |
CHARACTER(1) |
FREQ, WEIGHT |
|
3 Description
A survivor function,
, is the probability of surviving to at least time
. Given a series of
failure or right-censored times from
groups G12ABF calculates a rank statistic for testing the null hypothesis
-
where
is the largest observed time, against the alternative hypothesis
-
at least one of the
differ, for some
.
Let
, for
, denote the list of distinct failure times across all
groups and
a series of
weights. Let
denote the number of failures at time
in group
and
denote the number of observations in the group
that are known to have not failed prior to time
, i.e., the size of the risk set for group
at time
. If a censored observation occurs at time
then that observation is treated as if the censoring had occurred slightly after
and therefore the observation is counted as being part of the risk set at time
. Finally let
The (weighted) number of observed failures in the
th group,
, is therefore given by
and the (weighted) number of expected failures in the
th group,
, by
If
denotes the vector of differences
and
where
if
and
otherwise, then the rank statistic,
, is calculated as
where
denotes a generalized inverse of the matrix
. Under the null hypothesis,
where the degrees of freedom,
, is taken as the rank of the matrix
.
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
Rostomily R C, Duong D, McCormick K, Bland M and Berger M S (1994) Multimodality management of recurrent adult malignant gliomas: results of a phase II multiagent chemotherapy study and analysis of cytoreductive surgery Neurosurgery 35 378
5 Parameters
- 1: – INTEGERInput
-
On entry: , the number of failure and censored times.
Constraint:
.
- 2: – REAL (KIND=nag_wp) arrayInput
-
On entry: the observed failure and censored times; these need not be ordered.
Constraint:
for at least one , for and .
- 3: – INTEGER arrayInput
-
On entry:
contains the censoring code of the
th observation, for
.
- the th observation is a failure time.
- the th observation is right-censored.
Constraints:
- or , for ;
- for at least one .
- 4: – INTEGER arrayInput
-
On entry: contains a flag indicating which group the th observation belongs in, for .
Constraints:
- , for ;
- each group must have at least one observation.
- 5: – INTEGERInput
-
On entry: , the number of groups.
Constraint:
.
- 6: – CHARACTER(1)Input
-
On entry: 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 .
- 7: – INTEGER arrayInput
-
Note: the dimension of the array
IFREQ
must be at least
if
.
On entry: if
,
must contain the frequency (number of observations) to which each entry in
T corresponds.
If
, each entry in
T is assumed to correspond to a single observation, i.e., a frequency of
is assumed, and
IFREQ is not referenced.
Constraint:
if , , for .
- 8: – CHARACTER(1)Input
-
On entry: indicates if weights are to be used.
- All weights are assumed to be .
- The weights, are supplied in WT.
Constraint:
or .
- 9: – REAL (KIND=nag_wp) arrayInput
-
Note: the dimension of the array
WT
must be at least
if
.
On entry: if
,
WT must contain the
weights,
, where
is the number of distinct failure times.
If
,
WT is not referenced and
for all
.
Constraint:
if , , for .
- 10: – REAL (KIND=nag_wp)Output
-
On exit: , the test statistic.
- 11: – INTEGEROutput
-
On exit: , the degrees of freedom.
- 12: – REAL (KIND=nag_wp)Output
-
On exit:
, when
, i.e., the probability associated with
TS.
- 13: – REAL (KIND=nag_wp) arrayOutput
-
On exit: , the observed number of failures in each group.
- 14: – REAL (KIND=nag_wp) arrayOutput
-
On exit: , the expected number of failures in each group.
- 15: – INTEGEROutput
-
On exit: , the number of distinct failure times.
- 16: – INTEGER arrayOutput
-
On exit: the first
ND elements of
DI contain
, the number of failures, across all groups, at time
.
- 17: – INTEGER arrayOutput
-
On exit: the first
ND elements of
NI contain
, the size of the risk set, across all groups, at time
.
- 18: – INTEGERInput
-
On entry: the size of arrays
DI and
NI. As
, if
is not known
a priori then a value of
N can safely be used for
LDN.
Constraint:
, the number of unique failure times.
- 19: – INTEGERInput/Output
-
On entry:
IFAIL must be set to
,
. 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
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
.
When the value is used it is essential to test the value of IFAIL on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6 Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
Errors or warnings detected by the routine:
-
On entry, .
Constraint: .
-
On entry, all the times in
T are the same.
-
On entry, .
Constraint: or .
-
On entry, and .
Constraint: .
-
On entry, and .
Constraint: .
-
On entry,
FREQ had an illegal value.
-
On entry, .
Constraint: .
-
On entry,
WEIGHT had an illegal value.
-
On entry, .
Constraint: .
-
The degrees of freedom are zero.
-
On entry, .
Constraint: .
-
On entry, all observations are censored.
-
On entry, group has no observations.
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.8 in the Essential Introduction for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 3.7 in the Essential Introduction for further information.
Dynamic memory allocation failed.
See
Section 3.6 in the Essential Introduction for further information.
7 Accuracy
Not applicable.
8 Parallelism and Performance
G12ABF is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
G12ABF makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the
X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the
Users' Note for your implementation for any additional implementation-specific information.
The use of different weights in the formula given in
Section 3 leads to different rank statistics being calculated. The logrank test has
, for all
, which is the equivalent of calling G12ABF when
. Other rank statistics include Wilcoxon (
), Tarone–Ware (
) and Peto–Peto (
where
) amongst others.
Calculation of any test, other than the logrank test, will probably require G12ABF to be called twice, once to calculate the values of and to facilitate in the computation of the required weights, and once to calculate the test statistic itself.
10 Example
This example compares the time to death for
adults with two different types of recurrent gliomas (brain tumour), astrocytoma and glioblastoma, using a logrank test. For further details on the data see
Rostomily et al. (1994).
10.1 Program Text
Program Text (g12abfe.f90)
10.2 Program Data
Program Data (g12abfe.d)
10.3 Program Results
Program Results (g12abfe.r)