covidestim returns a base configuration of the model with the default set of priors, and no input data. This configuration, after adding input data (see input_cases, input_deaths, priors_*), represents a valid model configuration that can be passed to run.covidestim (for NUTS) or runOptimizer.covidestim (for BFGS).

covidestim(
  nweeks,
  nweeks_before = 4,
  pop_size = 1e+12,
  chains = 3,
  iter = 2000,
  nspl_rt_knotwidth = 1,
  thin = 1,
  seed = 42,
  adapt_delta = 0.98,
  max_treedepth = 14,
  window.length = 7,
  region,
  start_p_imm,
  cum_p_inf_init
)

Arguments

nweeks

A positive integer. The number of weeks of input data being modeled. This should always be set to the number of weeks in your input data.

nweeks_before

A positive integer. How many weeks before the first week of model data should be modeled? A higher number will produce estimates that go farther back in time, however, those estimates will contain more and more uncertainty.

pop_size

A positive integer What is the population in the geography being modelled? This sets the max susceptible population and becomes important as the population ever infected approaches the population size.

chains

The number of chains to use during NUTS sampling, as passed to sampling.

iter

The number of iterations to run during NUTS sampling, as passed to sampling.

nspl_rt_knotwidth

An integer. The knotwidth to use for the spline of Rt.

thin

A positive integer to specify period for saving samples, as passed to sampling. Modify this only if you intend to inspect raw iterations data returned by sampling.

seed

A number. The random number generator seed for use in NUTS sampling or in BFGS.

region

A string. The FIPS code (for U.S. counties) or state name (e.g. New York) being modeled. Required.

Value

An S3 object of type covidestim. This can be passed to run.covidestim or runOptimizer.covidestim to execute the model, as long as input data has been added (using the addition operator, see example). This object can also be saved to disk using saveRDS to enable reproducibility across platforms or sessions. However, note that Stan runs are only reproducible under very specific conditions due to Stan's multi-language architecture. The print method is overloaded to return to the user a summary of the configuration, including prior values and the presence or absence of input data.

Examples

cfg <- covidestim(nweeks = 32, region = 'Connecticut',
   pop = get_pop("Connecticut"),
   start_p_imm = get_imm_init("Connecticut")$start_p_imm,
   cum_p_inf_init = get_imm_init("Connecticut")$cum_p_inf_init) +
  input_cases(example_ct_data('cases')) +
  input_deaths(example_ct_data('deaths')) +
  input_rr(example_ct_data('RR')) + 
  input_hosp(example_ct_data('hosp')) +
  input_boost(example_ct_data('boost'))
#> Error: Number of observations in obs_cas (31) was not equal to N_weeks (32)