enw_fit_opts: Format model fitting options for use with stan

enw_fit_optsR Documentation

Format model fitting options for use with stan

Description

Format model fitting options for use with stan

Usage

enw_fit_opts(
  sampler = epinowcast::enw_sample,
  nowcast = TRUE,
  pp = FALSE,
  likelihood = TRUE,
  likelihood_aggregation = c("snapshots", "groups"),
  threads_per_chain = 1L,
  debug = FALSE,
  output_loglik = FALSE,
  ...
)

Arguments

sampler

A function that creates an object that be used to extract posterior samples from the specified model. By default this is enw_sample() which makes use of cmdstanr::sample().

nowcast

Logical, defaults to TRUE. Should a nowcast be made using posterior predictions of the unobserved future reported notifications.

pp

Logical, defaults to FALSE. Should posterior predictions be made for observed data. Useful for evaluating the performance of the model.

likelihood

Logical, defaults to TRUE. Should the likelihood be included in the model

likelihood_aggregation

Character string, aggregation over which stratify the likelihood when threads_per_chain is greater than 1; enforced by base::match.arg(). Currently supported options:

  • "snapshots" which aggregates over report dates and groups (i.e the lowest level that observations are reported at),

  • "groups" which aggregates across user defined groups.

Note that some model modules override this setting depending on model requirements. For example, the enw_missing() module model forces "groups" option. Generally, Users should typically want the default "snapshots" aggregation.

threads_per_chain

Integer, defaults to 1. The number of threads to use within each MCMC chain. If this is greater than 1 then components of the likelihood will be calculated in parallel within each chain.

debug

Logical, defaults to FALSE. Should within model debug information be returned.

output_loglik

Logical, defaults to FALSE. Should the log-likelihood be output. Disabling this will speed up fitting if evaluating the model fit is not required.

...

Additional arguments to pass to the fitting function being used by epinowcast(). By default this will be enw_sample() and so cmdstanr options should be used.

Value

A list containing the specified sampler function, data as a list specifying the fitting options to use, and additional arguments to pass to the sampler function when it is called.

See Also

Model modules enw_expectation(), enw_missing(), enw_obs(), enw_reference(), enw_report()

Examples

# Default options along with settings to pass to enw_sample
enw_fit_opts(iter_sampling = 1000, iter_warmup = 1000)

seabbs/epinowcast documentation built on July 17, 2024, 5:18 p.m.