Skip to content

bayesfactor_models() recomputes brms model with rstan. Can we avoid that? #708

@DominiqueMakowski

Description

@DominiqueMakowski

For the (I think many) people struggling with having a functioning rstan (typically on servers or with restricted laptops), cmdstanr has been great. However, bayesfactor_models recomputes the models using rstan, rendering it unusable with cmdstanr. Is there a solution?

m1 <- brms::brm(mpg ~ wt, data=mtcars, backend="cmdstanr", refresh=0)
m2 <- brms::brm(mpg ~ wt + hp, data=mtcars, backend="cmdstanr", refresh=0)


bayestestR::bayesfactor_models(m1, m2)
#> Warning: Bayes factors might not be precise.
#>   For precise Bayes factors, sampling at least 40,000 posterior samples is
#>   recommended.
#> Computation of Marginal Likelihood: estimating marginal likelihood,
#>   please wait...
#> Recompiling the model with 'rstan'
#> Error in compileCode(f, code, language = language, verbose = verbose): /Users/domma/AppData/Local/R/win-

Created on 2025-04-02 with reprex v2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions