Difference between revisions of "SIR model: swine flu"

From JSXGraph Wiki
Jump to navigationJump to search
 
(28 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
The SIR model (see also [[Epidemiology: The SIR model]]) tries to predict influenza epidemics. Here, we try to model the spreading of the H1N1 virus, aka swine flu.
 +
* According to the [http://www.cdc.gov/ CDC Centers of Disease Control and Prevention]: "Adults shed influenza virus from the day before symptoms begin through 5-10 days after illness onset. However, the amount of virus shed, and presumably infectivity, decreases rapidly by 3-5 days after onset in an experimental human infection model." So, here we set <math>\gamma=1/7=0.1428</math> as the recovery rate. This means, on average an infected person sheds the virus for 7 days.
 +
* In [http://www.pubmedcentral.nih.gov/articlerender.fcgi?artid=2715422 Modeling influenza epidemics and pandemics: insights into the future of swine flu (H1N1)] the authors estimate the reproduction rate <math>R_0</math> of the virus to be about <math>2</math>. For the SIR model this means: the reproduction rate <math>R_0</math> for influenza is equal to the infection rate of the strain (<math>\beta</math>) multiplied by the duration of the infectious period (<math>1/\gamma</math>), i.e.
 +
:<math>\beta = R_0\cdot \gamma</math>. Therefore, we set <math>\beta = 2\cdot 1/7 = 0.2857.</math> For the 1918–1919 pandemic <math>R_0</math> is estimated to be between 2 and 3, whereas for the seasonal flu the range for <math>R_0</math> is 0.9 to 2.1.
 +
* In [http://www.newscientist.com/article/dn17109-first-analysis-of-swine-flu-spread-supports-pandemic-plan.html] the mortality is estimated to be approximately 0.4 per cent.
 +
* We run the simulation for a population of 1 million people, where 1 person is infected initially, i.e. <math>s=1E{-6}</math>. Thus,  S(0) = 1, I(0) = 1.E-6, R(0) = 0.
 +
 +
The lines in the JSXGraph-simulation below have the following meaning:
 +
* <span style="color:Blue">Blue: Rate of susceptible population</span>
 +
* <span style="color:red">Red: Rate of infected population</span>
 +
* <span style="color:green">Green: Rate of recovered population
 
<html>
 
<html>
<form><input type="button" value="clear and run a simulation of 100 days" onClick="clearturtle();run()">
+
<form><input type="button" value="clear and run a simulation of 200 days" onClick="clearturtle();run()">
 
<input type="button" value="stop" onClick="stop()">
 
<input type="button" value="stop" onClick="stop()">
 
<input type="button" value="continue" onClick="goOn()"></form>
 
<input type="button" value="continue" onClick="goOn()"></form>
 
</html>
 
</html>
 +
 
<jsxgraph width="700" height="500">
 
<jsxgraph width="700" height="500">
var brd = JXG.JSXGraph.initBoard('jxgbox', {originX: 20, originY: 300, unitX: 7, unitY: 250});
+
var brd = JXG.JSXGraph.initBoard('jxgbox', { boundingbox: [-6.66, 1.2, 226.66, -0.8], axis:true});
 
   
 
   
var S = brd.createElement('turtle',[],{strokeColor:'blue',strokeWidth:3});
+
var S = brd.create('turtle',[],{strokeColor:'blue',strokeWidth:3});
var I = brd.createElement('turtle',[],{strokeColor:'red',strokeWidth:3});
+
var I = brd.create('turtle',[],{strokeColor:'red',strokeWidth:3});
var R = brd.createElement('turtle',[],{strokeColor:'green',strokeWidth:3});
+
var R = brd.create('turtle',[],{strokeColor:'green',strokeWidth:3});
 
   
 
   
var xaxis = brd.createElement('axis', [[0,0], [1,0]], {});
+
var s = brd.create('slider', [[0,-0.3], [60,-0.3],[0,1E-6,1]], {name:'s'});
var yaxis = brd.createElement('axis', [[0,0], [0,1]], {});
+
var beta = brd.create('slider', [[0,-0.4], [60,-0.4],[0,0.2857,1]], {name:'&beta;'});
 +
var gamma = brd.create('slider', [[0,-0.5], [60,-0.5],[0,0.1428,0.5]], {name:'&gamma;'});
 +
var mort = brd.create('slider', [[0,-0.6], [60,-0.6],[0,0.4,10.0]], {name:'% mortality'});
 +
brd.create('text', [90,-0.3, "initially infected population rate"]);
 +
brd.create('text', [90,-0.4, function(){ return "&beta;: infection rate, R<sub>0</sub>="+(beta.Value()/gamma.Value()).toFixed(2);}]);
 +
brd.create('text', [90,-0.5, function(){ return "&gamma;: recovery rate = 1/(days of infection), days of infection= "+(1/gamma.Value()).toFixed(1);}]);
 
   
 
   
var s = brd.createElement('slider', [[0,-0.3], [30,-0.3],[0,0.03,1]], {name:'s'});
+
var t = 0; // global
brd.createElement('text', [40,-0.3, "initially infected population rate"]);
+
var beta = brd.createElement('slider', [[0,-0.4], [30,-0.4],[0,0.5,1]], {name:'&beta;'});
+
brd.create('text', [100,-0.2,
brd.createElement('text', [40,-0.4, "&beta;: infection rate"]);
+
        function() {return "Day "+t+
var gamma = brd.createElement('slider', [[0,-0.5], [30,-0.5],[0,0.3,1]], {name:'&gamma;'});
+
                          ": infected="+(1000000*I.Y()).toFixed(1)+
brd.createElement('text', [40,-0.5, "&gamma;: recovery rate = 1/(days of infection)"]);
+
                          " recovered="+(1000000*R.Y()).toFixed(1)+
 +
                          " dead="+(1000000*R.Y()*mort.Value()*0.01).toFixed(0);}]);
 +
 +
S.hideTurtle();
 +
I.hideTurtle();
 +
R.hideTurtle();
 +
 +
function clearturtle() {
 +
  S.cs();
 +
  I.cs();
 +
  R.cs();
 +
 +
  S.hideTurtle();
 +
  I.hideTurtle();
 +
  R.hideTurtle();
 +
}
 +
 +
function run() {
 +
  S.setPos(0,1.0-s.Value());
 +
  R.setPos(0,0);
 +
  I.setPos(0,s.Value());
 +
 +
  delta = 1; // global
 +
  t = 0;  // global
 +
  loop();
 +
}
 +
 +
function turtleMove(turtle,dx,dy) {
 +
  turtle.moveTo([dx+turtle.X(),dy+turtle.Y()]);
 +
}
 +
 +
function loop() {
 +
  var dS = -beta.Value()*S.Y()*I.Y();
 +
  var dR = gamma.Value()*I.Y();
 +
  var dI = -(dS+dR);
 +
  turtleMove(S,delta,dS);
 +
  turtleMove(R,delta,dR);
 +
  turtleMove(I,delta,dI);
 +
 +
  t += delta;
 +
  if (t<200.0) {
 +
    active = setTimeout(loop,10);
 +
  }
 +
}
 +
function stop() {
 +
  if (active) clearTimeout(active);
 +
  active = null;
 +
}
 +
function goOn() {
 +
  if (t>0) {
 +
    if (active==null) {
 +
      active = setTimeout(loop,10);
 +
    }
 +
  } else {
 +
    run();
 +
  }
 +
 +
}
 +
</jsxgraph>
 +
 
 +
===External links===
 +
* [http://www.cdc.gov/flu/professionals/acip/clinical.htm Clinical Signs and Symptoms of Influenza]
 +
* [http://www.pubmedcentral.nih.gov/articlerender.fcgi?artid=2715422 Modeling influenza epidemics and pandemics: insights into the future of swine flu (H1N1)]
 +
* [http://www.newscientist.com/article/dn17109-first-analysis-of-swine-flu-spread-supports-pandemic-plan.html First analysis of swine flu spread supports pandemic plan]
 +
* [http://jsxgraph.org JSXGraph Homepage]
 +
 
 +
===The underlying JavaScript code===
 +
<source lang="xml">
 +
<html>
 +
<form><input type="button" value="clear and run a simulation of 200 days" onClick="clearturtle();run()">
 +
<input type="button" value="stop" onClick="stop()">
 +
<input type="button" value="continue" onClick="goOn()"></form>
 +
</html>
 +
</source>
 +
 
 +
<source lang="javascript">
 +
var brd = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-6.66, 1.2, 226.66, -0.8], axis:true});
 +
 +
var S = brd.create('turtle',[],{strokeColor:'blue',strokeWidth:3});
 +
var I = brd.create('turtle',[],{strokeColor:'red',strokeWidth:3});
 +
var R = brd.create('turtle',[],{strokeColor:'green',strokeWidth:3});
 +
 +
var s = brd.create('slider', [[0,-0.3], [60,-0.3],[0,1E-6,1]], {name:'s'});
 +
var beta = brd.create('slider', [[0,-0.4], [60,-0.4],[0,0.2857,1]], {name:'&beta;'});
 +
var gamma = brd.create('slider', [[0,-0.5], [60,-0.5],[0,0.1428,0.5]], {name:'&gamma;'});
 +
var mort = brd.create('slider', [[0,-0.6], [60,-0.6],[0,0.4,10.0]], {name:'% mortality'});
 +
brd.create('text', [90,-0.3, "initially infected population rate"]);
 +
brd.create('text', [90,-0.4, function(){ return "&beta;: infection rate, R<sub>0</sub>="+(beta.Value()/gamma.Value()).toFixed(2);}]);
 +
brd.create('text', [90,-0.5, function(){ return "&gamma;: recovery rate = 1/(days of infection), days of infection= "+(1/gamma.Value()).toFixed(1);}]);
 
   
 
   
 
var t = 0; // global
 
var t = 0; // global
 
   
 
   
brd.createElement('text', [40,-0.2,  
+
brd.create('text', [100,-0.2,  
         function() {return "Day "+t+": infected="+brd.round(7900000*I.Y(),1)+" recovered="+brd.round(7900000*R.Y(),1);}]);
+
         function() {return "Day "+t+
 +
                          ": infected="+(1000000*I.Y()).toFixed(1)+
 +
                          " recovered="+(1000000*R.Y()).toFixed(1)+
 +
                          " dead="+(1000000*R.Y()*mort.Value()*0.01).toFixed(0);}]);
 
   
 
   
 
S.hideTurtle();
 
S.hideTurtle();
Line 63: Line 171:
 
   
 
   
 
   t += delta;
 
   t += delta;
   if (t<100.0) {
+
   if (t<200.0) {
 
     active = setTimeout(loop,10);
 
     active = setTimeout(loop,10);
 
   }
 
   }
Line 81: Line 189:
 
   
 
   
 
}
 
}
</jsxgraph>
+
</source>
 +
 
 +
[[Category:Examples]]
 +
[[Category:Turtle Graphics]]

Latest revision as of 14:46, 8 June 2011

The SIR model (see also Epidemiology: The SIR model) tries to predict influenza epidemics. Here, we try to model the spreading of the H1N1 virus, aka swine flu.

  • According to the CDC Centers of Disease Control and Prevention: "Adults shed influenza virus from the day before symptoms begin through 5-10 days after illness onset. However, the amount of virus shed, and presumably infectivity, decreases rapidly by 3-5 days after onset in an experimental human infection model." So, here we set [math]\gamma=1/7=0.1428[/math] as the recovery rate. This means, on average an infected person sheds the virus for 7 days.
  • In Modeling influenza epidemics and pandemics: insights into the future of swine flu (H1N1) the authors estimate the reproduction rate [math]R_0[/math] of the virus to be about [math]2[/math]. For the SIR model this means: the reproduction rate [math]R_0[/math] for influenza is equal to the infection rate of the strain ([math]\beta[/math]) multiplied by the duration of the infectious period ([math]1/\gamma[/math]), i.e.
[math]\beta = R_0\cdot \gamma[/math]. Therefore, we set [math]\beta = 2\cdot 1/7 = 0.2857.[/math] For the 1918–1919 pandemic [math]R_0[/math] is estimated to be between 2 and 3, whereas for the seasonal flu the range for [math]R_0[/math] is 0.9 to 2.1.
  • In [1] the mortality is estimated to be approximately 0.4 per cent.
  • We run the simulation for a population of 1 million people, where 1 person is infected initially, i.e. [math]s=1E{-6}[/math]. Thus, S(0) = 1, I(0) = 1.E-6, R(0) = 0.

The lines in the JSXGraph-simulation below have the following meaning:

* Blue: Rate of susceptible population
* Red: Rate of infected population
* Green: Rate of recovered population

External links

The underlying JavaScript code

<html>
<form><input type="button" value="clear and run a simulation of 200 days" onClick="clearturtle();run()">
<input type="button" value="stop" onClick="stop()">
<input type="button" value="continue" onClick="goOn()"></form>
</html>
var brd = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-6.66, 1.2, 226.66, -0.8], axis:true});
 
var S = brd.create('turtle',[],{strokeColor:'blue',strokeWidth:3});
var I = brd.create('turtle',[],{strokeColor:'red',strokeWidth:3});
var R = brd.create('turtle',[],{strokeColor:'green',strokeWidth:3});
 
var s = brd.create('slider', [[0,-0.3], [60,-0.3],[0,1E-6,1]], {name:'s'});
var beta = brd.create('slider', [[0,-0.4], [60,-0.4],[0,0.2857,1]], {name:'&beta;'});
var gamma = brd.create('slider', [[0,-0.5], [60,-0.5],[0,0.1428,0.5]], {name:'&gamma;'});
var mort = brd.create('slider', [[0,-0.6], [60,-0.6],[0,0.4,10.0]], {name:'% mortality'});
brd.create('text', [90,-0.3, "initially infected population rate"]);
brd.create('text', [90,-0.4, function(){ return "&beta;: infection rate, R<sub>0</sub>="+(beta.Value()/gamma.Value()).toFixed(2);}]);
brd.create('text', [90,-0.5, function(){ return "&gamma;: recovery rate = 1/(days of infection), days of infection= "+(1/gamma.Value()).toFixed(1);}]);
 
var t = 0; // global
 
brd.create('text', [100,-0.2, 
        function() {return "Day "+t+
                           ": infected="+(1000000*I.Y()).toFixed(1)+
                           " recovered="+(1000000*R.Y()).toFixed(1)+
                           " dead="+(1000000*R.Y()*mort.Value()*0.01).toFixed(0);}]);
 
S.hideTurtle();
I.hideTurtle();
R.hideTurtle();
 
function clearturtle() {
  S.cs();
  I.cs();
  R.cs();
 
  S.hideTurtle();
  I.hideTurtle();
  R.hideTurtle();
}
 
function run() {
  S.setPos(0,1.0-s.Value());
  R.setPos(0,0);
  I.setPos(0,s.Value());
 
  delta = 1; // global
  t = 0;  // global
  loop();
}
 
function turtleMove(turtle,dx,dy) {
  turtle.moveTo([dx+turtle.X(),dy+turtle.Y()]);
}
 
function loop() {
  var dS = -beta.Value()*S.Y()*I.Y();
  var dR = gamma.Value()*I.Y();
  var dI = -(dS+dR);
  turtleMove(S,delta,dS);
  turtleMove(R,delta,dR);
  turtleMove(I,delta,dI);
 
  t += delta;
  if (t<200.0) {
    active = setTimeout(loop,10);
  }
}
function stop() {
  if (active) clearTimeout(active);
  active = null;
}
function goOn() {
   if (t>0) {
     if (active==null) {
       active = setTimeout(loop,10);
     }
   } else {
     run();
   }
 
}