# \donttest{
# set number of cores to use
old_opts <- options()
options(mc.cores = ifelse(interactive(), 4, 1))
# get example case counts
reported_cases <- example_confirmed[1:40]
# fit model to data to recover Rt estimates
# samples and calculation time have been reduced for this example
# for real analyses, use at least samples = 2000
est <- estimate_infections(reported_cases,
generation_time = generation_time_opts(example_generation_time),
delays = delay_opts(example_incubation_period + example_reporting_delay),
rt = rt_opts(prior = LogNormal(mean = 2, sd = 0.1), rw = 7),
obs = obs_opts(scale = Normal(mean = 0.1, sd = 0.01)),
gp = NULL,
forecast = forecast_opts(horizon = 0),
stan = stan_opts(samples = 100, warmup = 200)
)
# update Rt trajectory and simulate new infections using it
# keeping the first 30 days' estimates and adding a 10-day forecast
R <- c(rep(NA_real_, 30), rep(0.8, 10))
sims <- forecast_infections(est, R)
plot(sims)
options(old_opts)
# }
Run the code above in your browser using DataLab