## Not run: ------------------------------------
# library("survival")
# set.seed(123)
#
# ## Simulate survival data.
# d <- simSurv(n = 500)
#
# ## Formula of the survival model, note
# ## that the baseline is given in the first formula by s(time).
# f <- list(
# Surv(time, event) ~ s(time) + s(time, by = x3),
# gamma ~ s(x1) + s(x2)
# )
#
# ## Cox model with continuous time.
# ## Note the the family object cox_bamlss() sets
# ## the default optimizer and sampler function!
# ## First, posterior mode estimates are computed
# ## using function cox.mode(), afterwards the
# ## sampler cox.mcmc() is started.
# b <- bamlss(f, family = "cox", data = d)
#
# ## Predict survival probabilities P(T > t).
# p <- predict(b, type = "probabilities",
# time = 3, subdivisions = 100, FUN = c95)
## ---------------------------------------------
Run the code above in your browser using DataCamp Workspace