Skip to contents

The $init_model_methods() method compiles and initializes the log_prob, grad_log_prob, hessian, constrain_variables, unconstrain_variables and unconstrain_draws functions. These are then available as methods of the fitted model object. This requires the additional Rcpp package. The methods compile once per model object, so later fits of the same model reuse them. To avoid compiling them again in every new R session, set the rcpp.cache.dir option as described for $expose_functions().

If a model or fit object was saved with base::saveRDS() and later reloaded, any previously compiled model-method bindings will be rebuilt in the current R session when this method is called.

Note: there may be many compiler warnings emitted during compilation but these can be ignored so long as they are warnings and not errors.

Usage

init_model_methods(seed = 1, verbose = FALSE, quiet = FALSE)

Arguments

seed

(integer) The random seed to use when initializing the model.

verbose

(logical) Whether to show verbose logging during compilation.

quiet

(logical) Should the message announcing the compilation be suppressed? The default is FALSE. Compiler output is controlled by verbose.

Value

NULL, invisibly.

Examples

# \dontrun{
fit_mcmc <- cmdstanr_example("logistic", method = "sample", force_recompile = TRUE)
# fit_mcmc$init_model_methods()
# }