Skip to contents

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.

Usage

is_current()

Value

TRUE or FALSE.

Examples

# \dontrun{
mod <- cmdstan_model(
  file.path(cmdstan_path(), "examples/bernoulli/bernoulli.stan")
)
mod$is_current()
#> [1] TRUE
# }