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 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.

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)


# Note that this configuration is improper as it uses New York City
# case/death data, but uses Manhattan's FIPS code ('36061') and population size.
# (for demonstration purposes only!)
cfg <- covidestim(ndays = 120, seed = 42, region = '36061', pop_size = 1.63e6) +
  input_cases(example_nyc_data('cases')) +

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