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

NAG Library Routine Document


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.


    1  Purpose
    7  Accuracy

1  Purpose

G12ZAF creates the risk sets associated with the Cox proportional hazards model for fixed covariates.

2  Specification

REAL (KIND=nag_wp)  Z(LDZ,M), T(N), X(MXN,IP), TP(N)

3  Description

The Cox proportional hazards model (see Cox (1972)) relates the time to an event, usually death or failure, to a number of explanatory variables known as covariates. Some of the observations may be right-censored, that is, the exact time to failure is not known, only that it is greater than a known time.
Let ti, for i=1,2,,n, be the failure time or censored time for the ith observation with the vector of p covariates zi. It is assumed that censoring and failure mechanisms are independent. The hazard function, λt,z, is the probability that an individual with covariates z fails at time t given that the individual survived up to time t. In the Cox proportional hazards model, λt,z is of the form
where λ0 is the base-line hazard function, an unspecified function of time, and β is a vector of unknown parameters. As λ0 is unknown, the parameters β are estimated using the conditional or marginal likelihood. This involves considering the covariate values of all subjects that are at risk at the time when a failure occurs. The probability that the subject that failed had their observed set of covariate values is computed.
The risk set at a failure time consists of those subjects that fail or are censored at that time and those who survive beyond that time. As risk sets are computed for every distinct failure time, it should be noted that the combined risk sets may be considerably larger than the original data. If the data can be considered as coming from different strata such that λ0 varies from strata to strata but β remains constant, then G12ZAF will return a factor that indicates to which risk set/strata each member of the risk sets belongs rather than just to which risk set.
Given the risk sets the Cox proportional hazards model can then be fitted using a Poisson generalized linear model (G02GCF with G04EAF to compute dummy variables) using Breslow's approximation for ties (see Breslow (1974)). This will give the same fit as G12BAF. If the exact treatment of ties in discrete time is required, as given by Cox (1972), then the model is fitted as a conditional logistic model using G11CAF.

4  References

Breslow N E (1974) Covariate analysis of censored survival data Biometrics 30 89–99
Cox D R (1972) Regression models in life tables (with discussion) J. Roy. Statist. Soc. Ser. B 34 187–220
Gross A J and Clark V A (1975) Survival Distributions: Reliability Applications in the Biomedical Sciences Wiley

5  Parameters

1:     N – INTEGERInput
On entry: n, the number of data points.
Constraint: N2.
2:     M – INTEGERInput
On entry: the number of covariates in array Z.
Constraint: M1.
3:     NS – INTEGERInput
On entry: the number of strata. If NS>0 then the stratum for each observation must be supplied in ISI.
Constraint: NS0.
4:     ZLDZM – REAL (KIND=nag_wp) arrayInput
On entry: the ith row must contain the covariates which are associated with the ith failure time given in T.
5:     LDZ – INTEGERInput
On entry: the first dimension of the array Z as declared in the (sub)program from which G12ZAF is called.
Constraint: LDZN.
6:     ISZM – INTEGER arrayInput
On entry: indicates which subset of covariates are to be included in the model.
The jth covariate is included in the model.
The jth covariate is excluded from the model and not referenced.
Constraint: ISZj0 and at least one value must be nonzero.
7:     IP – INTEGERInput
On entry: p, the number of covariates included in the model as indicated by ISZ.
Constraint: IP= the number of nonzero values of ISZ.
8:     TN – REAL (KIND=nag_wp) arrayInput
On entry: the vector of n failure censoring times.
9:     ICN – INTEGER arrayInput
On entry: the status of the individual at time t given in T.
Indicates that the ith individual has failed at time Ti.
Indicates that the ith individual has been censored at time Ti.
Constraint: ICi=0 or 1, for i=1,2,,N.
10:   ISI* – INTEGER arrayInput
Note: the dimension of the array ISI must be at least N if NS>0, and at least 1 otherwise.
On entry: if NS>0, the stratum indicators which also allow data points to be excluded from the analysis.
If NS=0, ISI is not referenced.
Indicates that the ith data point is in the kth stratum, where k=1,2,,NS.
Indicates that the ith data point is omitted from the analysis.
Constraint: if NS>0, 0ISIiNS, for i=1,2,,N.
11:   NUM – INTEGEROutput
On exit: the number of values in the combined risk sets.
12:   IXSMXN – INTEGER arrayOutput
On exit: the factor giving the risk sets/strata for the data in X and ID.
If NS=0 or 1, IXSi=l for members of the lth risk set.
If NS>1, IXSi=j-1×ND+l for the observations in the lth risk set for the jth strata.
13:   NXS – INTEGEROutput
On exit: the number of levels for the risk sets/strata factor given in IXS.
14:   XMXNIP – REAL (KIND=nag_wp) arrayOutput
On exit: the first NUM rows contain the values of the covariates for the members of the risk sets.
15:   MXN – INTEGERInput
On entry: the first dimension of the array X and the dimension of the arrays IXS and ID as declared in the (sub)program from which G12ZAF is called.
Constraint: MXN must be sufficiently large for the arrays to contain the expanded risk sets. The size will depend on the pattern of failures times and censored times. The minimum value will be returned in NUM unless the routine exits with IFAIL=1 or 2.
16:   IDMXN – INTEGER arrayOutput
On exit: indicates if the member of the risk set given in X failed.
IDi=1 if the member of the risk set failed at the time defining the risk set and IDi=0 otherwise.
17:   ND – INTEGEROutput
On exit: the number of distinct failure times, i.e., the number of risk sets.
18:   TPN – REAL (KIND=nag_wp) arrayOutput
On exit: TPi contains the ith distinct failure time, for i=1,2,,ND.
19:   IRSN – INTEGER arrayOutput
On exit: indicates rows in X and elements in IXS and ID corresponding to the risk sets. The first risk set corresponding to failure time TP1 is given by rows 1 to IRS1. The lth risk set is given by rows IRSl-1+1 to IRSl, for l=1,2,,ND.
20:   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:
On entry,M<1,
On entry,ISZi<0 for some i,
orthe value of IP is incompatible with ISZ,
orICi1 or 0.
orNS>0 and ISIi<0,
orNS>1 and ISIi>NS.
MXN is too small, the minimum value is returned in NUM.
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

Not applicable.

9  Further Comments

When there are strata present, i.e., NS>1, not all the NXS groups may be present.

10  Example

The data are the remission times for two groups of leukemia patients (see page 242 of Gross and Clark (1975)). A dummy variable indicates which group they come from. The risk sets are computed using G12ZAF and the Cox's proportional hazard model is fitted using G11CAF.

10.1  Program Text

Program Text (g12zafe.f90)

10.2  Program Data

Program Data (g12zafe.d)

10.3  Program Results

Program Results (g12zafe.r)

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

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