Compile all Stan models in a directory, usually in a package.
stan_package_compile(
models = instantiate::stan_package_model_files(),
cmdstan_install = Sys.getenv("CMDSTAN_INSTALL", unset = ""),
verbose = TRUE,
quiet = FALSE,
pedantic = FALSE,
include_paths = NULL,
user_header = NULL,
cpp_options = list(),
stanc_options = list(),
force_recompile = getOption("cmdstanr_force_recompile", default = FALSE),
threads = FALSE,
...
)
Character vector of file paths to Stan model source code
files. Defaults to the Stan files in ./src/stan/
because all the Stan model files must live in the src/stan/
folder
for an R package built with instantiate
.
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.
Logical of length 1, whether to set the
cmdstanr_verbose
global option to print more compiler messages
than usual.
Argument to cmdstanr::cmdstan_model()
to control compilation.
Logical of length 1, whether to activate pedantic
mode when compiling the Stan models. See the cmdstanr
documentation
for details.
Argument to cmdstanr::cmdstan_model()
to control model compilation.
Argument to cmdstanr::cmdstan_model()
to control model compilation.
Argument to cmdstanr::cmdstan_model()
to control model compilation.
Argument to cmdstanr::cmdstan_model()
to model control compilation.
Argument to cmdstanr::cmdstan_model()
to model control compilation.
Argument to cmdstanr::cmdstan_model()
to model control compilation.
Other named arguments to cmdstanr::cmdstan_model()
.
NULL
(invisibly). Called for its side effects.
If building a package using instantiate
, all Stan model files
must live in a folder called src/stan/
in the package source
directory.
Other packages:
stan_cmdstan_path()
,
stan_package_clean()
,
stan_package_configure()
,
stan_package_model_files()
if (identical(Sys.getenv("INSTANTIATE_EXAMPLES"), "true")) {
path <- tempfile()
stan_package_create(path = path)
stan_package_configure(path = path)
models <- stan_package_model_files(path)
list.files(file.path(path, "inst", "stan"))
stan_package_compile(models)
list.files(file.path(path, "inst", "stan"))
}