Ebola

A growing number of Ebola cases have been reported in a small town. The following table shows the number of reported cases each day for the last 11 days.

Day 1 2 3 4 5 6 7 8 9 10 11

Cases 1 2 2 3 3 6 4 6 13 13 20

You have been given additional information that will help you to model the disease

The population of the town is 100,000

An inf#ected person will infect others at a rate of 3 per day

The latent period of the disease is 10 days

The average infectious duration is assumed to be 2 days, since after 2 days most infected people will be too ill to have contact with others

Some individuals will die from infection while others will recover and become immune. In either case we can assume they are “removed” from the system

The mayor of the town is considering two possible ways to keep the disease under control

Impose social restrictions on the whole town. This will reduce the transmission rate from 3 to 2

Force anyone suspected of having latent Ebola into quarantine. Each day, 20% of infected people who are in the latent period of their infection are discovered and moved into quarantine. The quarantine period is 14 days.

# Load the required package

library(deSolve)
## Warning: package 'deSolve' was built under R version 4.5.2
# Define the SEIR model

ODE_system <- function(t, state, parameters) {
  with(as.list(c(state, parameters)), {

    # Force of infection
    lambda <- beta * I / N

    # Differential equations
    dS <- -lambda * S
    dE <-  lambda * S - sigma * E
    dI <-  sigma * E - gamma * I
    dR <-  gamma * I

    list(c(dS, dE, dI, dR))
  })
}
# Define initial conditions

state <- c(
  S = 99999,
  E = 0,
  I = 1,
  R = 0
)
# Define parameters

parameters <- c(
  beta = 3,      # transmission rate per day
  sigma = 1/10,  # latent -> infectious
  gamma = 1/2,   # infectious -> removed
  N = 100000
)
# Define time steps

times <- seq(0, 60, by = 1)
# Solve with deSolve

out <- ode(
  y = state,
  times = times,
  func = ODE_system,
  parms = parameters
)

out <- as.data.frame(out)
head(out)
##   time        S         E         I         R
## 1    0 99999.00  0.000000 1.0000000 0.0000000
## 2    1 99996.52  2.350496 0.7136612 0.4128424
## 3    2 99994.46  4.091527 0.6934755 0.7570302
## 4    3 99992.22  5.832185 0.8154804 1.1295925
## 5    4 99989.47  7.906637 1.0389306 1.5892236
## 6    5 99985.89 10.562292 1.3609281 2.1848420
# Plot the epidemic curves

plot(out$time, out$S, type="l", col="blue", ylim=c(0,100000),
     xlab="Time (days)", ylab="Population",
     main="SEIR Model of Ebola Outbreak")

lines(out$time, out$E, col="orange")
lines(out$time, out$I, col="red")
lines(out$time, out$R, col="green")

legend("right",
       legend=c("Susceptible","Exposed","Infectious","Removed"),
       col=c("blue","orange","red","green"),
       lty=1)

library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.5.2
library(tidyr)
## Warning: package 'tidyr' was built under R version 4.5.2
out_long <- pivot_longer(out,
                         cols = c(S,E,I,R),
                         names_to = "Compartment",
                         values_to = "Count")

ggplot(out_long, aes(x=time, y=Count, colour=Compartment)) +
  geom_line(size=1.2) +
  labs(title="SEIR Model Simulation of Ebola Outbreak",
       x="Time (days)",
       y="Population") +
  theme_minimal()
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once per session.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.