Social Networks and Epidemics Practical

BehaviourComposer: ignore everything before this.

Here we will model a disease by building interactions of individuals rather than modelling mathematically with variables that represent entire populations. This is variously called Individual-based modelling (IBM) or Agent-based modelling (ABM).

In the first part of the practical (1-6), you will build a model equivalent to the SIR model you have already built in R. But the methodology here is very different: the program describes the behaviours of individuals and the behaviour of the population emerges by summing those behaviours. The SIR model you built in R describes populations (if you recall, you were making an approximation of a series of differential equations). 

After modelling the infected, recovered, and vaccinated, you'll explore the influence of social heterogeneity on the spread of diseases. This would be very hard to model analytically with equations that model populations.

In the final part of the practical you'll model a vaccination policy that targets super-spreaders.

Towards the end of the exercise we ask you to run some experiments with the model and record your findings collectively (using an online form). 

At the end there are some questions which we would like you to answer.

Please go through the instructions carefully, step-by-step. There might be slight differences depending upon the web browser that you are using. You can use the browser's back and forward buttons to undo and redo. You can refresh the page to restart everything (only the open tabs will be lost -- your model will be restored).

Step 1. Getting started

You'll be constructing the IBM using a tool called the BehaviourComposer that you access via a web browser. The software enables you to build a computer model by pulling together (or composing) blocks of computer code called micro-behaviours, which are simply web pages that contain NetLogo code with explanatory text. 

  1. First, to make it easier to move between this guide and the Composer scroll down to the bottom of this page and click on the check box labelled Split screen between this panel and everything elseThis will make it easier to work through the steps below and build up your model. 
  2. Click on INITIAL MODEL and select Replace current model to load a model containing only a population of susceptible individuals and some technical machinery. This model has no infected individuals nor a mechanism for spreading an infection. You'll build on this initial model in the steps below.

Step 2. Explore the initial model

The micro-behaviours you have just brought into the Build area of the BehaviourComposer can be compiled into a computer program using the Run  tab. Clicking this tab causes the BehaviourComposer to strip the NetLogo code from all the micro-behaviours and combine them to run as a Java applet in your browser.

  1. Click on the Run tab in the Composer
  2. Once the Applet has loaded (might take a few seconds the first time) click on SETUP button to initialise the model. 
  3. Change the slider labelled the-initial-susceptible-population and click on the SETUP button again to see what happens. 

Notes:

  • To change the slider by small increments use the mouse to click on the slider to the left or right of its current value.
  • Only the Person prototype is an agent within the model, the others contain micro-behaviours that support the model or create graphs and sliders.

Step 3. Create some infected individuals

  1. Open the Initial infected population micro-behaviour web page (by clicking this link) and add it to your model:
    1. Click on the button at the top of the page labelled Initial infected population 
    2. Select the menu item Add to a Prototype
    3. Once taken to the Build area of the BehaviourComposer click on the prototype called Person.
  2. You need to make sure this micro-behaviour appears last in the list of micro-behaviours on the Person prototype. A micro-behaviour will enter the list where you drop it and you can change the order again by clicking on it and selecting Move Up and Move Down from the menu. 
  3. Run your model in the Composer Area again and you'll see an infected individual displayed in yellow after clicking the SETUP button. 
Tip: 
  • The order matters because the code is read by the NetLogo compiler from top to bottom which means, for example, the SET-SHAPE-PERSON micro-behaviour needs to be above the code where you create the initial infected population. If it is above the SET-SHAPE-PERSON command then the infected individuals will be the default triangle shape.

Step 4. Create a social network

Rather than model perfect mixing of people within the population we will model a network where each individual has a limited number of contacts. Here we model each individual to have the same number of potential contacts, called acquaintances. Diseases can be transmitted between individuals that are acquaintances in our model.

  1. Open the Constant social network micro-behaviour web page and add it to the Observer prototype (the position in list does not matter). This gives every individual the same number of acquaintances.
  2. Run your model in the Composer Area and click the SETUP button. You should see grey lines that represent the acquaintance relationships between individuals.
Tip:
  • You may wish to take some time to read the micro-behaviour pages you add to your model. The micro-behaviour you just added has important information about how the NetLogo code works e.g. see the section "How this works" at the bottom of the page.

Step 5. Spread the infection

  1. Add the Contact acquaintances micro-behaviour to the behaviour list called To do when infected.
  2. Now for one of the more tricky actions you need to perform with the BehaviourComposer: add a micro-behaviour to a list inside another micro-behaviour! To do this:
    1. Open the Contact acquaintances micro-behaviour and click on the button for the Possibly become infected micro-behaviour and select Open from the menu that pops up
    2. Open the Change colour of link with infector micro-behaviour, click on the button at the top of the page and select the menu item Add to list
    3. Go back to the Possibly become infected micro-behaviour and click on the Infection Behaviours list to add it to the list inside this micro-behaviour. (You should see something like the screenshot below.)
    4. Run your model from the Composer Area, click SETUP then GO and you should see the infection spread. The links that transmitted the disease should turn red because you added Change colour of link with infector. The model is programmed to stop when either no one is infected or no one is susceptible. You can manually stop the simulation by either pressing the PAUSE button or pressing GO a second time.

Notes:
  • Contact acquaintances works by multiplying the value from the-encounter-fraction slider with the number of acquaintances to determine the individual's contact rate. Since at this point we are modelling a population where every individual has the same number of acquaintances the contact rate is a constant and is very similar to the aggregate SIR model's contact rate. If the value is not an exact integer then the fractional part is used to determine the odds of contacting an additional person. E.g. a contact rate of 1.2 will contact one acquaintance 80% of the time and two 20% of the time. The odds of a contact between an infected and susceptible person resulting in a new infection is determined by the-infection-odds slider.

Step 6. Add recovery

  1. Add the Schedule recovery micro-behaviour to the To do when infected behaviour list in the Composer Area
  2. Run your model, click the SETUP and GO buttons.
Notes:
  • The Schedule recovery micro-behaviour models recovery by adding three micro-behaviours that change the state, change the display colour, and stop contacting acquaintances. Of course, real people will continue to contact people after recovery but it will have no effect on the spread of the disease. 
  • In reality when someone is infected there is, of course, no mechanism that sets a timer for when the person will recover. Since we are modelling recovery as a process that does not depend upon any interactions or later events (e.g. taking a drug) this is a simple way of implementing recovery that is equivalent to more detailed modelling. 
  • Note that graphs are being produced when you run the model - you may need to  scroll down or move the divider to see it.

Step 7. Add vaccination

Next we model a public health authority with only a limited amount of a vaccine. 

  1. Add the Vaccinate random proportion of population micro-behaviour to the prototype called Public Health Authority
  2. Run your model and experiment with different values. Even when all the parameters are left unchanged do you see different outcomes for different runs?
Notes:
  • Depending on the value set on the-fraction-vaccinated slider a random fraction of the population will be vaccinated. This is modelled as setting the state to vaccinated (instead of susceptible) and changes the colour used to display the individual to green.

Step 8. Build a different social network

In reality, individuals differ in the number of other individuals with whom they are likely to be in infectious contact. Here we shall investigate how different networks can affect the spread of a disease (note, the average number of contacts will remain the same). 

  1. Go to the Composer Area and click on the Constant social network micro-behaviour and Inactivate it. 
  2. Add the Power law social network micro-behaviour to the Observer prototype.
  3. Add the Size proportional to number of acquaintances micro-behaviour to Person. Inactivate the Small size micro-behaviour.
  4. Run the model and click SETUP a few times to see a variety of starting conditions.
Notes:
  • The Power law social network micro-behaviour implements a power law distribution of the number of acquaintances each individual has. A few will have very many acquaintances while most will have few. 
  • The power law distribution approximates the situation in sexually transmitted diseases such as HIV where some individuals have many sexual encounters while others have very few or none. 

Step 9. Using the model to study different approaches to vaccination

In the Public Health Authority prototype there is a micro-behaviour called Vaccinate random proportion of population which, as the name suggests vaccinates a proportion of the population randomly so that these individuals do not become infected. This behaviour can be constrasted with the Vaccinate most highly connected individuals micro-behaviour to see the effect of targeting vaccination towards the most connected individuals in the network. 
  1. Add Vaccinate most highly connected individuals to the Public Health Authority prototype.
  2. Run each of the 3 experiments described in the table below 10 times and record (on paper at first) the number of recovered individuals when the simulation run stops i.e. when the disease is no longer spreading. For each experiment ensure you use the following values for the model variables (set using the sliders):
  • the-encounter-fraction = 0.25 
  • the-fraction-vaccinated slider = 0.2
  • the-average-recovery-time = 20
  • the-initial-susceptible-population slider = 100
 Experiment  Constant social network micro-behaviour  Power law social network micro-behaviour  Vaccinate random proportion of population micro-behaviour  Vaccinate most highly connected individuals micro-behaviour
 1  Activate  Inactivate  Activate  Inactivate
 2  Inactivate  Activate  Activate  Inactivate
 3  Inactivate  Activate  Inactivate  Activate

Notes:
  1. Remember that the average number of acquaintances in both the constant and power law networks is the same.
  2. Think why we aren't asking you to experiment with targeted vaccinations for the constant network.
  3. Getting zero infections does not mean something has gone wrong!

Step 10. Use the results from the experiments to answer some questions

  1. Use this data entry form to input the data from the three experiments you just conducted.
  2. Go to the experimental results web page to analyse the collective data published as a histogram.
  3. Reflect on what you have done in this practical and answer some questions

Step 11. Further Steps

Time permitting there are many other questions you may wish to explore with your model. Examples include:

  • What fraction of targeted vaccinations are equally effective as the fraction of non-targeted vaccinations? 
  • What if the targeting introduces a delay in the distribution of the vaccine? What is the maximum delay where targeting is still helpful?
  • What effect do the different vaccination policies have on the duration of the epidemic?
  • What is the minimum amount of vaccine that would reduce the odds of infection below 1%?
  • How do the dynamics change if you change the average number of acquaintances per person?
  • How different would your conclusions be if the disease had different characteristics? E.g. if the infection had a very long duration but low odds of transmission?
BehaviourComposer: ignore everything after this.
Comments