Crashes using bayes_factor() in brms

Possibly related to this thread, each time I try to use the bridge sampler via bayes_factor() in brms (2.17.0), R Studio crashes. As far as I’m aware, I have the latest (development) versions of rstan and StanHeaders (2.26.13), and am running R 4.2.1 through RStudio 2022.07.1+554 on a Windows machine. The models I am trying to compare are simple:

firstPrior <- set_prior("normal(0, 1)", class = "b")
first <- brm(amplitudeD ~ group, data=data, family=gaussian(),
             prior=firstPrior, save_pars=save_pars("all"), sample_prior=TRUE)

secondModel <- bf(amplitudeD ~ group, sigma ~ group)
secondPrior <- set_prior("normal(0, 1)", class = "b")
second <- brm(secondModel, data=data, family=gaussian(),
              prior=secondPrior, save_pars=save_pars("all"),
              sample_prior=TRUE)

bayes_factor(first, second)

The data are also simple:
data.csv (2.3 KB)

If anyone has any ideas regarding how to solve this issue, I’d appreciate it. (I’ve never had any problems using bridgesampling before, though have not tried for some months previously, so suspect the version of something I’m using now is to blame.)

1 Like

To respond to myself: When I tried the same thing on my MacBook, instead of crashing I received the error message

Error: Bridgesampling failed. Perhaps you did not set 'save_pars = save_pars(all=TRUE)' when fitting your model?

Changing save_pars=save_pars("all") to save_pars=save_pars(all=TRUE) led to successful execution on the laptop; and when I made the same change on my Windows machine, it worked too. So, apparently the crash was just a result of incorrect use of the save_pars argument.

1 Like