@@ -432,9 +432,9 @@ fit_pf$print("theta")
432432
433433
434434Let's extract the draws, make the same plot we made after running the other
435- algorithms, and compare them all. approximation, and compare them all. In this
436- simple example the distributions are quite similar, but this will not always be
437- the case for more challenging problems.
435+ algorithms, and compare them all. In this simple example the distributions are
436+ quite similar, but this will not always be the case for more challenging
437+ problems.
438438
439439``` {r plot-compare-pf, message = FALSE}
440440mcmc_hist(fit_pf$draws("theta"), binwidth = 0.025) +
@@ -469,46 +469,29 @@ For more details on the `$optimize()`, `$laplace()`, `$variational()`, and
469469## Saving fitted model objects
470470
471471The [ ` $save_object() ` ] ( http://mc-stan.org/cmdstanr/reference/fit-method-save_object.html )
472- method provided by CmdStanR is the most convenient way to save a fitted model object
473- to disk and ensure that all of the contents are available when reading the object back into R.
472+ method provided by CmdStanR is the most convenient way to save a fitted model
473+ object to disk and ensure that all of the contents are available when reading
474+ the object back into R. By default, ` fit$save_object() ` will use the ` RDS `
475+ format to save the object. The saved object can then be read back into R using
476+ ` readRDS() ` .
474477
475478``` {r save_object, eval=FALSE}
476479fit$save_object(file = "fit.RDS")
477480
478- # can be read back in using readRDS
479481fit2 <- readRDS("fit.RDS")
480482```
481483
482- But if your model object is large, then
483- [ ` $save_object() ` ] ( http://mc-stan.org/cmdstanr/reference/fit-method-save_object.html )
484- could take a long time when saving in the default RDS format. For large objects,
485- use the much faster [ ` qs2 ` ] ( https://github.com/traversc/qs2 ) format .
484+ But if your model object is large, then ` fit$save_object() ` can take a long time
485+ if saving in the default RDS format. For large objects, we recommend using the
486+ much faster [ ` qs2 ` ] ( https://github.com/traversc/qs2 ) format. The saved object
487+ can then be read back into R using ` qs2::qs_read() ` .
486488
487489``` {r save_object_qs_full, eval = FALSE}
488- # Save the object to a file using qs2.
489490fit$save_object(file = "fit.qs2", format = "qs2")
490491
491- # Read the object.
492492fit2 <- qs2::qs_read("fit.qs2")
493493```
494494
495- Storage is even faster if you discard results you do not need to save.
496- The following example saves only posterior draws and discards
497- sampler diagnostics, user-specified initial values, and profiling data.
498-
499- ``` {r save_object_qs_small, eval = FALSE}
500- # Load posterior draws into the fitted model object and omit other output.
501- fit$draws()
502-
503- # Save the object to a file.
504- qs2::qs_save(fit, file = "fit.qs2")
505-
506- # Read the object.
507- fit2 <- qs2::qs_read("fit.qs2")
508- ```
509-
510- See the vignette [ _ How does CmdStanR work?_ ] ( http://mc-stan.org/cmdstanr/articles/cmdstanr-internals.html )
511- for more information about the composition of CmdStanR objects.
512495
513496## Comparison with RStan
514497
@@ -526,7 +509,8 @@ To ask a question please post on the Stan forums:
526509
527510* https://discourse.mc-stan.org/
528511
529- To report a bug, suggest a feature (including additions to these vignettes), or to start contributing to CmdStanR
530- development (new contributors welcome!) please open an issue on GitHub:
512+ To report a bug, suggest a feature (including additions to these vignettes), or
513+ to start contributing to CmdStanR development (new contributors welcome!) please
514+ open an issue on GitHub:
531515
532516* https://github.com/stan-dev/cmdstanr/issues
0 commit comments