Hans Nesse - Global Health - SIR Model (with vaccine)

Population graph label

Time (days)

The SIR models the flows of people between three states: susceptible (S), infected (I), and resistant (R). Each of those variables represents the number of people in those groups. The parameters alpha and beta partially control how fast people move from being susceptible to infected (beta), and from infected to resistant (gamma).

The SIR model is used where individuals infect each other directly (rather than through a disease vector such as a mosquito). An individual who recovers from the illness is also modeled to have perfect immunity to the disease thereafter. Contact between people is also modeled to be random.

The rate that people become infected is proportional to the number of people who are infected, and the number of people who are susceptible. If there are lots of people infected, the chances of a susceptible coming into contact with someone who is infected is high. Likewise, if there are very few people who are susceptible, the chances of a susceptible coming into contact with an infected is lower (since most of the contact would be between the non-susceptible people--either infected or resistant).

This implementation includes an additional parameter, nu, which allows people to become vaccinated. A vaccinated person moves from being susceptible to being resistant without going through the infected stage.

The boxes on the right side of the page control the parameters of the model. The page should load with some parameters already in the box. Click "submit" to run the model. The parameters can all be modified and the model re-run. The parameters are
BetaThe parameter controlling how often a susceptible-infected contact results in a new infection.
GammaThe rate an infected recovers and moves into the resistant phase.
NuThe rate at which susceptible become vaccinated.
Initial susceptibleThe number of susceptible individuals at the beginning of the model run.
Initial infectedThe number of infected individuals at the beginning of the model run.
Initial recoveredThe number of recovered individuals at the beginning of the model run.
IterationsControls how long the model will run (each iteration is .01 units of time).
This program runs on your computer, so some computers may run faster than others. It is probably a good idea not to set the number iterations or the initial populations too high, since it will take longer to run. Note that cookies must be enabled for the algorithm to function.

This is an ordinary differential equation model, described by the following equation:

derivative of S with respect to t equals
The simulation uses the fourth-order Runge-Kutta algorithm to solve it numerically, with a step size fixed at 0.01, written in JavaScript. The plotting methods are from the flot module. Both the ode simulation and the script in this page calling it are new, so there may still be some unanticipated bugs (I am also fairly new to the language, so my code may be inefficient or bizarre in places). Internet Explorer may have a different look than other browsers, since it has not yet adopted the canvas element, which is used in plotting.