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.
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
Character string or
stanfit
object, defaults to NULL. Should an initial fit be used to initialise the full fit. An example scenario would be using a national level fit to parametrise regional level fits. Optionally a character string can be passed with the currently supported option being "cumulative". This fits the model to cumulative cases and may be useful for certain data sets where the sampler gets stuck or struggles to initialise. Seeinit_cumulative_fit()
for details.This implementation is based on the approach taken in epidemia authored by James Scott.
This argument is deprecated and the default (NULL) will be used from version 2.0.0.
- return_fit
Logical, defaults to TRUE. Should the fit stan model be returned.
- ...
Additional parameters to pass to underlying option functions,
stan_sampling_opts()
orstan_vb_opts()
, depending on the method
Examples
# using default of [rstan::sampling()]
stan_opts(samples = 1000)
#> $backend
#> [1] "rstan"
#>
#> $object
#> NULL
#>
#> $method
#> [1] "sampling"
#>
#> $chains
#> [1] 4
#>
#> $save_warmup
#> [1] FALSE
#>
#> $seed
#> [1] 59898700
#>
#> $future
#> [1] FALSE
#>
#> $max_execution_time
#> [1] Inf
#>
#> $cores
#> [1] 1
#>
#> $warmup
#> [1] 250
#>
#> $control
#> $control$adapt_delta
#> [1] 0.95
#>
#> $control$max_treedepth
#> [1] 15
#>
#>
#> $iter
#> [1] 500
#>
#> $return_fit
#> [1] TRUE
#>
#> attr(,"class")
#> [1] "stan_opts" "list"
# using vb
stan_opts(method = "vb")
#> $backend
#> [1] "rstan"
#>
#> $object
#> NULL
#>
#> $method
#> [1] "vb"
#>
#> $trials
#> [1] 10
#>
#> $iter
#> [1] 10000
#>
#> $output_samples
#> [1] 2000
#>
#> $return_fit
#> [1] TRUE
#>
#> attr(,"class")
#> [1] "stan_opts" "list"