GoForceX

forecast_whole.R

Aug 22nd, 2024
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 1.06 KB | Source Code | 0 0
  1. library(EpiNow2)
  2. library(patchwork)
  3. library(xlsx)
  4.  
  5. df <- read.xlsx("Wave2_Raw.xlsx", sheetIndex = 1)
  6.  
  7. # set number of cores to use
  8. old_opts <- options()
  9. options(mc.cores = 8)
  10. # construct example distributions
  11. generation_time <- get_generation_time(disease = "SARS-CoV-2", source = "ganyani")
  12. incubation_period <- get_incubation_period(disease = "SARS-CoV-2", source = "lauer")
  13. reporting_delay <- list(mean = convert_to_logmean(3,1),
  14.                         mean_sd = 0.1,
  15.                         sd = convert_to_logsd(3,1),
  16.                         sd_sd = 0.1, max = 15)
  17.  
  18. # example case data
  19. reported_cases <- df[1:35, ]
  20.  
  21. # estimate Rt and nowcast/forecast cases by date of infection
  22. out1 <- epinow(
  23.   horizon = 15,
  24.   reported_cases = reported_cases,
  25.   generation_time = generation_time,
  26.   delays = delay_opts(incubation_period, reporting_delay),
  27.   rt = rt_opts(prior = list(mean = 2, sd = 0.2), future = "project"),
  28.   stan = stan_opts(cores = 12),
  29.   verbose = interactive()
  30. )
  31.  
  32. # summary of the latest estimates
  33. summary(out1)
  34. # plot estimates
  35. plot(out1)
Advertisement
Add Comment
Please, Sign In to add comment