In R software, I want to plot a graph by using cox regression with the restricted cubic spline method. However, I can't quite get it to work.
This is the code I'm using:
library(rms); require(rms); library(Hmisc) d<-curve.men dd <- datadist(d) options(datadist="dd") fit <- cph(Surv(time,death) ~ rcs(bmi,4) + systolic +glucose + l_chol + age + edu_g2 + smoke_s + l_chol + drink + activity_l+activity_w, data=d, nk=5) plot(Predict(fit,bmi), xlab="bmi", ylab="Relative Risk", lty=1, lwd=2)
Which creates the following plot (A):
However, I want to plot the following graph (B):
- How do I set the reference point? (for example:
bmi = 24.21429as the reference point)
- I want to add the horizontal line. I tried using
abline(h=1), but it did not work.
- All in all, how do I make the graph look like (B)?