Compiles (or retrieves from cache) the Stan models shipped with the package. Compiled executables are stored in a persistent user-level cache directory so that compilation happens only once per Stan source version.
Arguments
- model
Character vector of model names to compile, or
NULL(default) to compile all four models. Valid names:"hbb_base","hbb_weighted","hbb_svc","hbb_svc_weighted".- force
Logical. If
TRUE, recompile even when the cached executable is up-to-date. DefaultFALSE.- quiet
Logical. If
TRUE, suppress informational messages during compilation. DefaultFALSE.- cpp_options
Named list of C++ compilation options passed to
cmdstanr::cmdstan_model(). For example,list(stan_threads = TRUE)enables within-chain threading. Defaultlist().- stanc_options
Named list of stanc3 transpiler options. Default
list().
Details
You can call this function explicitly, or let the main fitting function trigger compilation automatically on first use.
Cache location
Compiled executables are stored under
tools::R_user_dir("hurdlebb", "cache"), following R >= 4.0
conventions. Each model produces two files in the cache directory:
the compiled executable and a .md5 file recording the MD5 digest
of the Stan source at compilation time.
See also
hbb_clear_cache to remove all cached executables.
Examples
if (FALSE) { # \dontrun{
# Compile all models (one-time operation)
hbb_compile()
# Compile only the base model with threading support
hbb_compile("hbb_base", cpp_options = list(stan_threads = TRUE))
# Force recompilation after CmdStan upgrade
hbb_compile(force = TRUE)
} # }