SIR EPIDEMIOLOGICAL MODEL

Objective: To analyse the dynamics of the Susceptible-Infectious-Recovered (SIR) epidemic model.

Remove all objects from workspace.

remove (list = objects())

Load add-on packages - deSolve - contains lsoda function - differential equation solver.

library (deSolve)
## 
## Attaching package: 'deSolve'
## 
## The following object is masked from 'package:graphics':
## 
##     matplot

Function to compute derivatives of the differential equations.

sir_model = function (current_timepoint, state_values, parameters)
{
  # create state variables (Local variables)
  S = state_values [1]        # susceptibles
  I = state_values [2]        # infectious
  R = state_values [3]        # recovered
  
  with (
    as.list (parameters),     # variable names within parameters can be used
  {
    #compute derivatives
    dS = (-beta * S * I)
    dI = ( beta * S * I) - (gamma * I)
    dR = (gamma * I)
    
    # combine results
    results = c (dS, dI, dR)
    list (results)
    }
  )
}

Parameters

contact_rate = 10                   # number of contacts per day
transmission_probability = 0.07     # transmission probability
infectious_period = 5               # infectious period

Compute values of beta (transmission rate) and gamma (recovery rate).

beta_value = contact_rate * transmission_probability
gamma_value = 1 / infectious_period

Compute Ro - Reproductive number.

Ro = beta_value / gamma_value

Disease dynamics parameters

parameter_list = c (beta = beta_value, gamma = gamma_value)

Initial values for sub-populations.

X = 9999        # susceptible hosts
Y = 1           # infectious hosts
Z = 0           # recovered hosts

Compute total population.

N = X + Y + Z

Initial state values for the differential equations.

initial_values = c (S = X/N, I = Y/N, R = Z/N)

Output timepoints.

timepoints = seq (0, 50, by=1)

Simulate the SIR edipemic

output = lsoda (initial_values, timepoints, sir_model, parameter_list)

Plot dynamics of Susceptibles sub-population.

plot (S ~ time, data = output, type='b', col = 'blue')  

Plot dynamics of Infectious sub-population.

plot (I ~ time, data = output, type='b', col = 'red') 

Plot dynamics of Recovered sub-population.

plot (R ~ time, data = output, type='b', col = 'green')

Plot dynamics of Susceptibles, Infectious and Recovered sub-populations in the same plot.

# susceptible hosts over time
plot (S ~ time, data = output, type='b', ylim = c(0,1), col = 'blue', ylab = 'S, I, R', main = 'SIR epidemic') 

# remain on same frame
par (new = TRUE)    

# infectious hosts over time
plot (I ~ time, data = output, type='b', ylim = c(0,1), col = 'red', ylab = '', axes = FALSE) 

# remain on same frame
par (new = TRUE)  

# recovered hosts over time
plot (R ~ time, data = output, type='b', ylim = c(0,1), col = 'green', ylab = '', axes = FALSE)

COMMENT:

The SIR epidemic model shows the number of susceptible hosts (blue), infectious hosts (red) and recovered hosts (green) over time. The majority of the population is susceptible at the beginning of the epidemic. But as the number of susceptible hosts decreases over time, the number of recoverd hosts increases. The number of infectious hosts increases until around day 20, and starts decreasing (Ro ≤ 1).

SEIR EPIDEMIOLOGICAL MODEL

Objective: To analyse the dynamics of the Susceptible-Latent-Infectious-Recovered (SEIR) epidemic model.

Remove all objects from workspace.

remove (list = objects())

Load add-on packages - deSolve - contains lsoda function - differential equation solver.

library (deSolve)

Function to compute derivatives of the differential equations.

seir_model = function (current_timepoint, state_values, parameters)
{
  # create state variables (Local variables)
  S = state_values [1]        # susceptibles
  E = state_values [2]        # exposed 
  I = state_values [3]        # infectious
  R = state_values [4]        # recovered
  
  with (
    as.list (parameters),     # variable names within parameters can be used
  {
    #compute derivatives
    dS = (-beta * S * I)
    dE = (beta * S * I) - (delta * E)
    dI = (delta * E) - (gamma * I)
    dR = (gamma * I)
    
    # combine results
    results = c (dS, dE, dI, dR)
    list (results)
    }
  )
}

Parameters

contact_rate = 10                   # number of contacts per day
transmission_probability = 0.07     # transmission probability
infectious_period = 5               # infectious period
latent_period = 3                   # latent period

Compute values of beta (transmission rate), gamma (recovery rate) and delta

beta_value = contact_rate * transmission_probability
delta_value = 1 / latent_period
gamma_value = 1 / infectious_period

Compute Ro - Reproductive number.

Ro = beta_value / gamma_value

Disease dynamics parameters

parameter_list = c (beta = beta_value, delta = delta_value, gamma = gamma_value)

Initial values for sub-populations.

W = 9998        # susceptible hosts
X = 50          # exposed hosts
Y = 5           # infectious hosts
Z = 0           # recovered hosts

Compute total population.

N = W + X + Y + Z

Initial state values for the differential equations.

initial_values = c (S = W/N, E = X/N, I = Y/N, R = Z/N)

Output timepoints.

timepoints = seq (0, 50, by=1)

Simulate the SEIR edipemic

output = lsoda (initial_values, timepoints, seir_model, parameter_list)

Plot dynamics of Susceptibles sub-population.

plot (S ~ time, data = output, type='b', col = 'blue')  

Plot dynamics of Exposed sub-population

plot (E ~ time, data = output, type='b', col = 'purple')

Plot dynamics of Infectious sub-population.

plot (I ~ time, data = output, type='b', col = 'red') 

Plot dynamics of Recovered sub-population.

plot (R ~ time, data = output, type='b', col = 'green')

Plot dynamics of Susceptibles, Exposed, Infectious and Recovered sub-populations in the same plot.

# susceptible hosts over time
plot (S ~ time, data = output, type='b', ylim = c(0,1), col = 'blue', ylab = 'S, E, I, R', main = 'SEIR epidemic') 

# remain on same frame
par (new = TRUE)    

# exposed hosts over time
plot (E ~ time, data = output, type='b', ylim = c(0,1), col = 'purple', ylab = '', axes = FALSE)

# remain on same frame
par (new = TRUE) 

# infectious hosts over time
plot (I ~ time, data = output, type='b', ylim = c(0,1), col = 'red', ylab = '', axes = FALSE) 

# remain on same frame
par (new = TRUE)  

# recovered hosts over time
plot (R ~ time, data = output, type='b', ylim = c(0,1), col = 'green', ylab = '', axes = FALSE)

# remain on same frame
par (new = TRUE) 

COMMENT:

The SEIR epidemic model shows over time the number of susceptible hosts (blue), exposed hosts (purple), infectious hosts (red) and recovered hosts (green) over time. At the early stages of the epidemic, a larger part of the population is susceptible. As in the SIR epidemiological model, the number of susceptible hosts decreases over time as the number of recoverd hosts increases. The SEIR model also adds the exposed stage as a condition for becoming infectious, which helps decrease the number of infectious hosts over time. The number of infectious hosts increases until around day 30, and starts decreasing (Ro ≤ 1).

SIS EPIDEMIOLOGICAL MODEL

Objective: To analyse the dynamics of the Susceptible-Infectious-Susceptible (SIS) epidemic model.

Remove all objects from workspace.

remove (list = objects())

Load add-on packages - deSolve - contains lsoda function - differential equation solver.

library (deSolve)

Function to compute derivatives of the differential equations.

sis_model = function (current_timepoint, state_values, parameters)
{
  # create state variables (Local variables)
  S = state_values [1]        # susceptibles
  I = state_values [2]        # infectious
  
  with (
    as.list (parameters),     # variable names within parameters can be used
  {
    #compute derivatives
    dS = (-beta * S * I) + (gamma * I)
    dI = ( beta * S * I) - (gamma * I)
    
    # combine results
    results = c (dS, dI)
    list (results)
    }
  )
}

Parameters

contact_rate = 10                   # number of contacts per day
transmission_probability = 0.07     # transmission probability
infectious_period = 5               # infectious period

Compute values of beta (transmission rate) and gamma (recovery rate).

beta_value = contact_rate * transmission_probability
gamma_value = 1 / infectious_period

Compute Ro - Reproductive number.

Ro = beta_value / gamma_value

Disease dynamics parameters

parameter_list = c (beta = beta_value, gamma = gamma_value)

Initial values for sub-populations.

X = 19992        # susceptible hosts
Y = 6            # infectious hosts

Compute total population.

N = X + Y 

Initial state values for the differential equations.

initial_values = c (S = X/N, I = Y/N)

Output timepoints.

timepoints = seq (0, 50, by=1)

Simulate the SIS edipemic

output = lsoda (initial_values, timepoints, sis_model, parameter_list)

Plot dynamics of Susceptibles sub-population.

plot (S ~ time, data = output, type='b', col = 'blue')  

Plot dynamics of Infectious sub-population.

plot (I ~ time, data = output, type='b', col = 'red') 

Plot dynamics of Susceptibles and Infectious sub-populations in the same plot.

# susceptible hosts over time
plot (S ~ time, data = output, type='b', ylim = c(0,1), col = 'blue', ylab = 'S, I, S', main = 'SIS epidemic') 

# remain on same frame
par (new = TRUE)    

# infectious hosts over time
plot (I ~ time, data = output, type='b', ylim = c(0,1), col = 'red', ylab = '', axes = FALSE) 

# remain on same frame
par (new = TRUE)  

COMMENT:

The SIS epidemiological model analyzes relationship between the number of susceptible hosts (blue) and infectious hosts (red) over time. The number of susceptible host increases as the number of infectious hosts increases over time. That is because in this model, prior infected hosts can become susceptible for future infections.

SEIS EPIDEMIOLOGICAL MODEL

Objective: To analyse the dynamics of the Susceptible-Latent-Infectious-Susceptible (SEIS) epidemic model.

Remove all objects from workspace.

remove (list = objects())

Load add-on packages - deSolve - contains lsoda function - differential equation solver.

library (deSolve)

Function to compute derivatives of the differential equations.

seis_model = function (current_timepoint, state_values, parameters)
{
  # create state variables (Local variables)
  S = state_values [1]        # susceptibles
  E = state_values [2]        # latent period
  I = state_values [3]        # infectious

  with (
    as.list (parameters),     # variable names within parameters can be used
  {
    #compute derivatives
    dS = (-beta * S * I) + (gamma * I)
    dE = (beta * S * I) - (delta * E)
    dI = (delta * E) - (gamma * I)
    
    # combine results
    results = c (dS, dE, dI)
    list (results)
    }
  )
}

Parameters

contact_rate = 10                   # number of contacts per day
transmission_probability = 0.07     # transmission probability
infectious_period = 5               # infectious period
latent_period = 3                   # latent period

Compute values of beta (transmission rate), gamma (recovery rate) and delta.

beta_value = contact_rate * transmission_probability
delta_value = 1 / latent_period
gamma_value = 1 / infectious_period

Compute Ro - Reproductive number.

Ro = beta_value / gamma_value

Disease dynamics parameters

parameter_list = c (beta = beta_value, gamma = gamma_value, delta = delta_value)

Initial values for sub-populations.

X = 9988       # susceptible hosts
Y = 9          # exposed hosts
Z = 3          # infectious hosts

Compute total population.

N = X + Y + Z 

Initial state values for the differential equations.

initial_values = c (S = X/N, E = Y/N, I = Z/N)

Output timepoints.

timepoints = seq (0, 50, by=1)

Simulate the SEIS edipemic

output = lsoda (initial_values, timepoints, seis_model, parameter_list)

Plot dynamics of Susceptibles sub-population.

plot (S ~ time, data = output, type='b', col = 'blue')  

Plot dynamics of Exposed sub-population

plot (E ~ time, data = output, type='b', col = 'purple')

Plot dynamics of Infectious sub-population.

plot (I ~ time, data = output, type='b', col = 'red') 

Plot dynamics of Susceptibles, Exposed, and Infectious sub-populations in the same plot.

# susceptible hosts over time
plot (S ~ time, data = output, type='b', ylim = c(0,1), col = 'blue', ylab = 'S, E, I, S', main = 'SEIS epidemic') 

# remain on same frame
par (new = TRUE)    

# exposed hosts over time
plot (E ~ time, data = output, type='b', ylim = c(0,1), col = 'purple', ylab = '', axes = FALSE)

# remain on same frame
par (new = TRUE) 

# infectious hosts over time
plot (I ~ time, data = output, type='b', ylim = c(0,1), col = 'red', ylab = '', axes = FALSE) 

# remain on same frame
par (new = TRUE)  

COMMENT:

The SEIS epidemiological model analyzes relationship between the number of susceptible hosts (blue), exposed hosts (purple) and infectious hosts (red) over time. As in the SIS model, prior infected hosts can become susceptible for future infections. The model shows that, as the number of susceptible hosts decreases, the numbers of exposed and infectious hosts increase, then stabilize.

SI EPIDEMIOLOGICAL MODEL

Objective: To analyse the dynamics of the Susceptible-Infectious (SI) epidemic model.

Remove all objects from workspace.

remove (list = objects())

Load add-on packages - deSolve - contains lsoda function - differential equation solver.

library (deSolve)

Function to compute derivatives of the differential equations.

si_model = function (current_timepoint, state_values, parameters)
{
  # create state variables (Local variables)
  S = state_values [1]        # susceptibles
  I = state_values [2]        # infectious
  
  with (
    as.list (parameters),     # variable names within parameters can be used
  {
    #compute derivatives
    dS = (-beta * S * I)
    dI = ( beta * S * I) 
    
    # combine results
    results = c (dS, dI)
    list (results)
    }
  )
}

Parameters

contact_rate = 10                   # number of contacts per day
transmission_probability = 0.07     # transmission probability
infectious_period = 20              # infectious period

Compute values of beta (transmission rate) and gamma (recovery rate).

beta_value = contact_rate * transmission_probability
gamma_value = 0

Compute Ro - Reproductive number.

Ro = beta_value / gamma_value

Disease dynamics parameters

parameter_list = c (beta = beta_value, gamma = gamma_value)

Initial values for sub-populations.

X = 9599        # susceptible hosts
Y = 9           # infectious hosts

Compute total population.

N = X + Y 

Initial state values for the differential equations.

initial_values = c (S = X/N, I = Y/N)

Output timepoints.

timepoints = seq (0, 50, by=1)

Simulate the SI edipemic

output = lsoda (initial_values, timepoints, si_model, parameter_list)

Plot dynamics of Susceptibles sub-population.

plot (S ~ time, data = output, type='b', col = 'blue')  

Plot dynamics of Infectious sub-population.

plot (I ~ time, data = output, type='b', col = 'red') 

Plot dynamics of Susceptibles and Infectious sub-populations in the same plot.

# susceptible hosts over time
plot (S ~ time, data = output, type='b', ylim = c(0,1), col = 'blue', ylab = 'S, I', main = 'SI epidemic') 

# remain on same frame
par (new = TRUE)    

# infectious hosts over time
plot (I ~ time, data = output, type='b', ylim = c(0,1), col = 'red', ylab = '', axes = FALSE) 

# remain on same frame
par (new = TRUE)  

COMMENT:

In the SI epidemiological model, hosts go from the susceptible stage to the infectious stage and remain there. The model shows an important decrease in susceptible hosts as the number of infectious hosts dramatically increases.

SIR/C EPIDEMIOLOGICAL MODEL

Objective: To analyse the dynamics of the Susceptible-Infectious-Recovered/Carrier (SIR/C) epidemic model.

Remove all objects from workspace.

remove (list = objects())

Load add-on packages - deSolve - contains lsoda function - differential equation solver.

library (deSolve)

Function to compute derivatives of the differential equations.

sirc_model = function (current_timepoint, state_values, parameters)
{
  # create state variables (Local variables)
  S = state_values [1]        # susceptibles
  I = state_values [2]        # infectious
  R = state_values [3]        # recovered
  C = state_values [4]        # carrier
  
  with (
    as.list (parameters),     # variable names within parameters can be used
  {
    #compute derivatives
    dS = (-beta * S * I) - (epsilon * beta * S * C)
    dI = ( beta * S * I) + (epsilon * beta * S * C) - (gamma * I)
    dR = (1 - q) * (gamma * I) + (tau * C)
    dC = (q * gamma * I) - (tau * C)

    # combine results
    results = c (dS, dI, dR, dC)
    list (results)
    }
  )
}

Parameters

contact_rate = 10                       # number of contacts per day
transmission_probability = 0.07         # transmission probability
infectious_period = 5                   # infectious period
length_of_time_in_carrier_state = 7     # length of time in carrier state
reduced_transmission_rate = 4           # chronic carriers compared to acute infections
acute_infections_proportion = 0.6       # acute infections that become carriers 

Compute values of beta (transmission rate) and gamma (recovery rate), tau (carrier state), q (acute infections) and epsilon (reduced transmission rate)

beta_value = contact_rate * transmission_probability
gamma_value = 1 / infectious_period
tau_value = 1 / length_of_time_in_carrier_state
epsilon_value = 4
q_value = 0.6

Compute Ro - Reproductive number.

Ro = beta_value / gamma_value

Disease dynamics parameters

parameter_list = c (beta = beta_value, gamma = gamma_value, tau = tau_value, epsilon = epsilon_value, q = q_value)

Initial values for sub-populations.

W = 19998        # susceptible hosts
X = 68          # infectious hosts
Y = 156          # carrier hosts
Z = 78          # recovered hosts

Compute total population.

N = W + X + Y + Z

Initial state values for the differential equations.

initial_values = c (S = W/N, I = X/N, C = Y/N, R = Z/N)

Output timepoints.

timepoints = seq (0, 50, by=1)

Simulate the SIR/C edipemic

output = lsoda (initial_values, timepoints, sirc_model, parameter_list)

Plot dynamics of Susceptibles sub-population.

plot (S ~ time, data = output, type='b', col = 'blue')  

Plot dynamics of Infectious sub-population.

plot (I ~ time, data = output, type='b', col = 'red') 

Plot dynamics of Carrier sub-population.

plot (R ~ time, data = output, type='b', col = 'purple')

Plot dynamics of Recovered sub-population.

plot (R ~ time, data = output, type='b', col = 'green')

Plot dynamics of Susceptibles, Infectious Carrier and Recovered sub-populations in the same plot.

# susceptible hosts over time
plot (S ~ time, data = output, type='b', ylim = c(0,1), col = 'blue', ylab = 'S, I, R, C', main = 'SIR/C epidemic') 

# remain on same frame
par (new = TRUE)    

# infectious hosts over time
plot (I ~ time, data = output, type='b', ylim = c(0,1), col = 'red', ylab = '', axes = FALSE) 

# remain on same frame
par (new = TRUE)  

# carrier hosts over time
plot (C ~ time, data = output, type='b', ylim = c(0,1), col = 'purple', ylab = '', axes = FALSE) 

# remain on same frame
par (new = TRUE)

# recovered hosts over time
plot (R ~ time, data = output, type='b', ylim = c(0,1), col = 'green', ylab = '', axes = FALSE)

COMMENT:

In the SIR/C epidemiological model, hosts go from the susceptible stage to the infectious stage and then to the recovery stage either directly or through a carrier stage first. The model shows an important decrease in susceptible hosts as the number of carrier hosts increases over time.