In {bayestestR}
we use prior draws together with posterior draws to estimate Savage-Dickey ratios, Order restricted Bayes factors, and support intervals.
Currently, the way to do this, for example with a brmsfit
object is to re-run the model with prior="only"
(this is what bayestestR::unupdate()
does). This is rather time consuming, as the full HMC must be run again.
So I was wondering if somehow powerscale()
can be used to get prior samples? My thinking was that setting alpha=0 for the likelihood would “cancel” it’s effect, and so we would get prior samples, but this doesn’t seem to do the job.
library(brms)
library(priorsense)
mod <- brm(mpg ~ hp, data = mtcars,
prior = set_prior("normal(1, 2)", class = "b"),
backend = "cmdstanr", silent = TRUE)
ps1 <- powerscale(mod, component = "likelihood", alpha = 0, resample = TRUE)
# expecting a normal distribution centered around 1 with a sd of 2:
hist(ps1$b_hp)
mean(ps1$b_hp)
#> [1] -0.07144655
sd(ps1$b_hp)
#> [1] 0.01998533
Thanks!