Dark theme

Running a disease model IV: Working with the model

So our model lets us see the spread of the disease, but if we want to know how fast it spreads we have to sit there with a stopwatch timing it. Wouldn't it be better if it recorded the time it took itself? Well, as it happens, it does. However, because of the way the web works it is quite hard to get hold of this data if the model is running from a webpage, so, for the next bit you'll need to download the model to your computer.

Right-click on whichever link is suitable for you, below, and save the file somewhere onto your computer (for licencing, disclaimers, etc. see the source code below):

Windows version
MacOSX version
Linux version

Once you have the file downloaded, you'll need to unzip it. In Windows you should be able to right-click on it and "Extract" it. Once you have done this, go to the extracted files and find the executable file (in Windows this is Disease_modelling.exe). Double-click it in your file manager / My Computer to run it. You should see something like the webpage, but with different colours.

The other difference is that if you run the model and push the C key on your keyboard while holding down the "control" key (Ctrl) your computer will copy the times the model changed, and how. If you go to another piece of software (for example Notepad, Word, or Excel) and press Ctrl+V you should be able to paste the data into the software. The data is:

Time: the time in seconds when the model changed.
Total: the total number of people (this can change just by you adding more).
Susceptible: the number of Susceptible people.
Infected: the number of Infected people.
Insusceptible: the number of immune people.
Dead: the number of Dead people.

Drawing the data in Excel

You can use this to make a graph of infection rates:

a) Copy the model data using Ctrl+C.

b) Open Excel with a new spreadsheet. Select the top-left cell and paste the data using Ctrl+V - it should put it into the "A" and "B" columns for you.

c) Now, in Excel, select the data and go to the "Insert" tab on the ribbon. Click the arrow below "Scatter", and then choose a graph with smoothed lines and dots on it. You should see something like this:

Screenshot: Excel graph

Questions:

Say each infected person infects another at a rate of one a second, and newly infected people can infect other people as well, what kind of graph might we expect for such a model?
Why don't we get this graph in practice?
How might this be reflected in the infection rate in a real disease, and how might we control real diseases?

Building the model yourself

On the one hand this model is a little more complicated than most SIR models, which tend to just be based on maths where all the people are bundled up in a single set of numbers in an equation. This model has the extra problem of all the people being separate circles and moving around. It is a very (very) basic version of a model type we call "Agent-Based Models" where each person is a separate thing than acts on its own.

You will have seen Agent-Based Models before. They are the building block of games like SimCity and The SIMs, but also any game that has enemies to fight or friends to talk to. As well as being used in games, Agent-Based Models are used for all kinds of modelling in Geography and other subjects. You can find out more about the work we do with them on the MASS group webpages.

On the other hand, these models aren't actually too hard to build. Most people can have a go at building one. While the code for this one involves a lot of stuff to get the scrollbars working, and getting it working on the web, the actual model bit is quite simple (you can see the full source code here: Disease_modelling, if you're interested; it was built using Processing).

If you're interested in having a go at this, return to the Index page where you can find a tutorial to build one of these models using "Scratch", a simple piece of software for building Agent-Based Models.