Stan Development Team
The brms package provides an interface to fit Bayesian generalized multivariate (non-)linear multilevel models using Stan, which is a C++ package for obtaining full Bayesian inference (see https://mc-stan.org/). The formula syntax is an extended version of the syntax applied in the lme4 package to provide a familiar and simple interface for performing regression analyses.
The main function of brms is
brm, which uses
formula syntax to specify a wide range of complex Bayesian models
brmsformula for details). Based on the supplied
formulas, data, and additional information, it writes the Stan code
on the fly via
make_stancode, prepares the data via
make_standata, and fits the model using
Subsequently, a large number of post-processing methods can be applied:
To get an overview on the estimated parameters,
are perfectly suited. Detailed visual analyses can be performed by applying
stanplot methods, which both
rely on the bayesplot package.
Model comparisons can be done via
which make use of the loo package as well as
bayes_factor which relies on the bridgesampling package.
For a full list of methods to apply, type
methods(class = "brmsfit").
Because brms is based on Stan, a C++ compiler is required. The program Rtools (available on https://cran.r-project.org/bin/windows/Rtools/) comes with a C++ compiler for Windows. On Mac, you should use Xcode. For further instructions on how to get the compilers running, see the prerequisites section at the RStan-Getting-Started page.
When comparing other packages fitting multilevel models to brms, keep in mind that the latter needs to compile models before actually fitting them, which will require between 20 and 40 seconds depending on your machine, operating system and overall model complexity.
Thus, fitting smaller models may be relatively slow as compilation time makes up the majority of the whole running time. For larger / more complex models however, fitting my take several minutes or even hours, so that the compilation time won't make much of a difference for these models.
for a general introduction and overview of brms. For a full list of
available vignettes, type
vignette(package = "brms").
Paul-Christian Buerkner (2017). brms: An R Package for Bayesian Multilevel
Models Using Stan. Journal of Statistical Software, 80(1), 1-28.
Paul-Christian Buerkner (2018). Advanced Bayesian Multilevel Modeling
with the R Package brms. The R Journal. 10(1), 395–411.
The Stan Development Team. Stan Modeling Language User's Guide and Reference Manual. https://mc-stan.org/users/documentation/.
Stan Development Team (2020). RStan: the R interface to Stan. R package version 2.21.2. https://mc-stan.org/
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.