Skip to content

Instantly share code, notes, and snippets.

@cgrinker
Created January 15, 2022 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cgrinker/f66674e9c58d9c9d4262868951890009 to your computer and use it in GitHub Desktop.
Save cgrinker/f66674e9c58d9c9d4262868951890009 to your computer and use it in GitHub Desktop.
SIERS Model

SEIRS Model

u/coeyjoops linked an interesting tweet chain today about how long folks should be quarentining after infection. The analysis found that five to six days without a negative antigen at the end were enough to return to work without causing further infections.

The model discussed in the tweet chain is called SEIRS (stands for susceptible (S), exposed (E), infectious (I), and recovered (R).) Unlike the covid projections we see on Google/The CDC website which use the replicating factor to estimate infection trends, SEIRS simulates outbreaks over entire populations by modeling indivduals and connections across their social network. By modifying the parameters of SEIRS (how likely are you to get infected, how long do you stay infected, how effective are mitgations) we're able to make better informed decisions about things like quarentine periods, masking, and setting up social bubbles. SEIRS models aren't specific to COVID and can be applied to any communicable disease.

A Primer on Graphs

Look at This Graph SIERS makes use of a mathematical structure called a Graph to model disease transmission. Graphs model sets of objects and the relationships between them. They're analagous to Flowcharts or Webs

Graph Terminology

  • Nodes represent the objects.
  • Edges relate two objects together

image A family Tree is a graph where the nodes are people and the edges are the parent/child relationship/

  • Graph Algorithms walk a graph along it's edges to perform some task:

  • Edges can be Directed (one way only) An Example Flowchart

or Undirected (goes both ways like your father) image

SEIRS Model Node States

Each Node in our graph is a person and can be in four states. As they become infected and recovered they transition between these states. A node's current state effects how disease can move through the graph during the simulation.

  1. Susceptible to infection. How likely a person is infected is governed by the transmission parameter β (You're a BETA). This parameter might be tuned by how infectious a specific strain is, how vaccination attenuates that infection rate, or how pre infection interventions (like masking or social distancing) fare
  2. Exposed to Infection. How quickly a person becomes sick is governed by the progression paramter σ (aka The SIMGA Grindset)
  3. The Infectious State. How quickly a person recovers is governed by the recovery parameter γ (The Gamma/ Hulk coefficent) 3.5) A node which is in the Infectious state is able to exit the simulation by fucking dying. This is governed by the mortality parameter μI
  4. Recovered from infection. How long a person stays immune (or more correctly unable to infect others again) is governed by the re-susceptibility parameter ξ (Xi the letter not the Communist)

Quarentine Model Extension States

We can model the effectiveness of Quarentining exposed/infected individuals by adding two additional states:

  1. Exposed and Quarentining
  2. Infected and Quarentining

These states function the same as their hittin the club while sick counterparts, but can have different parameters regarding the likelyhood of infecting a neighbor in the graph

Simulation Steps

SEIRS simulations are run in two steps:

  1. Initialization Phase where we configure our graph
  2. Tick Phase Where we simulate interactions between people and how that causes infection to spread.

Intialization

  • Choose a population size. These are our graph Nodes. Everyone starts in the Susceptible state
  • Build the social network. Each graph node has some number of undirected edges to their adjacent neighbors representing "Close Contacts" These are the people you make contact with every tick of the simulation. Disease can spread either direction along the edge depending on the node's state
  • Seed some number of exposures/infections throughout the graph.

Simulation Tick

Transmission check

During each tick of the simulation a Node rolls to make contact with some portion of their close contacts (going to your mom's house) and rolls to make contact with a random global member of the network (getting coughed on on the bus.)

  • If a contact roll is sucessful we branch:
    1. If One node is Exposed/Infected and the other is Susceptible we roll for transmission. If the roll is sucessful the Susceptible node becomes an Exposed node
    2. If both nodes are Susceptible or at least one node is recovered, there is no transmission

Exposed to Infection Check

  • Each node which has been Exposed for time σ transitions to the Infected State

Infection to Dead Check

  • Each node which is Infected and rolls a μI dies and is removed from the graph.

Infection to Recovered Check

  • Each node which is Infected for time γ recovers

Exposed/Infection -> Quarintine State

  • Each node in the Exposed/Infection state has a probability to quarentine. In this state some number of edges between close contacts are dropped, and the system stops rolling against these nodes for a global infection. The likelihood to quarentine is governed by how much of a fuckboy you are

Re-susceptibility

  • Each node which is recovered for time ξ returns to the Susceptible state

Discussion Points

  • The simulation continues until either:
  1. Everyone Dies
  2. The Virus Dies
  3. The Virus becomes endemic where enough people are in the Recovered state to prevent exponential reinfection
  • Certain combinations of parameters can cause the virus to run forever, like the seasonal flu.

  • As u/coeyjoops linked SEIRS running on Delta varient's parameters seems to find a falloff in reduced transmission after five to six days. Any shorter you still infect folks, longer doesn't seem to reduce infections anymore

  • Generating the graph networks themsleves is a challenging part of modeling. Ryan's Python library has some suggestions about generating good graphs but it's tough to know for sure how closely they match our daily interactions.

  • If you're talking to an antivaxxer you might try explaining the model in the generic case (use Flu or Ebola) to them rather than pointing out how much of a moron they are.

Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment