# \donttest{
library(dplyr)
# Prepare the data
# Assume 'data' is your dataset containing 'time' and 'censored' variables
data2 <- data %>%
rename(status = censored) %>%
mutate(
time2 = ifelse(time > 10, 10, time),
status2 = ifelse(time > 10, 0, status)
)
# Pre-compile Stan models (ideally after installing the package)
# This step can be time-consuming but only needs to be done once per session
compiled_models_saved <- compile_stan()
# Fit the survival models using Bayesian methods
example1 <- fit.models.expert(
formula = Surv(time2, status2) ~ 1,
data = data2,
distr = c("wei", "gom"), # Weibull and Gompertz distributions
method = "bayes",
compile_mods = compiled_models_saved)
# Examine the results
summary(example1)
plot(example1)
# }
Run the code above in your browser using DataLab