## example using simulated Ebola outbreak
if (require(outbreaks) &&
require(distcrete) &&
require(incidence) &&
require(magrittr)) {
si <- distcrete("gamma", interval = 1L,
shape = 2.4,
scale = 4.7,
w = 0.5)
i <- incidence(ebola_sim$linelist$date_of_onset)
plot(i)
## projections after the first 100 days, over 60 days, fixed R to 2.1
set.seed(1)
proj_1 <- project(x = i[1:100], R = 2.1, si = si, n_days = 60)
plot(proj_1)
## add projections to incidence plot
plot(i[1:160]) %>% add_projections(proj_1)
## projections after the first 100 days, over 60 days,
## using a sample of R
set.seed(1)
R <- rnorm(100, 1.8, 0.2)
hist(R, col = "grey", border = "white", main = "Distribution of R")
proj_2 <- project(x = i[1:100], R = R, si = si, n_days = 60)
## add projections to incidence plot
plot(i[1:160]) %>% add_projections(proj_2)
## same with R constant per simulation (more variability)
set.seed(1)
proj_3 <- project(x = i[1:100], R = R, si = si, n_days = 60,
R_fix_within = TRUE)
## add projections to incidence plot
plot(i[1:160]) %>% add_projections(proj_3)
## time-varying R, 2 periods, R is 2.1 then 0.5
set.seed(1)
proj_4 <- project(i,
R = c(2.1, 0.5),
si = si,
n_days = 60,
time_change = 40,
n_sim = 100)
plot(proj_4)
## time-varying R, 2 periods, separate distributions of R for each period
set.seed(1)
R_period_1 <- runif(100, min = 1.1, max = 3)
R_period_2 <- runif(100, min = 0.6, max = .9)
proj_5 <- project(i,
R = list(R_period_1, R_period_2),
si = si,
n_days = 60,
time_change = 20,
n_sim = 100)
plot(proj_5)
}
Run the code above in your browser using DataLab