NAG Library Routine Document
G12ZAF creates the risk sets associated with the Cox proportional hazards model for fixed covariates.
|SUBROUTINE G12ZAF (
||N, M, NS, Z, LDZ, ISZ, IP, T, IC, ISI, NUM, IXS, NXS, X, MXN, ID, ND, TP, IRS, IFAIL)
||N, M, NS, LDZ, ISZ(M), IP, IC(N), ISI(*), NUM, IXS(MXN), NXS, MXN, ID(MXN), ND, IRS(N), IFAIL
||Z(LDZ,M), T(N), X(MXN,IP), TP(N)
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.
, be the failure time or censored time for the
th observation with the vector of
It is assumed that censoring and failure mechanisms are independent. The hazard function,
, is the probability that an individual with covariates
fails at time
given that the individual survived up to time
. In the Cox proportional hazards model,
is of the form
is the base-line hazard function, an unspecified function of time, and
is a vector of unknown parameters. As
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 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
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
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
- 1: N – INTEGERInput
On entry: , the number of data points.
- 2: M – INTEGERInput
: the number of covariates in array Z
- 3: NS – INTEGERInput
: the number of strata. If
then the stratum for each observation must be supplied in ISI
- 4: Z(LDZ,M) – REAL (KIND=nag_wp) arrayInput
th row must contain the covariates which are associated with the
th failure time given in T
- 5: LDZ – INTEGERInput
: the first dimension of the array Z
as declared in the (sub)program from which G12ZAF is called.
- 6: ISZ(M) – INTEGER arrayInput
: indicates which subset of covariates are to be included in the model.
- The th covariate is included in the model.
- The th covariate is excluded from the model and not referenced.
and at least one value must be nonzero.
- 7: IP – INTEGERInput
, the number of covariates included in the model as indicated by ISZ
the number of nonzero values of ISZ
- 8: T(N) – REAL (KIND=nag_wp) arrayInput
On entry: the vector of failure censoring times.
- 9: IC(N) – INTEGER arrayInput
: the status of the individual at time
given in T
- Indicates that the th individual has failed at time .
- Indicates that the th individual has been censored at time .
or , for .
- 10: ISI() – INTEGER arrayInput
the dimension of the array ISI
must be at least
, and at least
, the stratum indicators which also allow data points to be excluded from the analysis.
is not referenced.
- Indicates that the th data point is in the th stratum, where .
- Indicates that the th data point is omitted from the analysis.
if , , for .
- 11: NUM – INTEGEROutput
On exit: the number of values in the combined risk sets.
- 12: IXS(MXN) – INTEGER arrayOutput
: the factor giving the risk sets/strata for the data in X
If or , for members of the th risk set.
If , for the observations in the th risk set for the th strata.
- 13: NXS – INTEGEROutput
: the number of levels for the risk sets/strata factor given in IXS
- 14: X(MXN,IP) – REAL (KIND=nag_wp) arrayOutput
: the first NUM
rows contain the values of the covariates for the members of the risk sets.
- 15: MXN – INTEGERInput
: the first dimension of the array X
and the dimension of the arrays IXS
as declared in the (sub)program from which G12ZAF is called.
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
- 16: ID(MXN) – INTEGER arrayOutput
: indicates if the member of the risk set given in X
if the member of the risk set failed at the time defining the risk set and otherwise.
- 17: ND – INTEGEROutput
On exit: the number of distinct failure times, i.e., the number of risk sets.
- 18: TP(N) – REAL (KIND=nag_wp) arrayOutput
On exit: contains the th distinct failure time, for .
- 19: IRS(N) – INTEGER arrayOutput
: indicates rows in X
and elements in IXS
corresponding to the risk sets. The first risk set corresponding to failure time
is given by rows
th risk set is given by rows
- 20: IFAIL – INTEGERInput/Output
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.
unless the routine detects an error or a warning has been flagged (see Section 6
6 Error Indicators and Warnings
If on entry
, explanatory error messages are output on the current error message unit (as defined by X04AAF
Errors or warnings detected by the routine:
|On entry,|| for some ,|
|or||the value of IP is incompatible with ISZ,|
|or|| or .|
|or|| and ,|
|or|| and .|
is too small, the minimum value is returned in NUM
When there are strata present, i.e.,
, not all the NXS
groups may be present.
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
9.1 Program Text
Program Text (g12zafe.f90)
9.2 Program Data
Program Data (g12zafe.d)
9.3 Program Results
Program Results (g12zafe.r)