June 2017
Beginner to intermediate
576 pages
15h 22m
English
The curve can be plotted using the generic plot function:
plot(survfit(CoxModel.1),col=c('red','blue') ,lty=1,xlab="Months", ylab="Hazard")title(main = "Model Survival Curve")dev.copy(jpeg,Ch5 - Coxmodel1 plot.jpg); dev.off()
You can also plot a prettier version of the curve using ggplot and ggfortify:
library(ggplot2)library(ggfortify)autoplot(survfit(CoxModel.1), surv.linetype = 'dashed', surv.colour = 'blue', conf.int.fill = 'dodgerblue3', conf.int.alpha = 0.5, censor = FALSE)
Here is a side by side comparison of the curves produced by the native plot function (left plot) and autoplot functions (right plot). The major difference is that the shaded bands replace the confidence interval dotted lines: