A simple epidemic and endemic compartmental SIR (Susceptible, Infected, Recovered) infectious disease model using Javascript and HTML5.

The model implements these fairly standard iterative equations for S, I and R:-

s' = s - cis/t - bs + bt - vbt + wi i' = i + cis/t - ki - bi r' = r + ki - br + vbt - wi

All the usual constraints hold, like homogeneous mixing and vaccination at birth.

Note that the total population is constant.

Essentially:-

s' = s - new cases - susceptible deaths + births - vaxed + waned i' = i + new cases - recovered cases - infected deaths r' = r + recovered cases - recovered deaths + vaxed - waned

Where:-

t = Total population. This is always constant.

s,i,r = Number of susceptible, infected and recovered individuals at any one time.

c = Contact rate. The way to interpret this is to this of a totally susceptible population and a single infection. If on average the infective infects one person every other iteration then c=0.5.

k = Recovery rate. If it takes on average 10 days to recover then k = 0.1.

b = Birth and death rate. This is a fraction of the total population per iteration.

v = Vaccination rate. The fraction of newborns vaccinated at birth.

w = Wane rate after being immune from natural infection or vaccination. Think of this like k. If it takes 100 iterations for immunity to wane then w=0.01.

The initial values of s and i are input as fields s0 and i0. The initial value of r is then t-s0-i0.

The following metrics are calculated along with the graphs and tables:-

R0 = Basic reproduction number = c / (k+b) Se = Epidemic threshold of susceptibles = t / R0 H = Herd immunity threshold = 1 - 1/R0

The input parameters are integers, reals or strings as required.

c,k,b,v and w can be defined based on the current iteration using javascript functions.

For example in the measles2 scenario, the contact rate c is defined with a function to add seasonal variation:-

function (iter) { return 3.6*(1.0 + 0.036*Math.sin(iter*0.0172141)); }

0.0172141 being 2*pi/365 – i.e. every 365 iterations is a ‘season’ with a sin() shaped curve.

c,k,b,v and w can also be entered as expressions; e.g. 1/3 instead of 0.333333.

You can click on the model home page or one of the scenario links to see some predefined setups. If you tweak any of the value and click the Plot button, the graphs and outputs will be updated. You can also copy the resulting URL in the browser to link to your model.