-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpart_2.R
49 lines (43 loc) · 1.43 KB
/
part_2.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
##########################################################################
# Run some more nuanced simulations using a wrapper function for nimue::run, which allows us to set some more flexible options:
# - income setting
# - transmission over time
# - vaccine dose strategy
# - ...
# Load the functions script
source("R/functions.R")
# set some parameters
R0 <- 2.5
Rt1 <- 0.9
Rt2 <- 3
reduction1 <- 1-Rt1/R0
reduction2 <- 1-Rt2/R0
timing1 <- 50
timing2 <- 350
income_group <- "HIC"
duration_R <- 365
coverage <- 0
vaccine_period <- 30
vaccine_start <- 365
# set up a dataframe of scenarios
scenarios <- expand_grid(R0 = R0,
reduction1 = reduction1,
reduction2 = reduction2,
coverage = coverage,
income_group = income_group,
duration_R = duration_R,
vaccine_period = vaccine_period,
vaccine_start = vaccine_start,
timing1 = timing1,
timing2 = timing2)
# run the model
system.time({out <- future_pmap(scenarios, run_scenario, .progress = TRUE)})
# format the output
df <- bind_cols(scenarios, bind_rows(out)) %>%
unnest(output) %>%
filter(compartment %in% c("deaths", "infections"))
# create plot
ggplot(data = df, aes(x = t, y = value)) +
geom_line(size = 0.8) +
facet_wrap(~compartment, scales = "free") +
theme_bw()