Good morning, I wonder if you could tell me the R code to use to obtain a graph similar to the one below. (from: https://www.nejm.org/doi/full/10.1056/NEJMoa1215740)

enter image description here

That is, I would like to graph the association between the hazard ratio of the primary endpoint (EVENT) VS a continuous covariate (VALUE).

My cox model is as follows: cox<- coxph(Surv(TIME, EVENT) ~ VALUE, data = EBB)

dd <- datadist(mydata); options(datadist='dd')
f <- cph(Surv(time, event) ~ rcs(glucose, 4), data=mydata)

To have more control over the plot use the contrast function (full name contrast.rms) and plot its results as shown in the help file for contrast.rms.

  • $\begingroup$ Thank you very much. Can I just ask you how you interpret the log relative hazard in relation to the hazard ratio? In the graph I don't get the hazard ratio but log relative hazard $\endgroup$
    – Bibi
    Nov 8 '21 at 15:26
  • $\begingroup$ Anti-log of log relative hazard (you can easily plot the anti-log using an argument to Predict) is a hazard ratio. The HR is relative to the reference value for the covariate. Default in rms for a reference value is the median for most purposes. $\endgroup$ Nov 8 '21 at 15:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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