Skip to content
Prev 161640 / 398500 Next

coxph diagnostics plot for shape of hazard function?

Basically - yes you can.  There are a few caveats:
    1. As a computational shortcut cox.zph assumes that var(X) is approximately 
constant over time, where X is the matrix of covariates.  (Improving this has 
been on my to do list for some time). I have found this to be almost always 
true, but if you have a data set where e.g. everyone in treatment 1 is crossed 
over at 6 months, then you can get odd results for that covariate.  I've run 
across 2-3 such data sets in 10+ years.

    2. The spline curve on the plot is "for the eye".  You can certainly use 
other smoothings, fit a line, etc.  Often you can find a simpler fit.
    	zpfit <- cox.zph(mycoxfit, transform='identity')
    	plot(zpfit$x, zpfit$y[,1], xlab='Time')  #look at variable 1
    	lines(lowess(zpfit$x, zpfit$y[,1]), col=2)
    	abline( lm(zpfit$y[,1] ~zpfit$x), col=3)
    	
    	plot(zpfit$x, zpfit$y[,1], log='x') #same as transform=log 
    	
    	etc.
    	
Sometimes the regression spline fit, the default for cox.zph, puts an extra 
"hook" on the end of the curve, somewhat like polynomials will.  
    	
    	Terry T.