nag_surviv_cox_model (g12bac) (PDF version)
g12 Chapter Contents
g12 Chapter Introduction
NAG Library Manual

NAG Library Function Document

nag_surviv_cox_model (g12bac)

 Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_surviv_cox_model (g12bac) returns parameter estimates and other statistics that are associated with the Cox proportional hazards model for fixed covariates.

2  Specification

#include <nag.h>
#include <nagg12.h>
void  nag_surviv_cox_model (Integer n, Integer m, Integer ns, const double z[], Integer tdz, const Integer sz[], Integer ip, const double t[], const Integer ic[], const double omega[], const Integer isi[], double *dev, double b[], double se[], double sc[], double cov[], double res[], Integer *nd, double tp[], double sur[], Integer tdsur, Integer ndmax, double tol, Integer max_iter, Integer iprint, const char *outfile, NagError *fail)

3  Description

The proportional hazard model 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 t i , for i=1,2,,n be the failure time or censored time for the i th observation with the vector of p  covariates z i . 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 (Cox (1972)) λ t,z  is of the form:
λ t,z = λ 0 t exp zT β + ω  
where λ 0  is the base-line hazard function, an unspecified function of time, β  is a vector of unknown arguments and ω  is a known offset.
Assuming there are ties in the failure times giving n d < n  distinct failure times, t 1 < < t n d  such that d i  individuals fail at t i , it follows that the marginal likelihood for β  is well approximated (see Kalbfleisch and Prentice (1980)) by:
L = i=1 n d exp siT β + ω i l R t i exp zlT β + ω l d i (1)
where s i  is the sum of the covariates of individuals observed to fail at t i  and R t i  is the set of individuals at risk just prior to t i , that is it is all individuals that fail or are censored at time t i  along with all individuals that survive beyond time t i . The maximum likelihood estimates (MLEs) of β , given by β ^ , are obtained by maximizing (1) using a Newton–Raphson iteration technique that includes step halving and utilizes the first and second partial derivatives of (1) which are given by equations (2) and (3) below:
U j β = lnL βj = i=1 n d s ji - d i α ji β = 0 (2)
for j = 1 , , p , where s ji  is the j th element in the vector s i  and
α ji β = l R t i z jl exp zlT β + ω l l R t i exp zlT β + ω l .  
Similarly,
I hj β = - 2lnL βh βj = i=1 n d d i γ hji (3)
where
γ hji = l R t i z hl z jl exp zlT β + ω l l R t i exp zlT β + ω l - α hi β α ji β h , j = 1 , , p .  
U j β  is the j th component of a score vector and I hj β  is the h,j  element of the observed information matrix I β  whose inverse I β -1 = I hj β -1  gives the variance-covariance matrix of β .
It should be noted that if a covariate or a linear combination of covariates is monotonically increasing or decreasing with time then one or more of the β j 's will be infinite.
If λ 0 t  varies across ν  strata, where the number of individuals in the k th stratum is n k , k = 1 , , ν  with n = k=1 ν n k , then rather than maximizing (1) to obtain β ^ , the following marginal likelihood is maximized:
L = k=1 ν L k , (4)
where L k  is the contribution to likelihood for the n k  observations in the k th stratum treated as a single sample in (1). When strata are included the covariate coefficients are constant across strata but there is a different base-line hazard function λ 0 .
The base-line survivor function associated with a failure time t i , is estimated as exp - H ^ t i , where
H ^ t i = t j t i d i l R t j exp zlT β ^ + ω l , (5)
where d i  is the number of failures at time t i . The residual for the l th observation is computed as:
r t l = H ^ t l exp - zlT β ^ + ω l  
where H ^ t l = H ^ t i , t i t l < t i+1 . The deviance is defined as -2 × (logarithm of marginal likelihood). There are two ways to test whether individual covariates are significant: the differences between the deviances of nested models can be compared with the appropriate χ 2 -distribution; or, the asymptotic normality of the parameter estimates can be used to form z  tests by dividing the estimates by their standard errors or the score function for the model under the null hypothesis can be used to form z  tests.

4  References

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
Kalbfleisch J D and Prentice R L (1980) The Statistical Analysis of Failure Time Data Wiley

5  Arguments

1:     n IntegerInput
On entry: the number of data points, n .
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:     z[n×tdz] const doubleInput
Note: the i,jth element of the matrix Z is stored in z[i-1×tdz+j-1].
On entry: the i th row must contain the covariates which are associated with the i th failure time given in t.
5:     tdz IntegerInput
On entry: the stride separating matrix column elements in the array z.
Constraint: tdzm .
6:     sz[m] const IntegerInput
On entry: indicates which subset of covariates is to be included in the model.
sz[i-1] 1
The j th covariate is included in the model.
sz[i-1] = 0
The j th covariate is excluded from the model and not referenced.
Constraints:
  • sz[j-1] 0 ;
  • At least one and at most n 0 - 1  elements of sz must be nonzero where n 0  is the number of observations excluding any with zero value of isi.
7:     ip IntegerInput
On entry: the number of covariates included in the model as indicated by sz.
Constraint: ip=  number of nonzero values of sz.
8:     t[n] const doubleInput
On entry: the vector of n  failure censoring times.
9:     ic[n] const IntegerInput
On entry: the status of the individual at time t  given in t.
ic[i-1] = 0
Indicates that the i th individual has failed at time t[i-1] .
ic[i-1] = 1
Indicates that the i th individual has been censored at time t[i-1] .
Constraint: ic[i-1] = 0 ​ or ​ 1 , for i=1,2,,n.
10:   omega[n] const doubleInput
On entry: if an offset is required then omega must contain the value of ω i , for i=1,2,,n. Otherwise omega must be set NULL.
11:   isi[×] const IntegerInput
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 and may be NULL.
isi[i-1] = k
Indicates that the i th data point is in the k th stratum, for k=1,2,,ns.
isi[i-1] = 0
Indicates that the i th data point is omitted from the analysis.
Constraint: if ns>0 , 0 isi[i-1] ns , and more than ip values of isi[i-1] > 0 , for i=1,2,,n.
12:   dev double *Output
On exit: the deviance, that is -2 × (maximized log marginal likelihood).
13:   b[ip] doubleInput/Output
On entry: initial estimates of the covariate coefficient arguments β . b[j-1]  must contain the initial estimate of the coefficient of the covariate in z corresponding to the j th nonzero value of sz.
Suggested value: In many cases an initial value of zero for b[j-1]  may be used. For other suggestions see Section 9.
On exit: b[j-1]  contains the estimate β ^ i , the coefficient of the covariate stored in the i th column of z where i  is the j th nonzero value in the array sz.
14:   se[ip] doubleOutput
On exit: se[j-1]  is the asymptotic standard error of the estimate contained in b[j-1]  and score function in sc[j-1]  for j = 1 , 2 , , ip .
15:   sc[ip] doubleOutput
On exit: sc[j-1]  is the value of the score function, U j β , for the estimate contained in b[j-1] .
16:   cov[ip×ip+1] doubleOutput
On exit: the variance-covariance matrix of the parameter estimates in b stored in packed form by column, i.e., the covariance between the parameter estimates given in b[i-1]  and b[j-1] , ji , is stored in cov j j-1 / 2 + i .
17:   res[n] doubleOutput
On exit: the residuals, r t l , l = 1 , 2 , , n .
18:   nd Integer *Output
On exit: the number of distinct failure times.
19:   tp[ndmax] doubleOutput
On exit: tp[i-1]  contains the i th distinct failure time, for i = 1 , 2 , , nd .
20:   sur[ndmax×tdsur] doubleOutput
Note: the i,jth element of the matrix is stored in sur[i-1×tdsur+j-1].
On exit: if ns=0 , sur i,1  contains the estimated survival function for the i th distinct failure time.
If ns>0 , sur i,k  contains the estimated survival function for the i th distinct failure time in the k th stratum.
21:   tdsur IntegerInput
On entry: the stride separating matrix column elements in the array sur.
Constraint: tdsur maxns,1 .
22:   ndmax IntegerInput
On entry: the second dimension of the array sur.
Constraint: ndmax  the number of distinct failure times. This is returned in nd.
23:   tol doubleInput
On entry: indicates the accuracy required for the estimation. Convergence is assumed when the decrease in deviance is less than tol × ( 1.0 + CurrentDeviance). This corresponds approximately to an absolute precision if the deviance is small and a relative precision if the deviance is large.
Constraint: tol 10 × machine precision .
24:   max_iter IntegerInput
On entry: the maximum number of iterations to be used for computing the estimates. If max_iter is set to 0 then the standard errors, score functions, variance-covariance matrix and the survival function are computed for the input value of β  in b but β  is not updated.
Constraint: max_iter0 .
25:   iprint IntegerInput
On entry: indicates if the printing of information on the iterations is required.
iprint0
There is no printing.
iprint1
The deviance and the current estimates are printed every iprint iterations.
26:   outfile const char *Input
On entry: the name of the file into which information is to be output. If outfile is set to NULL or to the string ‘stdout’, then the monitoring information is output to stdout.
27:   fail NagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

NE_2_INT_ARG_LT
On entry, tdsur=value  while ns=value . These arguments must satisfy tdsurns .
On entry, tdz=value  while m=value . These arguments must satisfy tdzm .
NE_ALLOC_FAIL
Dynamic memory allocation failed.
NE_ARRAY_CONS
The contents of array ic are not valid.
Constraint: not all values of ic can be 1.
NE_G12BA_CONV
Convergence has not been achieved in max_iter iterations. The progress towards convergence can be examined by using by setting iprint to 1 . Any non-convergence may be due to a linear combination of covariates being monotonic with time. Full results are returned.
NE_G12BA_DEV
In the current iteration 10 step halvings have been performed without decreasing the deviance from the previous iteration. Convergence is assumed.
NE_G12BA_MAT_SING
The matrix of second partial derivatives is singular. Try different starting values or include fewer covariates.
NE_G12BA_NDMAX
On entry, ndmax is =value  while the output value of nd=value .
Constraint: ndmaxnd .
NE_G12BA_OVERFLOW
Overflow has been detected. Try different starting values.
NE_G12BA_SZ_IP
On entry, ip=value  and the number of nonzero values of sz=value .
Constraint: ip=  the number of nonzero values of sz.
NE_G12BA_SZ_ISI
On entry, the number of values of sz[i] > 0  is value, n=value  and excluded observations with isi[i] = 0  is value.
Constraint: the number of values of nonzero sz must be less than n -  excluded observations.
NE_INT_ARG_LT
On entry, m=value.
Constraint: m1.
On entry, max_iter must not be less than 0: max_iter=value .
On entry, n=value.
Constraint: n2.
On entry, ns=value.
Constraint: ns0.
On entry, tdsur=value.
Constraint: tdsur1.
NE_INT_ARRAY_CONS
On entry, ic[value] = value.
Constraint: ic[value] = 0  or 1.
On entry, isi[value] = value.
Constraint: 0 isi[value] ns .
On entry, sz[value] = value.
Constraint: sz[value] 0 .
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
NE_NOT_APPEND_FILE
Cannot open file outfile for appending.
NE_NOT_CLOSE_FILE
Cannot close file outfile.
NE_REAL_MACH_PREC
On entry, tol=value , machine precision nag_machine_precision = value.
Constraint: tol 10.0 × machine precision.

7  Accuracy

The accuracy is specified by tol.

8  Parallelism and Performance

Not applicable.

9  Further Comments

nag_surviv_cox_model (g12bac) uses mean centering which involves subtracting the means from the covariables prior to computation of any statistics. This helps to minimize the effect of outlying observations and accelerates convergence.
If the initial estimates are poor then there may be a problem with overflow in calculating exp βT z i  or there may be non-convergence. Reasonable estimates can often be obtained by fitting an exponential model using nag_glm_poisson (g02gcc).

10  Example

The data are the remission times for two groups of leukemia patients (see Gross and Clark (1975) p242). A dummy variable indicates which group they come from. An initial estimate is computed using the exponential model and then the Cox proportional hazard model is fitted and parameter estimates and the survival function are printed.

10.1  Program Text

Program Text (g12bace.c)

10.2  Program Data

Program Data (g12bace.d)

10.3  Program Results

Program Results (g12bace.r)


nag_surviv_cox_model (g12bac) (PDF version)
g12 Chapter Contents
g12 Chapter Introduction
NAG Library Manual

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