-
-
Notifications
You must be signed in to change notification settings - Fork 62
/
fit-method-save_object.Rd
41 lines (36 loc) · 1.34 KB
/
fit-method-save_object.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/fit.R
\name{fit-method-save_object}
\alias{fit-method-save_object}
\alias{save_object}
\title{Save fitted model object to a file}
\usage{
save_object(file, ...)
}
\arguments{
\item{file}{(string) Path where the file should be saved.}
\item{...}{Other arguments to pass to \code{\link[base:readRDS]{base::saveRDS()}} besides \code{object} and \code{file}.}
}
\description{
This method is a wrapper around \code{\link[base:readRDS]{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 \verb{$save_object()} method is the
safest way to guarantee that everything has been read in before saving.
See the "Saving fitted model objects" section of the
\href{https://mc-stan.org/cmdstanr/articles/cmdstanr.html}{\emph{Getting started with CmdStanR}}
vignette for some suggestions on faster model saving for large models.
}
\examples{
\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()
}
}
\seealso{
\code{\link{CmdStanMCMC}}, \code{\link{CmdStanMLE}}, \code{\link{CmdStanVB}}, \code{\link{CmdStanGQ}}
}