[R] how to check linearity in Cox regression

From: Terry Therneau <therneau_at_mayo.edu>
Date: Wed, 26 Nov 2008 08:42:37 -0600 (CST)

> 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

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 26 Nov 2008 - 14:46:20 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 26 Nov 2008 - 15:30:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive