Modeling the Ebola epidemic. We have to make some decisions as to what it is we want to use and what it is we don't want to use. This is dominated by the available data. So the available data it gives us something about how many cases occurred and how many people were involved. An appropriate choice for the modeling paradigm is called SIR models. That simply stands for Susceptible, Infected, and Removed. It's a standard technique in disease modeling. Welcome to week three, lecture one of Julia scientific computing, in which we discuss SIR models of disease dynamics. So after this lecture, you'll be able to define the compartments S, I, and R of an SIR model. You'll be able to formulate an SIR model for infectious diseases. You'll be able to write a for loop that implements an SIR model and you'll be able to plot the resulting curves; S of t, I of t and R of t. So SIR models formalize what are probably the simplest of all the ways to think of an epidemic. So it goes like this. The basic concept is that before the epidemic starts, is the population, a known population at risk of catching the disease? The disease spreads from infected to susceptible people. After awhile, people are no longer infected and once they were infected, they can never be infected again. The last very important point is that, that is all, there are no other issues we consider. The only differences between people is whether they're susceptible, not yet infected, whether they infected, but not yet become uninfected. That's it. So we use the symbol S for the number of people who are still at risk of the disease, and S is short for susceptible, meaning a person who hasn't had that disease and they might catch it. So S in this concept of function of time. It changes as time goes on. So we write S as a function of t, and t is then the time. Normally, we think of t as starting at naught. So S as naught is the initial number of susceptibles at the start of the epidemic. It's a very important number as you will see. The number of infected people at time t is IFt and initially of course, IFt must be greater than zero. Otherwise, they won't be an epidemic. Finally, people who are previously infected, but no longer infectious are called Removed. That's why we use the symbol R. Unfortunately, it doesn't necessarily mean they've recovered. They may still be ill, but simply no longer infectious, or they may actually as happened tragically in many cases with Ebola. They may be dead. So you may think that S, I, and R stand for numbers of people and therefore, they have to be whole numbers. But this is not the case. This is a model. All that we're trying to do is predict the values of S, I, and R and we want our prediction to be good. So we want the values that we predict to be close to what is observed. The observed values of course, will be whole numbers and numbers of people. But we just want a prediction that's close to that. So it doesn't have to be a whole number. Even if we were to get numbers that will within a few percent of S, I, and R as they were observed, that would be a major achievement. So this major achievement, getting the numbers to fit what is observed is usually possible only with hindsight. In fact, we will show later that an SIR model can actually predict the West African EVD epidemic fairly well. But of course, we're using it by hindsight in what happened in practice in 2014, 2015, is that the cause of the epidemic was only successfully predicted by the time it was already nearly over. So that is the basic concept of an SIR model. So now, we can go onto the equations. So we will use discrete time steps, and each time step will have the same length dt, t sub naught as we said is equal to zero. What that means is that t sub i is just i times dt. The I steps each of length dt. But the model does for us is it takes a step from t sub i to t sub i plus one and at t sub i, we know the values of S, I, and R. What we want to do is use those values to predict S at t sub i plus one, I at t sub i plus one and R at t sub i plus one. We'll use an equation for each of those. So we need three equations. All of them has the form that the new value, that is the S at t sub i plus one. R values is the old value, which is the previous value here, plus whatever has been gained and minus whatever has been lost. If you're susceptible, the only thing that can happen is that you stop being susceptible because you become infected. So there is only a loss term. We want to model this loss term and the simplest SIR models use a loss term that is called the law of mass action, which is a term that comes from chemistry. But in this law, if we interpreted it for diseases, it says that every susceptible person has an equal chance of meeting an infected person, and every infected person has an equal chance of meeting a susceptible person. So what that means is that, the number of meetings between infected and susceptibles is just proportional to the product, S times I. Now, we can use the symbol Lambda for a constant of proportionality that tells us the rate at which the susceptibles become invented, become infected. So S and I, let's say t stands for days. So dt is a sum time step in days. It can be several days. It could be a small part of a day, but it's measured in days. Then T sub i is also measured in days. So if we now say S at t sub i and I at t sub i. This is product S times I gives us the number of meetings per day between S and I. But they don't all result in infection, some proportion only. So we have this lambda as a constant of proportionality that tells us the rate at which susceptibles become infected. So this is a kind of infectivity parameter. Because this is meetings per day, this is infections per meeting. We end up with a number of infections per day. Now, we want to convert that into the number of infections with time steps. So we must multiply it by the number of days. Whether it's a fraction of a day or several days, we are going to multiply this rate per day to get the total per time step. So for the equation for S is just the old S minus the infections that has taken place in that time step dt. So the loss rate for infected people is just a constant probability of recovery per unit time. So there's a constant fraction Gamma of the infections that leave per day. So that's Gamma I infecteds per day and that's Gamma I dt infecteds per time step. The new infecteds are of course exactly the susceptibles that became infected. So this lambda SIdt is simply what we put there for the gains and that's what we put for the losses. These losses of the infecteds are exactly the gains of the removed. Then we have these three equations and discrete SIR model is just these three equations.