stan_opts: Stan Options

View source: R/opts.R

stan_optsR Documentation

Stan Options

Description

[Stable] 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.

Usage

stan_opts(
  object = NULL,
  samples = 2000,
  method = c("sampling", "vb", "laplace", "pathfinder"),
  backend = c("rstan", "cmdstanr"),
  init_fit = NULL,
  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, default 2000. Overall number of posterior samples. When using multiple chains iterations per chain is samples / chains.

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".

init_fit

[Deprecated] This argument is deprecated.

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

Value

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

See Also

stan_sampling_opts() stan_vb_opts()

Examples

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

# using vb
stan_opts(method = "vb")

EpiNow2 documentation built on Oct. 31, 2024, 5:09 p.m.