
# NOT RUN {
if(requireNamespace("EpiSoon")){
if(requireNamespace("forecastHybrid")){
# example case data
reported_cases <- example_confirmed[1:40]
generation_time <- get_generation_time(disease = "SARS-CoV-2", source = "ganyani")
incubation_period <- get_incubation_period(disease = "SARS-CoV-2", source = "lauer")
reporting_delay <- estimate_delay(rlnorm(100, log(6), 1), max_value = 15)
# estimate Rt and infections from data
out <- estimate_infections(reported_cases, generation_time = generation_time,
delays = delay_opts(incubation_period, reporting_delay),
rt = rt_opts(prior = list(mean = 2, sd = 0.1)))
# forecast Rt and infections from estimates
forecast <- forecast_infections(
infections = out$summarised[variable == "infections"],
rts = out$summarised[variable == "R"],
gt_mean = out$summarised[variable == "gt_mean"]$mean,
gt_sd = out$summarised[variable == "gt_sd"]$mean,
gt_max = 30,
forecast_model = function(y, ...){
EpiSoon::forecastHybrid_model(y = y[max(1, length(y) - 21):length(y)],
model_params = list(models = "aefz", weights = "equal"),
forecast_params = list(PI.combination = "mean"), ...)},
horizon = 14,
samples = 1000)
forecast$summarised
}
}
# }
Run the code above in your browser using DataLab