Skip to contents

A CmdStanLaplace object is the fitted model object returned by the $laplace() method of a CmdStanModel object.

Objects created from CSV files using as_cmdstan_fit() have a reduced set of available methods. See Reconstructed fitted model objects in the as_cmdstan_fit() documentation for details.

Methods

CmdStanLaplace objects have the following associated methods, all of which have their own (linked) documentation pages.

Extract contents of fitted model object

MethodDescription
$draws()Return approximate posterior draws as a draws_matrix.
$mode()Return the mode as a CmdStanMLE object.
$lp()Return the target log density (lp__) evaluated by Stan.
$lp_approx()Return the log density of the approximation to the posterior.
$init()Return user-specified initial values.
$metadata()Return a list of metadata gathered from the CmdStan CSV files.
$profiles()Return profiling data.
$code()Return Stan code as a character vector.

Summarize inferences

MethodDescription
$print()Print a summary of the approximate posterior draws.
$summary()Run posterior::summarise_draws().

Save fitted model object and temporary files

MethodDescription
$materialize()Read all draws and diagnostics into memory.
$save_object()Save fitted model object to a file.
$output_files()Return paths to output CSV files.
$save_output_files()Save output CSV files to a specified location.
$data_file()Return the path to the JSON data file.
$save_data_file()Save JSON data file to a specified location.
$profile_files()Return paths to profiling CSV files.
$save_profile_files()Save profiling CSV files to a specified location.
$config_files()Return paths to CmdStan configuration JSON files.
$save_config_files()Save CmdStan configuration JSON files to a specified location.

Report run times, console output, return codes

MethodDescription
$time()Report the run time of the Laplace sampling step.
$output()Pretty print the output that was printed to the console.
$return_codes()Return the return codes from the CmdStan runs.
$command()Return the commands that ran CmdStan.

Expose Stan functions and additional methods to R

MethodDescription
$expose_functions()Expose Stan functions for use in R.
$init_model_methods()Expose methods for log-probability, gradients, parameter constraining and unconstraining.
$log_prob()Calculate log-prob.
$grad_log_prob()Calculate log-prob and gradient.
$hessian()Calculate log-prob, gradient, and Hessian.
$constrain_variables()Transform a set of unconstrained parameter values to the constrained scale.
$unconstrain_variables()Transform a set of parameter values to the unconstrained scale.
$unconstrain_draws()Transform all parameter draws to the unconstrained scale.

See also

The CmdStanR website (mc-stan.org/cmdstanr) for online documentation and tutorials.

The Stan and CmdStan documentation:

Other fitted model objects: CmdStanDiagnose, CmdStanGQ, CmdStanMCMC, CmdStanMLE, CmdStanPathfinder, CmdStanVB