In this practical we will take our SIS model and extend it to produce the Susceptible-Infected-Recovered or SIR model. In this instance we’ll use the parameters for foot-and- mouth disease, a highly infectious disease of ruminants – in this case cattle.
The SIR model in difference equation form is given by the following equations:
\[S(t+1) = S(t) - \beta \times \frac{S(t) \times I(t)}{N}\] \[I(t+1) = I(t) + \beta \times \frac{S(t) \times I(t)}{N} - \sigma \times I(t)\] \[R(t+1) = R(t) + \sigma \times I(t)\]
Your task is to copy and edit the files from the previous practical
(0203-deterministic-SIS.R and 0203-run-SIS.R) to produce the
corresponding files 0204-deterministic-SIR.R and 0204-run-SIR.R that run the SIR model
rather than the SIS model. There shouldn’t be too many changes that are
necessary, though obviously the first is to add a new population (the
recovereds) to the data frame and remember than \(N\), the total population size, now
includes the recovereds too. Also remember that if you change the name
of the function, for example from
timestep_deterministic_SIS()
to
timestep_deterministic_SIR()
you need to change it in both
files.
Because foot-and-mouth disease (FMD) is so transmissible that the disease flashes through a herd very quickly, to model it we normally deal with farms rather than individual animals when we are thinking about transmission and recovery, so an “individual” is actually a farm in the model. This makes no difference to your code, but may change your choice of some variable names. You’ll therefore need to know the transmission and recovery rates of farms, and very roughly, running in timesteps of weeks again, we can use a transmission rate of 2 and a recovery rate of 1/2. Note that with such high transmission and recovery rates, you’ll find the outbreak finishes very quickly, so you should find that the end time of the simulation can be quite short, and you should find that the timestep will have to be below 1 to be stable.
Run the code by running your new file 0204-run-SIR.R. Check that you get the
same results as you saw in the lecture for an \(R_0\) of 2. Adding the argument
col=c("green", "red", "black")
to
plot_populations()
will allow you to change the colours of
the plot to match those from the lecture.
Create a report showing farm-to-farm transmission of FMD, displaying the output of its SIR model in a figure. You could for instance show how that differs from an SIS model with the same \(R_0\), or another SIR model with a different \(R_0\).
As with the other exercises, we want you to get a couple of other people to check your code and make sure it works for them, and we want you to check other people’s code too.
Once you’re happy with your code, commit your changes using the Git
pane in RStudio (just commit the R files - not, for instance, any html
files that were created by generating reports). Don’t forget then to
push the changes to GitHub and check on the website that it contains
your new code. Notify your partners that you have something for them to
check. If you’re not sitting next to them, then you can create an issue
in your repository asking for their review - you can contact them by
tagging them in the message with @theirusername
, and they
should receive an email and a notification on the website.
They should then create an issue, telling you if they had any problems
running your version of the practical.
Likewise, when you hear from someone else that a repo is available to check, then if it’s a project you have already downloaded, you should open that project in RStudio, go to the Git pane, and click on the Pull button to get the updates they have pushed to GitHub (there should be a subtle message saying that updates are available near the button). If you’re checking a new person’s work, or a new project, refer to the instructions in Practical 2-1. Once you’ve checked that the new code has downloaded, you can then run their code and make sure it works. Open an issue on GitHub to say if it works, or explaining what went wrong if it doesn’t (it might help to also do this in person if they are there).
Interacting like this through GitHub to help each other will count as your engagement marks for the course.