The brms package provides an interface to fit Bayesian generalized (non-)linear multilevel models using Stan, which is a C++ package for obtaining full Bayesian inference (see http://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 the brms package is brm
,
which creates the model in Stan language and fits it using Stan.
Subsequently, a large number of methods can be applied:
To get an overview on the estimated parameters,
summary
or
marginal_effects
are perfectly suited.
Detailed visual analyses can be performed by applying the shinystan package,
which can be called directly within brms using
launch_shiny
.
Information Criteria are also readily available via WAIC
and LOO
both relying on the loo 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 on https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started.
When comparing other packages fitting GLMMs 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 complicated models however, fitting my take several minutes or even hours, so that the compilation time won't make much of a difference here.
See vignette("brms_overview")
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. doi:10.18637/jss.v080.i01
The Stan Development Team Stan Modeling Language User's Guide and Reference Manual. http://mc-stan.org/.