10: Epidemics in Social Networks#
This week we’ll explore the spread of epidemics in a contact network. Use the High School contact network available on Austin R. Benson’s network data site. You should already have it downloaded from last time, and the data file is also available in the Sakai assignments. You may need to refer back to the Clustering homework for a reminder on how to input this data.
Epidemics are a sensitive topic, and modeling epidemics on data collected from real people requires care. Be sure to describe the spread of the epidemic theoretically and with respect for the people on which this data set is based. If you’re at all uncomfortable working with this example, you’re welcome to work with me to choose a different data set for this assignment.
In a short Jupyter notebook report, answer the following questions about this network. Don’t simply calculate the answers: make sure you’re fully explaining (in writing) the metrics and visualizations that you generate. Consider the Criteria for Good Reports as a guide. You can create markdown cells with section headers to separate the different sections of the report. Rather than number the report as if you’re answering distinct questions, use the questions as a guide to do some data storytelling, i.e. explain this network’s data in an organized way.
You’ll work with a hypothetical epidemic in which the probability of infection is 5/8: \(p=0.625\). Based on this network’s average number of contacts per person, what is the value of \(k\), and what is the value of \(R_{0}\)? (This network is undirected, so treat every edge as potentially carrying infection in both directions.) This not a branching process, but what do these values tell you about the network?
Using the steps on page 651 of Ch. 21 of our book, create a simulation of an SIR network similar to the simulation you created last week for information cascades. You’ll create a function to generate one time-step of the network and create both a series of visualization and a pandas DataFrame that shows the progress of infection and recovery. Will this infection stop itself over time or will it continue?
Create a static percolation of the SIR epidemic and visualize the open and blocked edges. (You might consider using edge weight or edge style to show percolation.) Does this confirm what you saw in the temporal model above? What did you learn from this representation?
Extend your initial epidemic simulation for a SIRS epidemic, letting the time in the removed state, \(t_{R}\) be 2 cycles. How does the affect the speed and extent of the epidemic?
n.b. To answer these questions, you’ll need to use a mixture of the NetworkX skills we’ve been working on, as well as combine NetworkX code with pandas and altair.
When you’re finished, remove these instructions from the top of the file, leaving only your own writing and code. Export the notebook as an HTML file, check to make sure everything is formatted correctly, and submit your HTML file to Sakai.
Random Choice#
In order to accomplish the above, you’ll need a way of selecting from one of two options based on a predetermined probability. Python has a built-in library for this, random
:
from random import choices
choices(['option1','option2'],weights=[.25,.75],k=1)[0]
The code above creates a scenario in which Option 1 has a 1 in 4 chance of occuring.