Introduction

In this lesson, we will study the SEIR model—a compartmental model widely used in epidemiology—with a focus on understanding the exposed compartment, which represents individuals who have been exposed to a disease but are not yet infectious. To bring these concepts to life, we’ll apply the SEIR model to a real-world example, Hepatitis E Virus (HEV).

Learning Objectives

By the end of this lesson, you should be able to:

  • Understand the SEIR model and the role of the exposed compartment.
  • Implement a generic SEIR model in R.
  • Customize the SEIR model for Hepatitis E Virus (HEV) to study transmission dynamics in a realistic context.

Packages

The following packages are necessary for this lesson:

if (!require(pacman)) install.packages("pacman")
pacman::p_load(deSolve, ggplot2, tidyverse)

1 Introduction to the SEIR Model

The classic SIR model assumes individuals become infectious immediately upon exposure. However, many diseases exhibit a latent period — a stage where individuals have been exposed but are not yet infectious. The SEIR model addresses this by adding an Exposed (E) compartment, providing a more realistic framework for modeling diseases with incubation periods.

1.1 Why Include the Exposed (E) Compartment?

In the SEIR model, we add an Exposed (E) compartment to account for the latent period — the time between exposure to the virus and becoming infectious. This stage is crucial for understanding how diseases actually progress.

The SIR model assumes that individuals are immediately infectious upon exposure, but many diseases have an incubation period. The SEIR model captures this delay, making it more accurate for diseases like Hepatitis E Virus (HEV), influenza, and measles. By including the E compartment, we model both the incubation period and the infectious period separately, reflecting a more realistic course of infection.

1.2 Conceptualizing the SEIR Model

The SEIR model divides a population into four compartments:

  • Susceptible (S): Individuals who can become infected.
  • Exposed (E): Individuals who have been exposed to the virus but are not yet infectious.
  • Infectious (I): Individuals who can transmit the virus to susceptible individuals.
  • Recovered (R): Individuals who have recovered and are now immune.

And three critical parameters:

  • Transmission coefficient (β): The rate at which susceptible individuals become infected.
  • Progression rate (σ): The rate at which exposed individuals become infectious (1/latent period).
  • Recovery rate (γ): The rate at which infected individuals recover.

1.2.1 SEIR Model Equations

The SEIR model can be described by a system of differential equations:

  • dS/dt = \(-\beta \times S \times I\)
  • dE/dt = \(\beta \times S \times I - \sigma \times E\)
  • dI/dt = \(\sigma \times E - \gamma \times I\)
  • dR/dt = \(\gamma \times I\)

where:

  • \(\beta\) is the transmission rate.
  • \(\sigma\) is the rate at which exposed individuals become infectious (1/latent period).
  • \(\gamma\) is the recovery rate (1/infectious period).

2 Implementing the SEIR Model in R

2.0.1 Step 1: Setting up Initial Conditions and Parameters

Let’s define the parameters, initial conditions, and time span for our model.

# Initial conditions
initial_state <- c(S = 990, E = 5, I = 4, R = 1)

# Parameters
parameters <- c(beta = 0.002,  # Transmission rate
                sigma = 0.1,   # Rate of progression from exposed to infectious
                gamma = 0.05)  # Recovery rate

# Time span for simulation
times <- seq(0, 200, by = 1)

2.0.2 Step 2: Writing the SEIR Model Function

Define the SEIR model as a function in R.

seir_model <- function(time, state, parameters) {
  with(as.list(c(state, parameters)), {
    
    # Differential equations
    dS <- -beta * S * I
    dE <- beta * S * I - sigma * E
    dI <- sigma * E - gamma * I
    dR <- gamma * I
    
    # Return list of rates of change
    list(c(dS, dE, dI, dR))
  })
}

2.0.3 Step 3: Solving the Differential Equations

Use the ode() function from the deSolve package to solve this system.

# Solve the SEIR model
seir_out <- ode(y = initial_state, times = times, func = seir_model, parms = parameters)

# Convert output to a data frame
seir_out <- as.data.frame(seir_out)

2.0.4 Step 4: Visualizing the Results

Plot the model output to visualize the changes over time in each compartment.

ggplot(seir_out, aes(x = time)) +
  geom_line(aes(y = S, color = "Susceptible")) +
  geom_line(aes(y = E, color = "Exposed")) +
  geom_line(aes(y = I, color = "Infectious")) +
  geom_line(aes(y = R, color = "Recovered")) +
  labs(title = "SEIR Model Dynamics", x = "Time (days)", y = "Population Count") +
  scale_color_manual(values = c("Susceptible" = "blue", "Exposed" = "orange", "Infectious" = "red", "Recovered" = "green")) +
  theme_minimal() +
  theme(legend.title = element_blank())

3 HEV Case Study

3.1 Background on Hepatitis E Virus (HEV)

Hepatitis E Virus (HEV) is a liver disease transmitted through contaminated water. It has a well-defined incubation period, making the SEIR model an excellent tool to understand HEV dynamics.

3.1.1 Key Epidemiological Parameters for HEV

  1. Transmission rate (\(\beta\)): Specific to the HEV spread in a given population.
  2. Incubation period (1/\(\sigma\)): The latent period, estimated around 2-4 weeks.
  3. Infectious period (1/\(\gamma\)): Average period over which individuals can spread the disease.

3.1.2 Modifying the SEIR Model for HEV

To adapt our SEIR model for HEV, we’ll use HEV-specific parameters and a modified incubation period.

# Parameters specific to HEV
hev_parameters <- c(beta = 0.0015,  # Reduced transmission rate for HEV
                    sigma = 0.07,   # Progression rate for HEV (approx. 2 weeks latent period)
                    gamma = 0.04)   # Recovery rate for HEV (approx. 25 days infectious period)

# Solve the adapted SEIR model for HEV
hev_out <- ode(y = initial_state, times = times, func = seir_model, parms = hev_parameters)

# Convert output to data frame for plotting
hev_out <- as.data.frame(hev_out)

3.1.3 Plotting HEV Model Results

ggplot(hev_out, aes(x = time)) +
  geom_line(aes(y = S, color = "Susceptible")) +
  geom_line(aes(y = E, color = "Exposed")) +
  geom_line(aes(y = I, color = "Infectious")) +
  geom_line(aes(y = R, color = "Recovered")) +
  labs(title = "SEIR Model for Hepatitis E Virus", x = "Time (days)", y = "Population Count") +
  scale_color_manual(values = c("Susceptible" = "blue", "Exposed" = "orange", "Infectious" = "red", "Recovered" = "green")) +
  theme_minimal() +
  theme(legend.title = element_blank())

4 Conclusion

In this lesson, we explored the SEIR model with a focus on the exposed compartment and applied it to Hepatitis E Virus. Including an exposed compartment allows us to realistically model diseases with latent periods, like HEV.

5 Answer Key

6 Contributors

The following team members contributed to this lesson:

7 References

  • Modeling Infectious Diseases in Humans and Animals - M. J. Keeling & P. Rohani.
  • Hepatitis E: Epidemiology and Disease Burden - WHO Report.

This work is licensed under the Creative Commons Attribution Share Alike license. Creative Commons License