The Bayesian framework is quickly gaining popularity among scientists, leading to the growing popularity of packages to fit Bayesian models, such as
brms. However, extracting summary indices from these models to report them in your manuscript can be quite challenging, especially for new users.
To address this, please let us introduce
We have recently decided to collaborate around the new easystats project, a set of packages designed to make your life easier (currently very WIP). As we are also Bayesian enthusiasts, we decided to focus on the development of a package devoted to Bayesian post-processing.
The goal of
bayestestR is to provide lightweight tools to help processing and understanding Bayesian models and posterior distributions. It includes several functions used to report and characterise them, such as Highest Density Interval (
hdi), the highest Maximum A Posteriori (
MAP) or functions to find a suitable ROPE range, compute the ROPE percentage or do an Equivalence Test. It also includes more exploratory indices, such as the Probability of Direction (
pd), a numeric equivalent of the frequentist p value.
bayestestR can be installed as follows:
install.packages("bayestestR") # Install the package library(bayestestR) # Load it
Let’s check whether the effects of my Bayesian regression can be considered as non-negligible. This can be done via the equivalence test.
# Load the rstanarm package library(rstanarm) # Fit a Bayesian model model <- stan_glm(mpg ~ wt + cyl + gear + am + hp, data = mtcars)
# Do the test equivalence_test(model)
## # Test for Practical Equivalence ## ## ROPE: [-0.60 0.60] ## ## Parameter H0 inside ROPE 89% HDI ## (Intercept) rejected 0.00 % [27.33 47.61] ## wt rejected 0.00 % [-4.14 -1.01] ## cyl undecided 36.84 % [-1.87 0.34] ## gear undecided 40.75 % [-2.18 1.78] ## am undecided 18.17 % [-1.18 4.58] ## hp accepted 100.00 % [-0.05 0.00]
Results can also be plotted, to get a better impression of the posterior distributions and the ROPE-coverage.
# Do the test and plot results plot(equivalence_test(model))
- Don’t forget to check out the documentation here for more!
More details about
bayestestR’s features are comming soon, stay tuned 😉
There is definitely room for improvement, and some new exciting features are already planned (BayesFactor objects support, better visualisation methods, etc.). Feel free to let us know how we could further improve this package!
To conclude, note that easystats is a new project in active development. Thus, do not hesitate to contact us if you want to get involved 🙂
- Check out our other blog posts here!