[R] how to check linearity in Cox regression

Terry Therneau therneau at mayo.edu
Mon May 12 20:05:20 CEST 2008


  Use pspline within a Cox model.  It includes a fairly general test for 
nonlinearity, that is similar to GAM models.
	Terry Therneau


> coxph(Surv(time, status) ~ ph.ecog + pspline(age), lung)
Call:
coxph(formula = Surv(time, status) ~ ph.ecog + pspline(age), 
    data = lung)

                     coef   se(coef) se2     Chisq DF   p      
ph.ecog              0.4505 0.11766  0.11723 14.66 1.00 0.00013
pspline(age), linear 0.0112 0.00927  0.00927  1.45 1.00 0.23000
pspline(age), nonlin                          2.96 3.08 0.41000

Iterations: 4 outer, 10 Newton-Raphson
     Theta= 0.797 
Degrees of freedom for terms= 1.0 4.1 
Likelihood ratio test=22.7  on 5.07 df, p=0.000412
  n=227 (1 observation deleted due to missingness)



More information about the R-help mailing list