2
$\begingroup$

I am using the survival package in R to run cox proportional hazards models. My question is about the plot.zph function.

This code

plot(zph[1], lwd = 2) +
  abline(0, 0, col = 1, lty = 3, lwd = 2) +
  abline(
    h = cox.ph.mod$coef[1],
    col = 3,
    lwd = 2,
    lty = 2
)

produces this plot: enter image description here

My question is just about the irregular spacing of the x-axis. The tick marks are not evenly spaced, the labeling is irregular, and the distance between tick marks seems off. For example the space between 32 and 35 appears larger than the space between 35 and 39. This doesn't seem to be just a me problem; the plots in this tutorial seem to have the same issue: http://www.sthda.com/english/wiki/cox-model-assumptions

I'm assuming this does not severely impact the interpretation of the plot, but I am curious a) why this is happening, b) if it's a problem or if it's by design, and c) if it impacts interpretation in any way.

Thanks!


$\endgroup$
1
  • $\begingroup$ I don't use R routinely -- I think it wonderful but I have a partner already -- but R enthusiasts are always underlining that all the code is accessible so that you can always work out what is going on! $\endgroup$
    – Nick Cox
    Commented Oct 26, 2022 at 14:04

1 Answer 1

4
$\begingroup$

This is by design. The transform argument to cox.zph() allows different transformations of the time axis. This is discussed in Chapter 6 of Therneau and Grambsch.

The default Kaplan-Meier ("km") choice transforms time to correspond to probabilities of survival.* You can choose instead to space evenly by observation times ("rank"), use the original time scale ("identity"), its log transformation ("log"), or any specific transformation you wish.

The Kaplan-Meier transformation is the default because it's less sensitive to censoring patterns than the rank transformation and it tends to spread residuals (calculated at event times) more evenly across the plot from left to right. For example, in a frequent situation with just a few individuals having events at late times, with an "identity" transformation you would have a lot of events bunched together at early times and events at very late times would visually overwhelm the display of the smoothed curve.

The transformations can affect the p-values returned by the test, as the test is effectively for a trend in scaled Schoenfeld residuals with respect to the transformed time axis. Therneau and Grambsch show how different choices for time transformation correspond to different tests that have been proposed for proportional hazards.


*"Consider a plot of t versus (1 - KM(t-)), and replace each time point by its vertical position on the plot." Page 136, Therneau and Grambsch.

$\endgroup$
2
  • $\begingroup$ Is it possible to change the x-axis when time is transformed by the KM estimator? Fx the above post shows the Time from 6.7 to 44. Let us say that the time in the data goes from 0 to 45. Is it possible to change the x-axis in R to show the time from 0 to 45? I have only been able to change the x-axis with the raw time, using transform = "identity" @EdM $\endgroup$
    – Devi Sita
    Commented Jun 6 at 18:18
  • $\begingroup$ @DeviSita the problem is that data points only exist at event times. Although the data might extend to time = 45 due to some right-censored observations, if the last event occurs at time = 44 then there won't be any points plotted after time = 44, regardless of transformation or how you extend the axis. Internally, plot.cox.zph() seems to scale the time axis for plotting so that 0 is the first event time and 1 is the last event time, with the time transformation applied within that span of event-time values. The km transformation is only defined within the span of event times. $\endgroup$
    – EdM
    Commented Jun 7 at 16:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.