hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_surviv_coxmodel (g12ba)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

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

Syntax

[dev, b, se, sc, covar, res, nd, tp, sur, ifail] = g12ba(offset, ns, z, isz, t, ic, omega, isi, b, ndmax, tol, maxit, iprint, 'n', n, 'm', m, 'ip', ip)
[dev, b, se, sc, covar, res, nd, tp, sur, ifail] = nag_surviv_coxmodel(offset, ns, z, isz, t, ic, omega, isi, b, ndmax, tol, maxit, iprint, 'n', n, 'm', m, 'ip', ip)

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 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 (see Cox (1972)) λt,z is of the form:
λt,z=λ0texpzTβ+ω  
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 nd<n distinct failure times, t1<<tnd such that di individuals fail at ti, it follows that the marginal likelihood for β is well approximated (see Kalbfleisch and Prentice (1980)) by:
L=i=1ndexpsiTβ+ωi lRtiexpzlTβ+ωldi (1)
where si is the sum of the covariates of individuals observed to fail at ti and Rti is the set of individuals at risk just prior to ti, that is, it is all individuals that fail or are censored at time ti along with all individuals that survive beyond time ti. 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:
Ujβ= lnL βj =i=1ndsji-diαjiβ=0 (2)
for j=1,2,,p, where sji is the jth element in the vector si and
αjiβ=lRtizjlexpzlTβ+ωl lRtiexpzlTβ+ωl .  
Similarly,
Ihjβ=- 2lnL βhβj =i=1nddiγhji (3)
where
γhji=lRti zhlzjlexpzlTβ+ωl lRtiexpzlTβ+ωl -αhiβαjiβ,   h,j= 1,,p.  
Ujβ is the jth component of a score vector and Ihjβ is the h,j element of the observed information matrix Iβ whose inverse Iβ-1=Ihjβ -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 λ0t varies across ν strata, where the number of individuals in the kth stratum is nk, for k=1,2,,ν with n=k=1νnk, then rather than maximizing (1) to obtain β^, the following marginal likelihood is maximized:
L=k=1νLk, (4)
where Lk is the contribution to likelihood for the nk observations in the kth 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 ti, is estimated as exp-H^ti, where
H^ti=tjti dilRtjexpzlTβ^+ωl , (5)
where di is the number of failures at time ti. The residual for the lth observation is computed as:
rtl= H^tlexpzlTβ^+ωl  
where H^tl=H^ti,titl<ti+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.

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

Parameters

Compulsory Input Parameters

1:     offset – string (length ≥ 1)
Indicates if an offset is to be used.
offset='Y'
An offset must be included in omega.
offset='N'
No offset is included in the model.
Constraint: offset='Y' or 'N'.
2:     ns int64int32nag_int scalar
The number of strata. If ns>0 then the stratum for each observation must be supplied in isi.
Constraint: ns0.
3:     zldzm – double array
ldz, the first dimension of the array, must satisfy the constraint ldzn.
The ith row must contain the covariates which are associated with the ith failure time given in t.
4:     iszm int64int32nag_int array
Indicates which subset of covariates is to be included in the model.
iszj1
The jth covariate is included in the model.
iszj=0
The jth covariate is excluded from the model and not referenced.
Constraint: iszj0 and at least one and at most n0-1 elements of isz must be nonzero where n0 is the number of observations excluding any with zero value of isi.
5:     tn – double array
The vector of n failure censoring times.
6:     icn int64int32nag_int array
The status of the individual at time t given in t.
ici=0
The ith individual has failed at time ti.
ici=1
The ith individual has been censored at time ti.
Constraint: ici=0 or 1, for i=1,2,,n.
7:     omega: – double array
The dimension of the array omega must be at least n if offset='Y', and at least 1 otherwise
If offset='Y', the offset, ωi, for i=1,2,,n. Otherwise omega is not referenced.
8:     isi: int64int32nag_int array
The dimension of the array isi must be at least n if ns>0, and at least 1 otherwise
If ns>0, the stratum indicators which also allow data points to be excluded from the analysis.
If ns=0, isi is not referenced.
isii=k
The ith data point is in the kth stratum, where k=1,2,,ns.
isii=0
The ith data point is omitted from the analysis.
Constraint: if ns>0, 0isiins and more than ip values of isii>0, for i=1,2,,n.
9:     bip – double array
Suggested value: in many cases an initial value of zero for bj may be used. For other suggestions see Further Comments.
Initial estimates of the covariate coefficient arguments β. bj must contain the initial estimate of the coefficient of the covariate in z corresponding to the jth nonzero value of isz.
10:   ndmax int64int32nag_int scalar
The dimension of the array tp and the first dimension of the array sur.
Constraint: ndmaxthe number of distinct failure times. This is returned in ​nd.
11:   tol – double scalar
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: tol10×machine precision.
12:   maxit int64int32nag_int scalar
The maximum number of iterations to be used for computing the estimates. If maxit 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: maxit0.
13:   iprint int64int32nag_int scalar
Indicates if the printing of information on the iterations is required.
iprint0
No printing.
iprint1
The deviance and the current estimates are printed every iprint iterations. When printing occurs the output is directed to the current advisory message unit (see nag_file_set_unit_advisory (x04ab)).

Optional Input Parameters

1:     n int64int32nag_int scalar
Default: the dimension of the arrays t, ic and the first dimension of the array z. (An error is raised if these dimensions are not equal.)
n, the number of data points.
Constraint: n2.
2:     m int64int32nag_int scalar
Default: the dimension of the array isz and the second dimension of the array z. (An error is raised if these dimensions are not equal.)
The number of covariates in array z.
Constraint: m1.
3:     ip int64int32nag_int scalar
Default: the dimension of the array b.
The number of covariates included in the model as indicated by isz.
Constraints:
  • ip1;
  • ip=​ number of nonzero values of ​isz.

Output Parameters

1:     dev – double scalar
The deviance, that is -2×(maximized log marginal likelihood).
2:     bip – double array
Suggested value: in many cases an initial value of zero for bj may be used. For other suggestions see Further Comments.
bj contains the estimate β^i, the coefficient of the covariate stored in the ith column of z where i is the jth nonzero value in the array isz.
3:     seip – double array
sej is the asymptotic standard error of the estimate contained in bj and score function in scj, for j=1,2,,ip.
4:     scip – double array
scj is the value of the score function, Ujβ, for the estimate contained in bj.
5:     covarip×ip+1/2 – double array
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 bi and bj, ji, is stored in covarjj-1/2+i .
6:     resn – double array
The residuals, rtl, for l=1,2,,n.
7:     nd int64int32nag_int scalar
The number of distinct failure times.
8:     tpndmax – double array
tpi contains the ith distinct failure time, for i=1,2,,nd.
9:     surndmax: – double array
The second dimension of the array sur will be maxns,1.
If ns=0, suri1 contains the estimated survival function for the ith distinct failure time.
If ns>0, surik contains the estimated survival function for the ith distinct failure time in the kth stratum.
10:   ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

   ifail=1
On entry,offset'Y' or 'N',
orm<1,
orn<2,
orns<0,
orip<1,
orldz<n,
ortol<10×machine precision,
ormaxit<0.
   ifail=2
On entry,iszi<0 for some i,
orthe value of ip is incompatible with isz,
orici1 or 0.
orisii<0 or isii>ns,
ornumber of values of iszi>0 is greater than or equal to n0, the number of observations excluding any with isii=0,
orall observations are censored, i.e., ici=1 for all i,
orndmax is too small.
   ifail=3
The matrix of second partial derivatives is singular. Try different starting values or include fewer covariates.
   ifail=4
Overflow has been detected. Try using different starting values.
W  ifail=5
Convergence has not been achieved in maxit iterations. The progress toward convergence can be examined by using a nonzero value of iprint. Any non-convergence may be due to a linear combination of covariates being monotonic with time.
Full results are returned.
W  ifail=6
In the current iteration 10 step halvings have been performed without decreasing the deviance from the previous iteration. Convergence is assumed.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

The accuracy is specified by tol.

Further Comments

nag_surviv_coxmodel (g12ba) 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βTzi or there may be non-convergence. Reasonable estimates can often be obtained by fitting an exponential model using nag_correg_glm_poisson (g02gc).

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. 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.
function g12ba_example


fprintf('g12ba example results\n\n');

% Data
n = 42;
m = 1;
z          = zeros(n,m);
ic         = zeros(n,1,'int64');
ic(31:end) = 1;
z(22:end)  = 1;
isz        = [int64(1)];

t = [ 1;      1;      2;      2;      3;      4;      4;
      5;      5;      8;      8;      8;      8;     11;
     11;     12;     12;     15;     17;     22;     23;
      6;      6;      6;      7;     10;     13;     16;
     22;     23;      6;      9;     10;     11;     17;
     19;     20;     25;     32;     32;     34;     35];

% Parameters for Cox proportional hazards model
offset = 'No-offset';
ns     = int64(0);
omega  = [0];
isi    = [int64(0)];
b(1)   = [0];
ndmax  = int64(n);
tol    = 5e-05;
maxit  = int64(20);
iprint = int64(0);

% Fit Cox proportional hazards model
[dev, b, se, sc, covar, res, nd, tp, sur, ifail] = ...
  g12ba( ...
         offset, ns, z, isz, t, ic, omega, isi, b, ndmax, tol, maxit, iprint);

% Display results
ns = max(ns,1);
fprintf(' Parameter      Estimate       Standard Error\n\n');
ivar = [1:m]';
fprintf('%6d%18.4f%18.4f\n',[ivar b se]');
fprintf('\n Deviance = %13.3e\n\n', dev);
fprintf('    Time     Survivor Function\n\n');
results = [tp(1:nd) sur(1:nd,1:ns)]; 
fprintf('%7.0f%16.4f\n', results');


g12ba example results

 Parameter      Estimate       Standard Error

     1           -1.5092            0.4096

 Deviance =     1.728e+02

    Time     Survivor Function

      1          0.9640
      2          0.9264
      3          0.9065
      4          0.8661
      5          0.8235
      6          0.7566
      7          0.7344
      8          0.6506
     10          0.6241
     11          0.5724
     12          0.5135
     13          0.4785
     15          0.4447
     16          0.4078
     17          0.3727
     22          0.2859
     23          0.1908

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

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