[R] Schoenfeld Residuals with tied data

Terry Therneau therneau at mayo.edu
Tue Jun 16 15:08:04 CEST 2009


-- begin included message ----
Thank you for the reply. I really appreciate it.

I calculated the Scoenfeld residual per event and my results are the
following:

	fin	                       age	race
17	-0.33942334	-2.072218727	0.29024804
20	0.394600944	5.303968774	0.517689472
25	0.488184603	-1.438140647	-0.359535162
25	-0.511815397	-1.438140647	-0.359535162

However, the results from R are shown as below:

	fin	                     age	race
17	-0.3394233	-2.072219	0.290248
20	0.3946009	5.303969	             0.5176895
25	0.4724112	-1.615875	-0.4039688
25	-0.5275888	-1.615875	-0.4039688

--------  end inclusion -------

Bessy,
  By default the coxph function uses the Efron approximation for ties (more 
accurate than the Breslow approx).  You are computing the Schoenfeld residuals 
using the betas from coxph (Efron), and then applying a Breslow formula.  I can 
reproduce your results by forcing the same computation in R:
  
  > fit1 <- coxph(Surv(week, arrest) ~ fin + age + race, bessdata)
  > fit2 <- coxph(Surv(week, arrest) ~ fin + age + race, bessdata,
  	             init=coef(fit1), iter=0, method='breslow')
  > resid(fit2, 'schoen')
    	     fin       age       race
     17 -0.3394233 -2.072219  0.2902480
     20  0.3946009  5.303969  0.5176895
     25  0.4881846 -1.438141 -0.3595352
     25 -0.5118154 -1.438141 -0.3595352

 The Efron approximation is simple for computation of beta, but a bit more 
subtle when doing the residuals from the fit (but still not hard).  You can find 
a detailed worked example in E.1.2 of the book by Therneau and Grambsch.
 
  If you had run the phreg procedure in SAS you would not have had this problem: 
it contains exactly the same incorrect computation.  (Appendix E of the book 
contains a set of very small data sets where the correct answers can be worked 
out in closed form.  SAS gets all of the Breslow approx computations correct and 
about 1/2 of the Efron ones.  R passes all the tests.)
  
  	Terry Therneau




More information about the R-help mailing list