Hello @paul.buerkner , I would like to know how to obtain the cumulative baseline hazard for a Cox model in brms, to estimate the survival probability at each time point. In the R survival package this is done with the basehaz function. How is it done after brms?
brms has currently no exported function that computes the cumulative baseline hazard, unfortunately.
OK, then, would you recommend a kludge like this?
fit <- brm(time | cens(1 - event) ~ 1 + arm,
data = data, family = brmsfamily("cox"))
… where arm is a binary variable (0,1).
After that, I estimate the survival rate at the time point of interest by Kaplan-Meier (e.g. survival at 5 years = 0.50) for arm = 0.
I apply the equation of the brms Cox model on the draws and obtain the difference in survival rates:
draws<-data.frame(fit %>% gather_draws(b_arm)) %>% mutate(Sexp= 0.50^exp(draws$.value)) %>% mutate(Sdiff= Sexp- 0.50)
Finally, I use these model’s draws to estimate posterior probabilities on the difference. For example:
F<- function (value) ecdf(draws$Sdiff)(value)
F(0)
F(-0.03)
Etc…
Does it seems to be sound?
How about stan_surv()?