Description

goodness of fit test for a coxph object

Usage

1
2
3
4

Arguments

x

An object of class coxph

...

Additional arguments (not implemented)

G

Number of groups into which to divide risk score.
If G=NULL (the default), uses closest integer to

G = max(2, min(10, ne/40))

where ne is the number of events overall.

Details

In order to verify the overall goodness of fit,
the risk score r[i] for each observation i is given by

r[i] = B.X[i]

where B is the vector of fitted coefficients
and X[i] is the vector of predictor variables for
observation i.
This risk score is then sorted and 'lumped' into
a grouping variable with G groups,
(containing approximately equal numbers of observations).
The number of observed (e) and expected (exp) events in
each group are used to generate a Z statistic for each group,
which is assumed to follow a normal distribution with
Z \sim N(0,1).
The indicator variable indicG is added to the
original model and the two models are compared to determine the
improvement in fit via the likelihood ratio test.

Value

A list with elements:

groups

A data.table with one row per group G.
The columns are

n

Number of observations

e

Number of events

exp

Number of events expected. This is

exp = ∑ e_i - M_i

where e_i are the events and
M_i are the martingale residuals
for each observation i

z

Z score, calculated as

Z = (e - exp) / exp^0.5

p

p-value for Z, which is

p = 2 * pnorm(-|z|)

where pnorm is the normal distribution function
with mean 0 and standard deviation 1
and |z| is the absolute value.

lrTest

Likelihood-ratio test.
Tests the improvement in log-likelihood with addition
of an indicator variable with G-1 groups.
This is done with survival:::anova.coxph.
The test is distributed as chi-square with G-1 degrees of freedom

Note

The choice of G is somewhat arbitrary but rarely should
be > 10.
As illustrated in the example, a larger value for
G makes the Z test for each group more likely to be significant.
This does not affect the significance of adding the
indicator variable indicG to the original model.

The Z score is chosen for simplicity, as for large sample sizes
the Poisson distribution approaches the normal. Strictly speaking,
the Poisson would be more appropriate for e and exp as
per Counting Theory.
The Z score may be somewhat conservative as the expected events
are calculated using the martingale residuals from the overall model,
rather than by group. This is likely to bring the expected events
closer to the observed events.

This test is similar to the Hosmer-Lemeshow test for logistic regression.

References

Default value for G as per:
May S, Hosmer DW 2004.
A cautionary note on the use of the Gronnesby and Borgan
goodness-of-fit test for the Cox proportional hazards model.
Lifetime Data Analysis10(3):283–91.
Springer (paywall)