R/stan_package_model.R
stan_package_model.RdGet the cmdstanr model object for a pre-compiled Stan
model inside a package.
stan_package_model(
name,
package,
library = NULL,
cmdstan_install = Sys.getenv("CMDSTAN_INSTALL", unset = ""),
compile = FALSE,
include_paths = NULL,
...
)Character of length 1, base name of the Stan model file
(without the containing directory or .stan file extension).
Character of length 1, name of the R package to look for the built-in Stan model.
Character of length 1 or NULL, library path
to look for the package with the built-in Stan model.
Passed to the lib.loc argument of system.file().
Character of length 1, how to look for an installed copy of CmdStan. See https://wlandau.github.io/instantiate/ for details. Choices:
"" (default): look at the original value that the CMDSTAN_INSTALL
environment variable contained when instantiate at the time
when it was installed.
If it was "implicit" or "fixed", then choose
the corresponding option below. Otherwise, default to "implicit".
"implicit": Let the cmdstanr::cmdstan_path() decide where
to look for CmdStan. As explained in the cmdstanr documentation,
the output of cmdstanr::cmdstan_path() depends
on the current value of the CMDSTAN environment variable.
The cmdstanr package must be installed. If it
is not installed, then stan_cmdstan_path()
returns the empty string "".
"fixed": Use the path to CmdStan that was originally
contained in Sys.getenv("CMDSTAN") at the time when instantiate
was installed.
TRUE to compile the model and store the executable file
where the package is installed in .libPaths(). FALSE to
use the executable already installed there, which is usually
the case. If the executable is missing, the model is compiled
either way.
Argument to cmdstanr::cmdstan_model()
to control model compilation. Used only when compile is TRUE
or the executable is missing.
Named arguments passed to cmdstanr::cmdstan_model().
Used only when compile is TRUE or the executable is missing.
An R6 Stan model object from the cmdstanr package.
Please visit the documentation website at https://mc-stan.org/cmdstanr/
for detailed information on the composition of this model object
and how to use it to conduct Bayesian inference.
Packages configured with instantiate compile their Stan
models on installation. Then the stan_package_model() function
retrieves the cmdstanr::cmdstan_model() object without needing
to re-compile the model. Please see the documentation website
of the instantiate package for examples.
# Please see the documentation website of the {instantiate} package
# for examples.