[R] Relative Risk/Hazard Ratio plots for continuous variables

Terry Therneau
Wed, 26 May 2010 13:29:14 -0000

I prefer smoothing splines, Frank prefers regression splines.  The
former is built into the survival package:

 options(na.action=na.exclude)  # This should be the default IMHO

 coxfit1<- coxph(Surv(rtime,rcens) ~ pspline(cts), data=data1)
 summary(coxfit1)   #shows the linear and nonlinear tests
 plot(data1$cts, predict(coxfit1))

or if you want confidence intervals, this gives the data to plot
 pr1 <- predict(coxfit1, type='terms', se=T)

Terry Therneau