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

NAG Library Routine Document

G12ABF

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

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, St, is the probability of surviving to at least time t. Given a series of n failure or right-censored times from g groups G12ABF calculates a rank statistic for testing the null hypothesis where τ is the largest observed time, against the alternative hypothesis
Let t i , for i=1,2,,nd, denote the list of distinct failure times across all g groups and wi a series of nd weights. Let dij denote the number of failures at time ti in group j and nij denote the number of observations in the group j that are known to have not failed prior to time ti, i.e., the size of the risk set for group j at time ti. If a censored observation occurs at time ti then that observation is treated as if the censoring had occurred slightly after ti and therefore the observation is counted as being part of the risk set at time ti. Finally let
di = j=1 g d ij   and   ni = j=1 g n ij .
The (weighted) number of observed failures in the jth group, Oj, is therefore given by
Oj = i=1 nd wi d ij
and the (weighted) number of expected failures in the jth group, Ej, by
Ej = i=1 nd wi n ij di ni .
If x denotes the vector of differences x = O1 - E1 , O2 - E2 , , Og - Eg  and
V jk = i=1 nd w i 2 di ni - di ni n i k I jk - n ij n ik n i 2 ni - 1
where I jk = 1  if j=k and 0 otherwise, then the rank statistic, T, is calculated as
T = x V- xT
where V- denotes a generalized inverse of the matrix V. Under the null hypothesis, T χ ν 2  where the degrees of freedom, ν, is taken as the rank of the matrix V.

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:     N – INTEGERInput
On entry: n, the number of failure and censored times.
Constraint: N2.
2:     T(N) – REAL (KIND=nag_wp) arrayInput
On entry: the observed failure and censored times; these need not be ordered.
Constraint: TiTj for at least one ij, for i=1,2,,N and j=1,2,,N.
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.
Constraints:
  • ICi=0 or 1, for i=1,2,,N;
  • ICi=0 for at least one i.
4:     GRP(N) – INTEGER arrayInput
On entry: GRPi contains a flag indicating which group the ith observation belongs in, for i=1,2,,N.
Constraints:
  • 1GRPiNGRP, for i=1,2,,N;
  • each group must have at least one observation.
5:     NGRP – INTEGERInput
On entry: g, the number of groups.
Constraint: 2NGRPN.
6:     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'.
7:     IFREQ(*) – INTEGER arrayInput
Note: the dimension of the array IFREQ must be at least N if FREQ='F'.
On entry: if FREQ='F', IFREQi must contain the frequency (number of observations) to which each entry in T corresponds.
If FREQ='S', each entry in T is assumed to correspond to a single observation, i.e., a frequency of 1 is assumed, and IFREQ is not referenced.
Constraint: if FREQ='F', IFREQi0, for i=1,2,,N.
8:     WEIGHT – CHARACTER(1)Input
On entry: indicates if weights are to be used.
WEIGHT='U'
All weights are assumed to be 1.
WEIGHT='W'
The weights, wi are supplied in WT.
Constraint: WEIGHT='U' or 'W'.
9:     WT(*) – REAL (KIND=nag_wp) arrayInput
Note: the dimension of the array WT must be at least LDN if WEIGHT='W'.
On entry: if WEIGHT='W', WT must contain the nd weights, wi, where nd is the number of distinct failure times.
If WEIGHT='U', WT is not referenced and wi=1 for all i.
Constraint: if WEIGHT='W', WTi0.0, for i=1,2,,nd.
10:   TS – REAL (KIND=nag_wp)Output
On exit: T, the test statistic.
11:   DF – INTEGEROutput
On exit: ν, the degrees of freedom.
12:   P – REAL (KIND=nag_wp)Output
On exit: PXT, when Xχν2, i.e., the probability associated with TS.
13:   OBSD(NGRP) – REAL (KIND=nag_wp) arrayOutput
On exit: Oi, the observed number of failures in each group.
14:   EXPT(NGRP) – REAL (KIND=nag_wp) arrayOutput
On exit: Ei, the expected number of failures in each group.
15:   ND – INTEGEROutput
On exit: nd, the number of distinct failure times.
16:   DI(LDN) – INTEGER arrayOutput
On exit: the first ND elements of DI contain di, the number of failures, across all groups, at time ti.
17:   NI(LDN) – INTEGER arrayOutput
On exit: the first ND elements of NI contain ni, the size of the risk set, across all groups, at time ti.
18:   LDN – INTEGERInput
On entry: the size of arrays DI and NI. As ndn, if nd is not known a priori then a value of N can safely be used for LDN.
Constraint: LDNnd, the number of unique failure times.
19:   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, all the times in T are the same.
IFAIL=3
On entry, ICi0 or 1, for at least one i=1,2,,N.
IFAIL=31
On entry, all observations are censored.
IFAIL=4
On entry, GRPi<1 or GRPi>NGRP, for at least one i=1,2,,N.
IFAIL=41
On entry, at least one group has no observations.
IFAIL=5
On entry, NGRP<2 or NGRP>N.
IFAIL=6
On entry, FREQ'F' or 'S'.
IFAIL=7
On entry, FREQ='F' and IFREQi<0, for at least one i=1,2,,N.
IFAIL=8
On entry, WEIGHT'U' or 'W'.
IFAIL=9
On entry, WEIGHT='W' and WTi<0.0, for some i=1,2,,N.
IFAIL=11
The degrees of freedom are zero.
IFAIL=18
On entry, LDN<nd.

7  Accuracy

Not applicable.

8  Further Comments

The use of different weights in the formula given in Section 3 leads to different rank statistics being calculated. The logrank test has wi=1, for all i, which is the equivalent of calling G12ABF when WEIGHT='U' . Other rank statistics include Wilcoxon (wi=ni), Tarone–Ware (wi=ni) and Peto–Peto ( wi = S~ ti  where S~ ti = tj ti nj - dj + 1 nj+1 ) 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 ni and di to facilitate in the computation of the required weights, and once to calculate the test statistic itself.

9  Example

This example compares the time to death for 51 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).

9.1  Program Text

Program Text (g12abfe.f90)

9.2  Program Data

Program Data (g12abfe.d)

9.3  Program Results

Program Results (g12abfe.r)


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

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