if (FALSE) {
## Attach the veteran data from the survival package
mydata <- survival::veteran
mydata$celltype <- relevel(mydata$celltype, ref = "large")
myformula <- Surv(time, status) ~ karno + celltype
## Fit the time-varying transformation model
fit <- splineCox(myformula, mydata, control = list(df = 5))
## Plot the time-varying coefficient function between two time points
plotCoef(subset(coef(fit), Time > 15 & Time < 175), smooth = TRUE)
}
Run the code above in your browser using DataLab