The hmetad package is a wrapper for the brms package, which by default
uses the rstan interface to the
probabilistic programming language Stan. Until recently, this meant that
users were required to set up a working C++ compiler. Although this
process is usually straightforward (see the Stan installation guide),
one can encounter various problems that are specific to one’s operating
system and other settings. For instance, Windows users must install an
appropriate version of Rtools, and
sometimes different versions can conflict (see this GitHub
issue for an example).
However, Stan has many interfaces with different benefits. For
example, users that prefer to work in programming languages other than R
can use the function stancode(model) on any model fitted
with the hmetad package to output Stan code which can be
used directly in Python, Julia, or MATLAB via the appropriate interface.
As another example, the cmdstanr interface also works
in R (with the optional argument
fit_metad(..., backend = "cmdstanr")) and tends to provide
more efficient code than rstan.
Most recently, the stanli interface has been
released, which uses pre-compiled C++ libraries. By interpreting Stan
code directly, the stanli backend removes the requirement
for a C++ installation and eliminates the time spent compiling models.
Moreover, the resulting models tend to fit significantly faster
than with other backends.
To use the stanli backend, first install the latest
version of brms (must be >= 2.24.0):
pak::pak("brms")Next, install the stanli package:
install.packages("stanli", repos = c("https://seantalts.r-universe.dev"))
stanli::stanli_install()Finally, simply add the argument backend = "stanli" to
any calls to fit_metad: