Instructor Notes
This is a placeholder file. Please add content here.
Statistics and Probability Unit
Building a simple deterministic model
Solution 1
R
# Parameter List
Lv <- 10 # Life expectancy of mosquitoes (in days)
Lh <- 50 * 365 # Life expectancy of humans (in days)
IPh <- 7 # Infectious period in humans (in days)
IPv <- 6 # Infectious period in mosquitoes (in days)
EIP <- 8.4 # Extrinsic incubation period in adult mosquitoes (in days)
muv <- 1 / Lv # Per capita mortality rate of mosquito population (1/Lv)
muh <- 1 / Lh # Per capita mortality rate of the human population (1/Lh)
alphav <- muv # Per capita birth rate of the mosquito population. For now, we will assume that it is the same as the mortality rate.
alphah <- muh # Per capita birth rate of the human population. For now, we will assume that it is the same as the mortality rate
gamma <- 1 / IPh # Recovery rate in humans (1/IPh)
delta <- 1 / EIP # Extrinsic incubation rate (1/EIP)
Nh <- 100000 # Number of humans. For this exercise, we suggest 100,000 humans. You can change this if you want according to the city you chose to model.
m <- 2 # Density of female mosquitoes per human
Nv <- m * Nh # Number of mosquitoes (m * Nh)
R0 <- 1000 # Basic Reproduction Number
ph <- 0.7 # Probability of transmission from an infectious mosquito to a susceptible human after a bite.
pv <- 0.7 # Probability of transmission from an infectious human to a susceptible mosquito after a bite.
b <- sqrt((R0 * muv * (muv + delta) * (muh + gamma)) /
(m * ph * pv * delta)) # Biting rate
betah <- ph * b # Coefficient of transmission from an infectious mosquito to a susceptible human after a bite (ph * b)
betav <- pv * b # Coefficient of transmission from an infectious human to a susceptible mosquito after a bite (pv * b)
TIME <- 1 # Number of years to be simulated. For this exercise, we will start with the first year of the epidemic.
Solution 3
R
# Simple Deterministic Model (FUN)
zika_model <- function(time, state_variable, parameters) {
with(as.list(c(state_variable, parameters)), # local environment to evaluate derivatives
{
# Humans
dSh <- alphah * Nh - betah * (Iv/Nh) * Sh - muh * Sh
dIh <- betah * (Iv/Nh) * Sh - (gamma + muh) * Ih
dRh <- gamma * Ih - muh * Rh
# Mosquitoes
dSv <- alphav * Nv - betav * (Ih/Nh) * Sv - muv * Sv
dEv <- betav * (Ih/Nh) * Sv - (delta + muv)* Ev
dIv <- delta * Ev - muv * Iv
dx <- c(dSh, dIh, dRh, dSv, dEv, dIv)
list(c(dSh, dIh, dRh, dSv, dEv, dIv))
}
)
}
Solution 5
R
# Initial conditions of the system (y)
start <- c(Sh = Nh, # Population of susceptible humans before the start of the epidemic
Ih = 0, # Population of infectious humans before the start of the epidemic
Rh = 0, # Population of humans recovered before the start of the epidemic
Sv = Nv, # Population of susceptible mosquitoes before the start of the epidemic
Ev = 0, # Population of mosquitoes exposed before the start of the epidemic
Iv = 0) # Population of infectious mosquitoes before the start of the epidemic
Solution 6
R
# Solution
out <- ode(y = start ,
times = time ,
fun = zika_model ,
parms = parameters
) %>%
as.data.frame() # Convert to data frame
Solution
R
# Initial conditions at the beginning of the epidemic
start <- c(Sh = Nh, # Initial population of susceptible humans
Ih = 1, # First infectious human case at the start of the epidemic
Rh = 0, # No recovered humans at the beginning
Sv = Nv, # Initial population of susceptible mosquitoes
Ev = 0, # No exposed mosquitoes at the start of the epidemic
Iv = 0) # No infectious mosquitoes at the beginning
R
out <- ode(y = start ,
times = time ,
fun = zika_model ,
parms = parameters
) %>%
as.data.frame() # Convert to data frame