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

Terry Therneau therneau at mayo.edu
Wed May 26 15:29:14 CEST 2010

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

More information about the R-help mailing list