HomeLatest ThreadsGreatest ThreadsForums & GroupsMy SubscriptionsMy Posts
DU Home » Latest Threads » Forums & Groups » Topics » Science » Science (Group) » Anyone used the SIR for i...

Mon Mar 9, 2020, 09:34 PM

Anyone used the SIR for infectious disease?

https://en.wikipedia.org/wiki/Mathematical_modelling_of_infectious_disease#The_SIR_model

Super simple model. I coded it in Perl, whopping 40 lines of code, I added a nuance to quarantine a portion of the infected.

What I found, (regardless of total population). If beta (similar to R0) drops from 1.5 to 1.0, the peak number of cases is cut in half. Implication being that
if we can reduce interpersonal contacts by just 33% each day we'll push the peak case load down and out. If you can quarantine 50% of the infected cases the peak reduces by about 80%.

But you can't quarantine cases if you don't test for them...

[code]

use strict ;
use warnings ;

my $s_pop=10000000 ; # susceptible
my $i_pop=1 ; # infected
my $r_pop=0 ; #dead or immune
my $tot_pop = $s_pop + $i_pop + $r_pop ;

my $beta0=$ARGV[0] ; # per week
my $beta2=$ARGV[1] ; # per week
my $delay=$ARGV[2] ; # weeks

die "usage sir.pl <betaO> <beta2> <delay2>" if ! defined $beta0 ;

my $cases=1 ;
my $day=0 ;

my $beta=$beta0 ;
my $gamma=0.5 ; # assume it takes 1/(2 weeks) to recover
my $p_q = 0.0 ; # proportion of infected who are quarantined.
my $p_uq = 1.0-$p_q ; # proportion of population quarantined, but infected.

for(my $week=1 ; $week < 50 ; $week++) {
my $pct=$i_pop/$tot_pop*100 ;

print "week $week -- infected cases $i_pop, $pct %n" ;

if(defined($beta2) && defined($delay)) {
$beta = $beta2 if $week >= $delay ;
}

my $ds = -$p_uq*$beta*$s_pop*$i_pop/$tot_pop ;
my $di = $p_uq*$beta*$s_pop*$i_pop/$tot_pop - $gamma*$i_pop ;
my $dr = $gamma*$i_pop ;

$s_pop += $ds ;
$i_pop += $di ;
$r_pop += $dr ;
}
[/code]

6 replies, 825 views

Reply to this thread

Back to top Alert abuse

Always highlight: 10 newest replies | Replies posted after I mark a forum
Replies to this discussion thread
Arrow 6 replies Author Time Post
Reply Anyone used the SIR for infectious disease? (Original post)
Pobeka Mar 2020 OP
defacto7 Mar 2020 #1
Canoe52 Mar 2020 #2
Karadeniz Mar 2020 #3
Pobeka Mar 2020 #4
Canoe52 Mar 2020 #5
Pobeka Mar 2020 #6

Response to Pobeka (Original post)

Mon Mar 9, 2020, 10:00 PM

1. Looks nice. Good job.

Reply to this post

Back to top Alert abuse Link here Permalink


Response to Pobeka (Original post)

Mon Mar 9, 2020, 10:34 PM

2. KnR because way cool, and also good info.

Reply to this post

Back to top Alert abuse Link here Permalink


Response to Pobeka (Original post)

Mon Mar 9, 2020, 11:22 PM

3. This should inspire everyone to be more careful...each person can make a difference!

Reply to this post

Back to top Alert abuse Link here Permalink


Response to Pobeka (Original post)

Tue Mar 10, 2020, 11:50 AM

4. Tweaked the code and made a graph

http://imgur.com/a/2MHcy0A

The code tweak was to directly model the recovery/death time as 7 days. The code uses new cases from 7 days prior, as an estimate of how many cases to remove from the infected population.

The graph reflects just 10% of the total active cases, assuming they'd be the ones needing critical care/ventilators etc.

What's interesting is if you delay the social distancing measure by 33% at 4 weeks (approx now), you still reduce the peak by well over half. The peak comes sooner in this case because there are more cases at week 4 (due to no social distancing) than the 33% social distancing that starts immediately

Reply to this post

Back to top Alert abuse Link here Permalink


Response to Pobeka (Reply #4)

Fri Mar 13, 2020, 01:37 AM

5. Great graph, I've shared it the last few days. Interesting that overall infections is roughly the

same for reduce interactions 33% and reduce interactions 33% at week four. (If Iím reading it right?) looks like the UK is taking the later action.

Reply to this post

Back to top Alert abuse Link here Permalink


Response to Canoe52 (Reply #5)

Fri Mar 13, 2020, 09:50 AM

6. CAUTION: Absolute numbers of the graph not going to be reasonable.

But the relative impacts comparing one peak to another are the important message.

Same stuff we're seeing in the "flatten the curve" folks.

And yes, you are reading it right. There is a grace period to implement these measures. BUT, it assumes *perfect* knowledge about when the first case appeared in the population. Wouldn't surprise me that we have a lag of 30 days of detecting a case, after the first actually appeared.

And now we know asymptomatic transmission has been occuring all along,

Bottom line, for Seattle at least, we're probably already 50 days into this already.

Reply to this post

Back to top Alert abuse Link here Permalink

Reply to this thread