Page 1 of 1

Help with my SIR model

Posted: Tue Feb 04, 2020 11:30 pm
by KSaigal
Hello,
I am currently working on an SIR model on the flu for a math project.
I already made the model, but for some reason, whenever I press simulate, a notification saying "floating point overflow-saving to time 6.00000" keeps on coming up.
I attached my model to this post. Can someone please help me fix it?
I have tried looking at past posts on fixing this problem, but I cannot seem to figure it out.
Thank you!

The equations that I want for the model are:
Susceptibles initial value:306109999
Infecteds initial value:1
recovereds initial value:0
infection probability r:0.3225
recover time a:0.25
Running the model from time t=0 to t=120 in days

Re: Help with my SIR model

Posted: Wed Feb 05, 2020 1:35 am
by tomfid
Moving to the Vensim section.

Re: Help with my SIR model

Posted: Wed Feb 05, 2020 9:06 am
by Administrator
I'd start by putting units in for all your parameters. It's difficult for others to know what you are doing without them (for example, "recovery time a" is 1/4, is that 1/4 of a week or month or day).

Once you put the units in and try the units check, I'm sure you'll see where the errors are.

Re: Help with my SIR model

Posted: Wed Feb 05, 2020 1:13 pm
by KSaigal
Ok, so my susceptibles (S), infecteds (I), and recovereds (r) are in terms of people and infection probability/recovery time are in terms of days.
Do I just type "people" and "days" into the units section?
Whenever I do this and press check units, it says RHS units not determinable.
I attached the model again with the units.

Re: Help with my SIR model

Posted: Wed Feb 05, 2020 4:34 pm
by tomfid
The units on "get better" (etc.) should be people/day.

This model will not be stable as is, because the shortest time constant (recovery time) is 1/4 is shorter than the time step (see Model>Time Bounds). As a rule of thumb, the time step should be less than half the shortest time constant or delay.

Also, the units for time (months) don't match the variables (days).

Re: Help with my SIR model

Posted: Wed Feb 05, 2020 9:13 pm
by Administrator
It might help if you start with a tutorial on Vensim, the following website has a really good PLE one.
http://www.public.asu.edu/~kirkwood/sysdyn/SDRes.htm

Re: Help with my SIR model

Posted: Wed Feb 05, 2020 10:59 pm
by KSaigal
Hello,
Ok thank you. I fixed all of the mistakes you suggested but it still says "floating point overflow"
I actually built this model using a tutorial I found online that did not include units, etc and it worked when I did it on ebola, but not for the flu.
Do you have any suggestions on how to get rid of this "floating point overflow" error that keeps on showing up? I attached the model that I fixed here.
Thank you for your help.

Re: Help with my SIR model

Posted: Wed Feb 05, 2020 11:14 pm
by KSaigal
Is there any way you can fix it for me? I cannot seem to locate the error that causes the floating-point overflow even after trying your suggestions.

Re: Help with my SIR model

Posted: Thu Feb 06, 2020 9:11 am
by Administrator
We will not fix the model for you as it's part of a math project.

First, fix the unit errors in the model, they are highlighting errors. The equation for "get better" is incorrect, it should be measured in people/day (your equation gives people*days). To fix the other problem, take a look at the Vensim help, there is a chapter on model calibration which includes a model called electric.mdl. This has the structure in it for when two populations interact with each other.

Re: Help with my SIR model

Posted: Thu Feb 06, 2020 3:00 pm
by tomfid
It may be easier to debug if you switch to Euler integration (at least temporarily). It's harder to see the behavior internal to the time step with RK4.

I think the problem here is with your "get sick" equation. You have k*infected*susceptible. There's immediately a problem here - imagine if half the population is in each category. Then the magnitude of the flow is roughly population^2, which is absurdly large unless k is very small. The units should indicate that this is a problem, because people*people/day doesn't make sense.

I think this needs to be normalized by the total population to make sense, i.e. k*infected*susceptible/population. Then, if k has units 1/day, you have units of people/day as expected.

Re: Help with my SIR model

Posted: Fri Feb 07, 2020 1:19 am
by KSaigal
Ok, thank you tomfid. Just to clarify by "k" you mean my "infection probability r" correct? And for the "population" I would just divide by the total population number?

Re: Help with my SIR model

Posted: Fri Feb 07, 2020 3:32 am
by KSaigal
The total population number being 3.0611e+08?

Re: Help with my SIR model

Posted: Fri Feb 07, 2020 4:18 pm
by tomfid
Right - k being the rate coefficient.

I'm guessing that the tutorial is using normalized population to begin with - it's common practice in epidemiology and nonlinear dynamics because the simplification makes it easy to analyze the model (no nuisance parameters). However, it's generally confusing for building models of real phenomena from scratch.

To make things robust to reparameterization of the population, I would typically compute
total pop = susceptible + infected + recovered
This works even if you have migration.

Another option (perhaps more convenient) is to make total pop a constant and initialize
susceptible = total pop - infected - recovered
This is generally easy because I and R are small.