Skip to contents

These methods access information stored in a CmdStanModel object, print its Stan program, and manage paths to its executable and generated C++ file. For how the executable was built, see the $build_info() method, which has its own page.

stan_file()
has_stan_file()
code()
print(line_numbers = getOption("cmdstanr_print_line_numbers", FALSE))
model_name()
exe_file()
include_paths()
cmdstan_version()
cpp_options()
user_header()
hpp_file()
save_hpp_file(dir = NULL)

Arguments

line_numbers

(logical) Should line numbers be printed? The default is getOption("cmdstanr_print_line_numbers", FALSE).

dir

(string) The directory in which to save the .hpp file. The default is the directory containing the Stan program.

Value

  • $stan_file() returns a path as a string, or character(0) if the model was created without a Stan file.

  • $has_stan_file() returns TRUE if the model was created with a Stan file and FALSE otherwise.

  • $code() returns a character vector with one element per line of Stan code, or NULL if the model was created without a Stan file.

  • $print() returns the CmdStanModel object invisibly.

  • $model_name() returns the model name as a string.

  • $exe_file() returns a path as a string, or character(0) if no executable path is set.

  • $include_paths() returns a character vector of absolute paths or NULL.

  • $cmdstan_version() returns the version of CmdStan that built the executable, as a string.

  • $cpp_options() returns a named list of C++ options, with names in their make spelling and values as the strings make received: TRUE comes back as "true" and FALSE as "". To ask whether the executable was built with a feature, use $build_info(), which reports logicals.

  • $user_header() returns the absolute path to the user header as a string, or NULL if the model has no user header.

  • $hpp_file() returns the path to the .hpp file holding the C++ code generated for the Stan program when the model object was created. It errors if the model was created without a Stan file.

  • $save_hpp_file() moves the .hpp file to dir, updates the stored path, and returns the new path invisibly.