simulate based on a vector of parameters (including both time-varying change parameters, initial conditions, and other dynamical parameters), for fitting or forecasting

forecast_sim(
  p,
  opt_pars,
  base_params,
  start_date,
  end_date,
  time_args = NULL,
  fixed_pars = NULL,
  stoch = NULL,
  stoch_start = NULL,
  sim_args = list(),
  aggregate_args = NULL,
  condense_args = NULL,
  return_val = c("aggsim", "vals_only"),
  sim_fun = run_sim_break,
  calc_Rt = FALSE,
  debug = FALSE,
  ...
)

Arguments

p

vector of parameters - on the link (log/logit) scale as appropriate; these are the parameters that will be adjusted during calibration

opt_pars

starting parameters (and structure). Parameters that are part of the params_pansim parameter vector can be specified within the params element (with prefixes if they are transformed); other parameters can include distributional parameters or time-varying parameters

base_params

baseline parameters (an object (vector?) of type params_pansim containing all of the parameters needed for a simulation; some may be overwritten during the calibration process)

start_date

starting date for sims (far enough back to allow states to sort themselves out)

end_date

ending date

time_args

arguments passed to sim_fun

fixed_pars

parameters to fix

stoch

stochastic settings (see run_sim)

stoch_start

dates on which to enable stochasticity (vector of dates with names 'proc' and 'obs')

sim_args

additional arguments to pass to run_sim

aggregate_args

arguments passed to aggregate.pansim

condense_args

arguments to pass to condense (via run_sim)

return_val

specify values to return (aggregated simulation, or just the values?)

sim_fun

function for simulating a single run (e.g. run_sim_break, run_sim_mobility)

calc_Rt

calculate and include R(t) in prediction/forecast?

debug

print debugging messages?

...

extra args (ignored)

Examples

ff <- ont_cal1$forecast_args
op <- ff$opt_pars
p <- unlist(op)
params <- fix_pars(read_params("ICU1.csv"))
forecast_sim(p, op, base_params=params,ff$start_date, ff$end_date,
    time_args=ff$time_args)
#> # A tibble: 1,722 × 3
#>    date       var    value
#>    <date>     <chr>  <dbl>
#>  1 2020-01-30 S     999945
#>  2 2020-01-30 E         23
#>  3 2020-01-30 I         30
#>  4 2020-01-30 H          1
#>  5 2020-01-30 ICU        1
#>  6 2020-01-30 R          0
#>  7 2020-01-30 hosp      NA
#>  8 2020-01-30 X          0
#>  9 2020-01-30 death     NA
#> 10 2020-01-30 D          0
#> # … with 1,712 more rows