Last chance! 50% off unlimited learning
Sale ends in
# NOT RUN {
library(ggplot2)
data(heart, package="survival")
lam <- 0.02
alp <- 1
pfit <- pcoxtime(Surv(start, stop, event) ~ age + year + surgery + transplant
, data = heart
, lambda = lam
, alpha = alp
)
# Plot survival curves
psurv <- pcoxsurvfit(pfit)
plot(psurv)
# Baseline survival curve
bsurv <- pcoxbasehaz(pfit, centered = FALSE)
plot(bsurv)
# Compare overall and baseline cumulative hazard
p1 <- plot(psurv, type = "cumhaz", compare = TRUE)
df2 <- data.frame(time = bsurv$time, cumhaz = bsurv$hazard)
p2 <- (p1
+ geom_step(data = df2, aes(x = time, y = cumhaz, group = 1, col = "baseline"))
+ scale_colour_manual(name = "C. hazard"
, values = c("#E41A1C", "#000000")
, labels = c("baseline", "overall")
)
)
print(p2)
# }
Run the code above in your browser using DataLab