The $is_current() method of a CmdStanModel object runs
the check that $sample() and the other fitting methods run before they
start, and returns the answer instead of raising an error. It returns
TRUE when the executable is still the one the object was created with
and, for a model created from a Stan file, nothing the executable was
built from has changed: the Stan file and its includes, the user header,
the build options and the CmdStan installation. It returns FALSE when
any of those changed or when the Stan file or the executable is gone,
which is when the fitting methods refuse to run. Call cmdstan_model()
again to rebuild. It errors rather than answering when the check itself
can't run, which happens when stanc rejects the program or can't find an
included file, when the user header is gone, or when no CmdStan
installation is set.
A package that keeps a CmdStanModel inside a saved fit can call it to
decide whether to rebuild before running the model again.
See also
The CmdStanR website (mc-stan.org/cmdstanr) for online documentation and tutorials.
The Stan and CmdStan documentation:
Stan documentation: mc-stan.org/users/documentation
CmdStan User’s Guide: mc-stan.org/docs/cmdstan-guide
Other CmdStanModel methods:
model-method-build_info,
model-method-check_syntax,
model-method-cmdstan_defaults,
model-method-diagnose,
model-method-expose_functions,
model-method-format,
model-method-generate-quantities,
model-method-laplace,
model-method-model-info,
model-method-optimize,
model-method-pathfinder,
model-method-sample,
model-method-sample_mpi,
model-method-variables,
model-method-variational
Examples
# \dontrun{
mod <- cmdstan_model(
file.path(cmdstan_path(), "examples/bernoulli/bernoulli.stan")
)
mod$is_current()
#> [1] TRUE
# }