Calling run() with a covidestim object executes the model and returns a result. run will attempt to run on as many cores as appear to be available on the host machine, through calling detectCores. Model runtimes will range anywhere from 30 minutes to 12 hours, with the cumulative number of cases appearing to be a strong correlate to longer runtime.

# S3 method for covidestim
run(cc, cores = parallel::detectCores(), ...)

Arguments

cc

A valid covidestim configuration

cores

A number. How many cores to use to execute runs.

...

Extra arguments, passed on to sampling

Value

An S3 object of class covidestim_result containing the configuration used to run the model, the raw Stan results, the extracted result as produced by extract, and the summarized results as produced by extract.

Details

When running in an interactive/TTY environment (like Rstudio, Radian, or the R terminal), progress messages from rstan will be displayed, indicatng how many iterations each chain has completed. When running in other environments, for instance on a cluster, rstan will produce no output until the end of sampling.

The sampler may return warnings upon completion. In general, "treedepth" and "divergent transitions" are the most serious. Use caution when interpreting results which were accompanied by these messages. See mc-stan.org for a detailed guide to Stan's most common warning messages.

A second method for fitting the model, using the BFGS algorithm, is available as runOptimizer. It is significantly faster, but lacks CI's.

FunctionMethodCI'sSpeedTermination
run()NUTSYes30m-hoursAlways, potentially with warnings, of which "treedepth" and "divergent transitions" are the most serious
runOptimizer()BFGSNo~1-3minPotentially with nonzero exit status (lack of convergence), or timeout (rare, gracefully handled internally)

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)
  

if (FALSE) {
result <- run(cfg, cores = 2)
}