naginterfaces.library.surviv.coxmodel¶

naginterfaces.library.surviv.coxmodel(ns, z, isz, t, ic, isi, b, ndmax, omega=None, tol=1.1102230246251565e-14, maxit=1000, iprint=0, io_manager=None)[source]

coxmodel returns parameter estimates and other statistics that are associated with the Cox proportional hazards model for fixed covariates.

For full information please refer to the NAG Library document for g12ba

https://www.nag.com/numeric/nl/nagdoc_28.6/flhtml/g12/g12baf.html

Parameters
nsint

The number of strata. If then the stratum for each observation must be supplied in .

zfloat, array-like, shape

The th row must contain the covariates which are associated with the th failure time given in .

iszint, array-like, shape

Indicates which subset of covariates is 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.

tfloat, array-like, shape

The vector of failure censoring times.

icint, array-like, shape

The status of the individual at time given in .

The th individual has failed at time .

The th individual has been censored at time .

isiint, array-like, shape

Note: the required length for this argument is determined as follows: if : ; otherwise: .

If , the stratum indicators which also allow data points to be excluded from the analysis.

If , is not referenced.

The th data point is in the th stratum, where .

The th data point is omitted from the analysis.

bfloat, array-like, shape

Initial estimates of the covariate coefficient parameters . must contain the initial estimate of the coefficient of the covariate in corresponding to the th nonzero value of .

Suggested value: in many cases an initial value of zero for may be used. For other suggestions see Further Comments.

ndmaxint

The dimension of the array .

The first dimension of the array .

omegaNone or float, array-like, shape , optional

If , the offset, , for . Otherwise is not referenced.

tolfloat, optional

Indicates the accuracy required for the estimation. Convergence is assumed when the decrease in deviance is less than . This corresponds approximately to an absolute precision if the deviance is small and a relative precision if the deviance is large.

maxitint, optional

The maximum number of iterations to be used for computing the estimates. If is set to then the standard errors, score functions, variance-covariance matrix and the survival function are computed for the input value of in but is not updated.

iprintint, optional

Indicates if the printing of information on the iterations is required.

No printing.

The deviance and the current estimates are printed every iterations. When printing occurs the output is directed to the file object associated with the advisory I/O unit (see FileObjManager).

io_managerFileObjManager, optional

Manager for I/O in this routine.

Returns
devfloat

The deviance, that is (maximized log marginal likelihood).

bfloat, ndarray, shape

contains the estimate , the coefficient of the covariate stored in the th column of where is the th nonzero value in the array .

sefloat, ndarray, shape

is the asymptotic standard error of the estimate contained in and score function in , for .

scfloat, ndarray, shape

is the value of the score function, , for the estimate contained in .

covfloat, ndarray, shape

The variance-covariance matrix of the parameter estimates in stored in packed form by column, i.e., the covariance between the parameter estimates given in and , , is stored in .

resfloat, ndarray, shape

The residuals, , for .

ndint

The number of distinct failure times.

tpfloat, ndarray, shape

contains the th distinct failure time, for .

surfloat, ndarray, shape

If , contains the estimated survival function for the th distinct failure time.

If , contains the estimated survival function for the th distinct failure time in the th stratum.

Raises
NagValueError
(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, there are not values of .

(errno )

On entry, and .

Constraint: .

(errno )

On entry too few observations included in model.

(errno )

On entry, , and .

Constraint: .

(errno )

On entry, and .

Constraint: or .

(errno )

On entry, and minimum value for .

Constraint: of distinct failure times.

(errno )

All observations are censored.

(errno )

The matrix of second partial derivative is singular.

(errno )

Overflow has been detected in the calculations.

Warns
NagAlgorithmicWarning
(errno )

Convergence not achieved in iterations.

(errno )

Too many step halvings required.

Notes

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 , for , be the failure time or censored time for the th observation with the vector of covariates . 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 (see Cox (1972)) is of the form:

where is the base-line hazard function, an unspecified function of time, is a vector of unknown parameters and is a known offset.

Assuming there are ties in the failure times giving distinct failure times, such that individuals fail at , it follows that the marginal likelihood for is well approximated (see Kalbfleisch and Prentice (1980)) by:

where is the sum of the covariates of individuals observed to fail at and is the set of individuals at risk just prior to , that is, it is all individuals that fail or are censored at time along with all individuals that survive beyond time . 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:

for , where is the th element in the vector and

Similarly,

where

is the th component of a score vector and is the element of the observed information matrix whose inverse 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 ’s will be infinite.

If varies across strata, where the number of individuals in the th stratum is , for with , then rather than maximizing (1) to obtain , the following marginal likelihood is maximized:

where is the contribution to likelihood for the observations in the 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 .

The base-line survivor function associated with a failure time , is estimated as , where

where is the number of failures at time . The residual for the th observation is computed as:

where . The deviance is defined as (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 -distribution; or, the asymptotic normality of the parameter estimates can be used to form 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 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