fit1 <- coxph(Surv(time, status) ~ sex + pspline(age), data=lung)
plotTerm(fit1, term=2, rug=FALSE, ylab="Log-hazard",
col=c("blue", "red", "red"))
### smoothing splines
data(mpip)
c1 <- coxph(Surv(futime, status) ~
pspline(lved) + factor(nyha) + rales + pspline(ef),
data=mpip)
plotTerm(c1, 4, ylab="Log-hazard", xlab="Ejection fraction (%)",
main="Log-hazard by ejection fraction \n Line fitted by penalized smoothing splines")
Run the code above in your browser using DataLab