Part 2 Solutions

Exercise

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)
_________________________________________________________________________
Running the model...
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done.
 done.
summary(model_sir)
________________________________________________________________________________
________________________________________________________________________________
SIMULATION STUDY

Name of the model   : Susceptible-Infected-Removed (SIR) (connected)
Population size     : 10000
Agents' data        : (none)
Number of entities  : 0
Days (duration)     : 75 (of 75)
Number of viruses   : 2
Last run elapsed t  : 40.00ms
Last run speed      : 18.34 million agents x day / second
Rewiring            : off

Global actions:
 (none)

Virus(es):
 - Flu (baseline prevalence: 0.10%)
 - Delta (baseline prevalence: 0.10%)

Tool(s):
 - Masking (baseline prevalence: 60.00%)

Model parameters:
 - Contact rate      : 2.1000
 - Recovery rate     : 0.2500
 - Transmission rate : 0.5000

Distribution of the population at time 75:
  - (0) Susceptible :  9980 -> 485
  - (1) Infected    :    20 -> 0
  - (2) Recovered   :     0 -> 9515

Transition Probabilities:
 - Susceptible  0.96  0.04  0.00
 - Infected     0.00  0.76  0.24
 - Recovered    0.00  0.00  1.00
# 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
[1] 17
# Number of infections on peak day
max(x$counts[x$state == "Infected"])
[1] 3105