Help with my SIR model

Use this forum to post Vensim related questions.
Post Reply
KSaigal
Junior Member
Posts: 6
Joined: Tue Feb 04, 2020 10:57 pm
Vensim version: PLE

Help with my SIR model

Post 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
Attachments
SIR model flu.mdl
(2.24 KiB) Downloaded 170 times
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Help with my SIR model

Post by tomfid »

Moving to the Vensim section.
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Help with my SIR model

Post 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.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
KSaigal
Junior Member
Posts: 6
Joined: Tue Feb 04, 2020 10:57 pm
Vensim version: PLE

Re: Help with my SIR model

Post 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.
Attachments
SIR model flu.mdl
(2.31 KiB) Downloaded 160 times
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Help with my SIR model

Post 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).
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Help with my SIR model

Post 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
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
KSaigal
Junior Member
Posts: 6
Joined: Tue Feb 04, 2020 10:57 pm
Vensim version: PLE

Re: Help with my SIR model

Post 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.
Attachments
SIR model flu.mdl
(2.44 KiB) Downloaded 178 times
KSaigal
Junior Member
Posts: 6
Joined: Tue Feb 04, 2020 10:57 pm
Vensim version: PLE

Re: Help with my SIR model

Post 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.
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Help with my SIR model

Post 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.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Help with my SIR model

Post 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.
KSaigal
Junior Member
Posts: 6
Joined: Tue Feb 04, 2020 10:57 pm
Vensim version: PLE

Re: Help with my SIR model

Post 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?
KSaigal
Junior Member
Posts: 6
Joined: Tue Feb 04, 2020 10:57 pm
Vensim version: PLE

Re: Help with my SIR model

Post by KSaigal »

The total population number being 3.0611e+08?
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Help with my SIR model

Post 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.
Post Reply