[R] how to check linearity in Cox regression

Terry Therneau therneau at mayo.edu
Wed Nov 26 15:42:37 CET 2008


> On examining non-linearity of Cox coefficients with penalized splines -  I
> have not been able to dig up a completely clear description of the test
> performed in R or S-plus.

 One "iron clad" way to test is to fit a model that has the variable of interest 
"x" as a linear term, then a second model with splines, and do a likelihood 
ratio test with 2*(difference in log-likelihood) on (difference in df) degrees 
of freedom.  With a penalized model this test is conservative: the chi-square is 
not quite the right distribution, the true dist has the same mean but smaller 
variance.

 The pspline function uses an evenly spaced set of symmetric basis functions.  A 
neat consequence of this is that the Wald test for linear vs 'more general' is a 
test that the coefficients of the spline terms fall in a linear series.  That 
is, a linear trend test on the coefficients.  This is what coxph does.  As with 
the LR test, the chi-square dist is conservative.  I have not worked at putting 
in the more correct distribution.  See Eilers and Marx, Statistical Science 
1986.
 
 > And what is the null for the non-linear test?

The linear test is "is a linear better than nothing", the non-linear one is a 
sequential test "is the non-linear better than the linear".  The second test of 
course depends on the total number of df you allowed for the pspline fit.  As a 
silly example adding "+ pspline(x, df=200)" would likely show that the nonlinear 
term was not a significant addition, i.e., not worth 199 more degrees of 
freedom.

	Terry Therneau



More information about the R-help mailing list