-
Notifications
You must be signed in to change notification settings - Fork 0
/
part2b.qmd
53 lines (43 loc) · 1.23 KB
/
part2b.qmd
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
50
51
52
---
title: "Part 2 Solutions"
---
## Exercise
```{r, fig.height=10}
library(epiworldR)
# Initialize model
model_sir <- ModelSIRCONN(
name = "Flu",
n = 10000,
prevalence = 0.001,
contact_rate = 2.1,
transmission_rate = 0.5,
recovery_rate = 1/4
)
# Building the virus
delta <- virus(name = "Delta", prob_infecting = .3, recovery_rate = 1/4)
# Adding the virus to the model
add_virus(model_sir, delta, .001)
# Building the masking tool
masking <- tool(name = "Masking",
susceptibility_reduction = 0.0,
transmission_reduction = 0.3, # Only transmission
recovery_enhancer = 0.0,
death_reduction = 0.0)
# Adding the tool to the model
add_tool(model_sir, masking, proportion = 0.6)
# Run the model and print summary
run(model_sir, ndays = 75, seed = 1912)
summary(model_sir)
# Reproductive number
repnum <- get_reproductive_number(model_sir)
# Plotting
op <- par(mfrow = c(2,1))
plot(model_sir)
plot(repnum, type="b")
par(op)
# Day of peak infections
x <- get_hist_total(model_sir)
which.max(x$counts[x$state == "Infected"]) - 1
# Number of infections on peak day
max(x$counts[x$state == "Infected"])
```