# 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}
cumhaz.true <- Vectorize( function(t){integrate(hazard.true, 0, t)$value} )
surv.true <- function(t){exp(-cumhaz.true(t))}
sim.df <- data.frame(id = 1:1000)
df <- simsurv(x = sim.df, maxt = 1, hazard = hazard.true)
bs <- BayesSurv(df, "eventtime", "status")
surv.pm <- approxfun(bs$surv.eval.grid, bs$surv.post.mean)
SurvEval(bs$surv.eval.grid, surv.true, surv.pm, bs$surv.radius)
# }
Run the code above in your browser using DataLab