I am trying to obtain the bridge sampling estimate of the log marginal likelihood for a Bayesian Cox regression model.
The bridgesampling::bridge_sampler
function works with brms::brm
objects but not with rstanarm::stan_surv
objects.
Error in bridge_sampler.stanreg(fit_rstanarm, silent = T) :
the ‘diagnostic_file’ option must be specified in the call to stan_surv to use the ‘bridge_sampler’
install.packages("rstanarm", repos=c("https://stan-dev.r-universe.dev", "https://cloud.r-project.org"))
devtools::install_github("quentingronau/bridgesampling@master")
library(survival) # v 3.7-0
library(rstanarm) # v 2.35.0.9000
library(brms) # v 2.21.0
library(bridgesampling) # v 1.1-5
# R 4.4.1, Stan 2.32.2, M2 macOS Ventura 13.6.9, RStudio 2024.04.2+764
fit_rstanarm <- stan_surv(Surv(time, status) ~ sex, lung, # built-in data set
basehaz="weibull",
refresh=0, cores=4, seed=277)
summary(fit_rstanarm)
bridge_sampler(fit_rstanarm, silent=T) # not work?
fit_brm <- brm(time | cens(1 - status) ~ sex, data=lung,
family=brmsfamily("cox"),
refresh=0, cores=4, seed=277)
summary(fit_brm)
bridge_sampler(fit_brm, silent=T)
Any feedback would be greatly appreciated.