stan_opts function

Stan Options

Stan Options

Defines a list specifying the arguments passed to underlying stan backend functions via stan_sampling_opts() and stan_vb_opts(). Custom settings can be supplied which override the defaults.

stan_opts( object = NULL, samples = 2000, method = c("sampling", "vb", "laplace", "pathfinder"), backend = c("rstan", "cmdstanr"), return_fit = TRUE, ... )

Arguments

  • object: Stan model object. By default uses the compiled package default if using the "rstan" backend, and the default model obtained using epinow2_cmdstan_model() if using the "cmdstanr" backend.
  • samples: Numeric, defaults to 2000. Number of posterior samples.
  • method: A character string, defaulting to sampling. Currently supports MCMC sampling ("sampling") or approximate posterior sampling via variational inference ("vb") and, as experimental features if the "cmdstanr" backend is used, approximate posterior sampling with the laplace algorithm ("laplace") or pathfinder ("pathfinder").
  • backend: Character string indicating the backend to use for fitting stan models. Supported arguments are "rstan" (default) or "cmdstanr".
  • return_fit: Logical, defaults to TRUE. Should the fit stan model be returned.
  • ...: Additional parameters to pass to underlying option functions, stan_sampling_opts() or stan_vb_opts(), depending on the method

Returns

A <stan_opts> object of arguments to pass to the appropriate rstan functions.

Examples

# using default of [rstan::sampling()] stan_opts(samples = 1000) # using vb stan_opts(method = "vb")

See Also

stan_sampling_opts() stan_vb_opts()