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(), ...)
A valid covidestim
configuration
A number. How many cores to use to execute runs.
Extra arguments, passed on to sampling
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
.
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.
Function | Method | CI's | Speed | Termination |
run() | NUTS | Yes | 30m-hours | Always, potentially with warnings, of which "treedepth" and "divergent transitions" are the most serious |
runOptimizer() | BFGS | No | ~1-3min | Potentially with nonzero exit status (lack of convergence), or timeout (rare, gracefully handled internally) |
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)
}