# Table of Contents

# Comp

EpiJS module for creating compartments, which can be combined into models.

Import it with:

       const comp = require('@epispot/epijs').comp

# Idiom

Class for a custom compartments.

# Parameters

  • equation String (opens new window) The equation for the compartment. This defines what to run to get a new value for the next day in the model. Use any variable in the equation (1 char max), but when making this a model, you need to define this in the key. If using other compartment classes, they each have their own corresponding variable:
    • 'S' - Susceptible
    • 'E' - Exposed
    • 'I' - Infectious
    • 'R' - Recovered
    • 'D' - Dead
    • 'C' - Critical
    • 'H' - Hospitalized
    • 'V' - Vaccinated
    • 'w' - Reserved for stochastic models. If put, it will be replaced with a random number generated from the gaussian distribution.

# Examples

let susceptible = new Idiom("S-(B*S*I)")

# Susceptible

Class for Suscepible compartment.

# Parameters

  • next Array (opens new window) List of rates of the next compartments This is multiplied by the current susceptible population.
  • prev Array (opens new window) List of rates of the previous compartments, which include sub-arrays with the compartment id (one letter only), as a string, and the rate for the compartment. If reffering to this compartment's population, use "S" as the id. This parameter is useful if you want to model a disease with re-susceptibility.
  • stochastic Boolean (opens new window) If true, the compartment will be stochastic. You can still pass in your normal equation, and epijs will auto generate the equations from what you pass in.

# Examples

// Note that you can pass in a number as a rate too, 
     // but we use a string because we want to multiply 
     // by other compartment populations. This applies to the prev parameter too. 
     let S = new Susceptible(["I*0.4/N"], [], true)

# Infected

Class for Infected compartment.

# Parameters

  • next Array (opens new window) List of rates of the next compartments This is multiplied by the current infected population.
  • prev Array (opens new window) List of rates of the previous compartments, which include sub-arrays with the compartment id (one letter only), as a string, and the rate for the compartment. If reffering to this compartment's population, use "I" as the id.
  • stochastic Boolean (opens new window) If true, the compartment will be stochastic.

# Examples

// Note that you can pass in a string as a rate too, 
     // but we use a number in this case because we don't need to multiply 
     // by other compartment populations. We do actually do this for the prev parameter, though.
     let I = new Infected([0.3], [["S", "I*0.4/N"]], false)

# Exposed

Class for Exposed compartment.

# Parameters

  • next Array (opens new window) List of rates of the next compartments This is multiplied by the current exposed population.
  • prev Array (opens new window) List of rates of the previous compartments, which include sub-arrays with the compartment id (one letter only), as a string, and the rate for the compartment. If reffering to this compartment's population, use "E" as the id.
  • stochastic Boolean (opens new window) If true, the compartment will be stochastic.

# Examples

// Note that you can pass in a string as a rate too, 
     // but we use a number in this case because we don't need to multiply 
     // by other compartment populations. We do actually do this for the prev parameter, though.
     let E = new Exposed([1/14], ["S*0.4/N"], false)

# Critical

Class for Critical compartment.

# Parameters

  • next Array (opens new window) List of rates of the next compartments This is multiplied by the current critical population.
  • prev Array (opens new window) List of rates of the previous compartments, which include sub-arrays with the compartment id (one letter only), as a string, and the rate for the compartment. If reffering to this compartment's population, use "C" as the id.
  • stochastic Boolean (opens new window) If true, the compartment will be stochastic.

# Examples

// Note that you can pass in a string as a rate too, 
     // but we use a number in this case because we don't need to multiply 
     // by other compartment populations.
     let C = new Critical([0.14, 0.1], [["H", 0.3]], false)

# Hospitalized

Class for Hospitalized compartment.

# Parameters

  • next Array (opens new window) List of rates of the next compartments This is multiplied by the current hospitalized population.
  • prev Array (opens new window) List of rates of the previous compartments, which include sub-arrays with the compartment id (one letter only), as a string, and the rate for the compartment. If reffering to this compartment's population, use "H" as the id.
  • stochastic Boolean (opens new window) If true, the compartment will be stochastic.

# Examples

// Note that you can pass in a string as a rate too, 
     // but we use a number in this case because we don't need to multiply 
     // by other compartment populations.
     let H = new Hospitalized([0.3], [["I", 0.1], ["E", 0.2]], false)

# Dead

Class for the Dead compartment.

# Parameters

  • next Array (opens new window) List of rates of the next compartments. This is multiplied by the current dead population. Useful if you want to have a dead population that can also be the walking dead.
  • prev Array (opens new window) List of rates of the previous compartments, which include sub-arrays with the compartment id (one letter only), as a string, and the rate for the compartment. If reffering to this compartment's population, use "D" as the id.
  • stochastic Boolean (opens new window) If true, the compartment will be stochastic.

# Examples

// Note that you can pass in a string as a rate too, 
     // but we use a number in this case because we don't need to multiply 
     // by other compartment populations. We do actually do this for the prev parameter, though.
     let D = new Dead([0.3], [["I", 0.3]], false) // This disease also gives you a 3/10 chance to come alive after death.

# Vaccinated

Class for Vaccinated compartment.

# Parameters

  • next Array (opens new window) List of rates of the next compartments, good if the vaccine isn't 100% effective. This is multiplied by the current vaccinated population.
  • prev Array (opens new window) List of rates of the previous compartments, which include sub-arrays with the compartment id (one letter only), as a string, and the rate for the compartment. If reffering to this compartment's population, use "V" as the id.
  • stochastic Boolean (opens new window) If true, the compartment will be stochastic.

# Examples

// Note that you can pass in a string as a rate too, 
     // but we use a number in this case because we don't need to multiply 
     // by other compartment populations. We do actually do this for the prev parameter, though.
     let I = new Infected([0.001], ["S*0.4"], false)

# Recovered

Class for Recovered compartment.

# Parameters

  • next Array (opens new window) List of rates of the next compartments, good if the vaccine isn't 100% effective. This is multiplied by the current vaccinated population.
  • prev Array (opens new window) List of rates of the previous compartments, which include sub-arrays with the compartment id (one letter only), as a string, and the rate for the compartment. If reffering to this compartment's population, use "V" as the id.
  • stochastic Boolean (opens new window) If true, the compartment will be stochastic.

# Examples

// Note that you can pass in a string as a rate too, 
     // but we use a number in this case because we don't need to multiply 
     // by other compartment populations. We do actually do this for the prev parameter, though.
     let R = new Recovered([ ], [["I", 0.1]], false)