easystats / bayestestR

:ghost: Utilities for analyzing Bayesian models and posterior distributions
https://easystats.github.io/bayestestR/
GNU General Public License v3.0
563 stars 55 forks source link

`bayesian_as_frequentist()` fails for brms `0 + Intercept` formula #646

Closed DominiqueMakowski closed 2 months ago

DominiqueMakowski commented 6 months ago

The 0 + Intercept syntax in brms is useful to facilitate prior specification for the intercept, but it leads to issues in check_model whereby it wrongly believes that Intercept is a variable and not a special term.

model <- brms::brm(qsec ~ mpg, data=mtcars, refresh=0)
#> Compiling Stan program...
#> Start sampling
performance::check_model(model)
#> Not enough model terms in the conditional part of the model to check for
#>   multicollinearity.


model <- brms::brm(qsec ~ 0 + Intercept + mpg, data=mtcars, refresh=0)
#> Compiling Stan program...
#> Start sampling
performance::check_model(model)
#> Error in eval(predvars, data, env): object 'Intercept' not found

Created on 2024-03-29 with reprex v2.0.2

strengejacke commented 6 months ago

Error comes from bayestestR::bayesian_as_frequentist(model).

DominiqueMakowski commented 6 months ago

Should be fixed by making our own plot (see https://github.com/easystats/performance/issues/477)

strengejacke commented 6 months ago

Not sure. Most of current checks don't work for Bayesian models, that's why we convert to frequentist

strengejacke commented 2 months ago

@DominiqueMakowski bayesian_to_frequentist() is much better now, also capturing less common families. We should include this patch before CRAN submission (if not too late).