This method is a wrapper around base::saveRDS()
that ensures
that all posterior draws and diagnostics are saved when saving a fitted
model object. Because the contents of the CmdStan output CSV files are only
read into R lazily (i.e., as needed), the $save_object()
method is the
safest way to guarantee that everything has been read in before saving.
save_object(file, ...)
(string) Path where the file should be saved.
Other arguments to pass to base::saveRDS()
besides object
and file
.
if (FALSE) { # \dontrun{
fit <- cmdstanr_example("logistic")
temp_rds_file <- tempfile(fileext = ".RDS")
fit$save_object(file = temp_rds_file)
rm(fit)
fit <- readRDS(temp_rds_file)
fit$summary()
} # }