# NOT RUN {
#Demonstration on a simulated data set
library(simsurv)
library(ggplot2)
hazard.true <- function(t,x, betas, ...){1.2*(5*(t+0.05)^3 - 10*(t+0.05)^2 + 5*(t+0.05) ) + 0.7}
sim.df <- data.frame(id = 1:1000)
df <- simsurv(x = sim.df, maxt = 1, hazard = hazard.true)
bs <- BayesSurv(df, "eventtime", "status")
PlotBayesSurv(bs, object = "survival")
cumhaz.plot <- PlotBayesSurv(bs, object = "cumhaz")
cumhaz.plot + labs(title = "Cumulative hazard")
# }
Run the code above in your browser using DataLab