142Z Project 2: Dynamics

Using the SIR Model

WebR Status

🟑 Loading...

In this project you will work with a differential equation model of the spread of contagious disease in order to make sense of the past, the prognosis of the COVID pandemic, and to examine the impact of policies such as social distancing and vaccination.

The model we will use and develop is called the SIR-model. The name reflects the three population groups at the core of the model: people susceptible to infection, people who are currently infective, and people who had the disease but are no longer infective, the so-called recovered group. That we implement the model using differential equations should in no way be interpreted as our having captured in detail the real-world mechanisms of contagion. The SIR model can at best make only rough, tentative approximations to the future course of an epidemic. There are many important phenomena completely outside the scope of the model, such as the evolution of new variants of the virus, the role of super-spreader events, and so on. That being said these SIR-models are commonly used including by the Pandemic Math Team which helps model the pandemic at USAFA and has served as a standard for the pandemic response across the Air Force.

The utility of the model is not for detailed prediction. Instead, the model provides

The model, like many others we’ve seen, consists of a state that describes the instantaneous β€œposition” of the system and dynamical rules that describe the instantaneous rate of change of the state as a function of the state itself. In constructing the dynamical rules, we’ll take note of an appropriate time scale, and we’ll follow the pattern of using parsimonious, low-order polynomials.

We’ll imagine the state as consisting of the number of people in three different compartments:

The dynamical rules describe the rates at which people move from one compartment to another. Those flows are rooted in some basic, everyday biology:

  1. contact between infective and susceptible people will, at some level of probability, convert a susceptible into an infective.
  2. after a characteristic amount of time, infective people no longer remain infective and enter the β€œrecovered” compartment.

Schematically, the flows are one-way only:

Susceptible ⟹ Infective ⟹ Recovered

Other patterns of flow might be appropriate depending on the circumstances. For instance, at the time of writing (March 2021) there is uncertainty whether those recovered from COVID might at some time regain susceptibility. Another sort of flow is evidenced by a very recent Ebola transmission traced to a person who had again become infective after recovering five years previously. In some diseasesβ€”herpes, malariaβ€”people can be latent carriers whose infectiveness comes and goes over periods of month or years.

With COVID, we have seen large scale changes in the number of sick on a time scale of months or seasons. Since overall population changes little on that time scale, we start with an assumption that the model does not have to incorporate birth rates.

Now to describe the dynamics in a population of size N:

The susceptible compartment has no inward flow. The outward flow is governed by the interaction between susceptibles and infectives. This gives simply SΛ™=βˆ’Ξ²SIN Think of SI as the total number of theoretically possible contacts each day between susceptibles and infectives. Each susceptible person could in principle meet any of the I infectives. since there are S different susceptibles, the total number of potential meetings is SI. The negative sign is because the people are leaving the compartment (Once again the flow is one way, so no one becomes susceptible).

What’s the N doing in Ξ²SIN? Suppose the N weren’t there. Then the dimension of Ξ² would need to be Tβˆ’1peopleβˆ’1 in order to produce the units of SΛ™ which are people/T. It’s convenient to be able to make an estimate of Ξ² in a population of one size and be able to apply it to a population of another size. The N takes care of this for us.

Hardly any of these potential meetings ever happens. And even if a meeting does happen, it will not necessarily lead to the susceptible becoming infective. All of this is meant to be captured by the parameter Ξ², for which we anticipate that Ξ² is much less than 1 (that is, Ξ²β‰ͺ1).

The infective compartment has a flow in and another flow out. The flow in is exactly those same people who flowed out of the susceptible compartment, the rate of which is Ξ²SI. But the infective people eventually recover. This will be represented as a term Ξ±I, giving

IΛ™=Ξ²SINβˆ’Ξ±I Why divide by N? We’d like Ξ² to tell us about how fast the epidemic spreads. So it should have dimension of 1/time.

Finally, the Ξ±I recovery is a flow into the recovered compartment:

RΛ™=Ξ±I

Only two unknown parameters: Ξ± and Ξ². N is the size of the population, which we know.

Estimating Ξ±

At the start of the pandemic, the Centers for Disease Control and other public health organization recommended that people who tested positive for COVID, or those in close contact with someone who tested positive, isolate themselves for two weeks.

Let’s reverse-engineer Ξ± from this recommendation. For those in isolation, who ideally have no contact with susceptibles, the dynamics and corresponding solution for this scenerio are IΛ™=βˆ’Ξ±I   βŸΉ   I(t)=I(0)eβˆ’Ξ±t Consider 100 people in isolation. Some will presumably recover faster than others but as a group, after two weeks the proportion still not recovered will be eβˆ’14Ξ±. The recommendation is framed to produce a very small probability that a person at the end of the two-week isolation will still be infective.

Essay 1: State what you think is a β€œvery small probability” might be and explain what that probability means in the context of this problem (For instance, if X number of people become infected and quarantined, we would expect Y number of people to still be in state I at the end of two weeks).

question id: using-SIR-essay-1

Essay 2: (Give a short answer.) Assume the very small probability through experimental trials is 0.1% after two weeks. What is the corresponding Ξ± value. Do not include units and round your answer to the nearest hundreth. (You’ll enter the units in the next question.)

question id: using-SIR-essay-2

  1. What are the appropriate units for Ξ±?
people/day       days/person       1/persons       1/days       1/(person-days)      

question id: using-SIR-1

Estimating Ξ²

To estimate Ξ², we can look at the exponential growth in the cumulative number of cases seen in the early phases of the outbreak. Exponential growth is, of course, characterized by a doubling time. Estimates for the doubling time ranged from about 10 days to about 40 days, depending on location. To simplify, let’s use 20 days as the doubling time.

Imagine a region containing N=100,000 people. Public health statistics are often given in rates per 100,000 (or per 10,000 or per 1000), so this is a convenient number mathematically.

Near the start of the epidemic, almost everyone is susceptible and there is just a small number of infectives or recovered. So we can treat S as approximately constant, say S0=100,000.

The dynamics of I are

IΛ™=(Ξ²S/Nβˆ’Ξ±)I with a solution, when S is constant I(t)=I(0)exp⁑((Ξ²S/Nβˆ’Ξ±)t)

For a doubling time of about 20 days in the beginning, when Sβ‰ˆN, we should set Ξ² such that Ξ²βˆ’Ξ±=ln⁑(2)20

Essay 3: Based upon your previous answer for Ξ±, what is your estimate for Ξ²? Do not include your units. Assume a doubling period of 20 days and round your answer to the nearest hundredth. (You’ll address the units in the next question.)

question id: using-SIR-essay-3

  1. What are the appropriate units for Ξ²? (Assume that N, the population size has units of persons.)

people/day

days/person

1/persons

1/days

1/(person-days)

question id: using-SIR-2

Essay 4: Explain how you know the units for Ξ². In your answer, be sure to include what the units are for S, I, and N.

question id: using-SIR-essay-4

Running the model

Having estimated the parameters Ξ± and Ξ² we have in effect calibrated the model and we’re ready to go. The initial conditions will be S(0)=100000, I(0)= small, and R(0)=0.

Here are the differential equations and the commands for numerical integration. The parameters have been set up so that you need only specify your value for Ξ± and for the doubling time. Ξ² is calculated based on those two quantities.

Active R chunk 1

Two quantities are of particular interest in public health: the fraction of the population that falls ill and the peak rate of new infection. The latter is relevant to the peak load on the medical system. The former indicates how likely a β€œaverage” person is to get the disease at some point in the outbreak. You can read both these quantities off the graphs.

The peak rate of infection and the population fraction are presumably related to the parameters Ξ± and Ξ². Try modifying these slightly to see what the relationship is. You’ll have to be careful in interpreting the meaning of β€œslightly.” You want the changes to be β€œslight” in terms of the physical meaning of the parameters, perhaps doubling or halving the physical manifestation of the numerical value of the parameters.

Essay 5: How does halving the quantity β€œdoubling time” affect the population fraction? Ensure you have the value for alpha that you calculated to start in the code.

question id: using-SIR-essay-5

Essay 6: How does doubling the quantity β€œdoubling time” affect the peak infection rate?

question id: using-SIR-essay-6

Essay 7: How does doubling the quantity β€œrecovery rate” affect the population fraction? Ensure your doubling rate has been returned to a value of 20.

question id: using-SIR-essay-7

Essay 8: How does halving the quantity β€œrecovery rate” affect the peak infection rate?

question id: using-SIR-essay-8

For the previous answers you should use your calculated Ξ± and Ξ² from before. In order to better understand the affect of these parameters, you can see what happens when the parameter changes aren’t slight, try doubling Ξ² while leaving Ξ± alone. You can accomplish this by inserting a line beta <- your number in place of the existing calculation of Ξ². Use R to calculate what the doubled value of Ξ² should be.

Essay 9: Describe how that doubling of beta changes the course of the epidemic. Be sure to mention the the terms β€œpeak rate of infection” and β€œpopulation fraction” in your answer.

question id: using-SIR-essay-9

Intervening

Many different forms of public-health interventions are available, e.g. mask wearing, closing businesses or schools, vaccination. In terms of the model, these all come down to adjusting the values of the parameters Ξ± and/or Ξ², or changing the initial conditions of the model.

For instance, the effect of social distancing might be modeled by increasing the doubling time for transmission. Vaccination could be modeled by moving people from the S compartment to the R compartment. You can do this in the code by manipulating the terms in the IntegrateODE function.

Essay 10: Suppose at the start of the epidemic you could vaccinate 70% of the population with a vaccine that is only 50% effective. Run the model to find out how would this change the population fraction and peak infection rate. Your answer should be supported by numbers and not simply be guesses about what would occur.

question id: using-SIR-essay-10

Essay 11: [Short Answer] Herd immunity refers to a situation where the number of infectives does not grow. Try moving various fractions of the population from S to R to find the threshold for herd immunity. What is this threshold when you use your previously calculated alpha and beta values?

question id: using-SIR-essay-11

Another way to intervene is to change Ξ±. You might think that Ξ± depends only on the biology of recovery, but this is not so. For instance, you can sequester people identified as infected or at high risk of becoming infective. Tools such as contact tracing are useful for this.

One of the strategies used in China to contain the outbreak in March and April 2020 was to isolate infectives. Voluntarily or not, those with a positive COVID test were removed from their families and placed in hospitals, some of which had been specially constructed at short notice. Widespread, rapid testing and response can also help to reduce the time that an infective is in contact with susceptibles.

Essay 12: Would sequestering infectives correspond to an increase in Ξ± or a decrease? Investigate the effect of such a change on the course of the epidemic and report your results. Your answer should be numerically supported.

question id: using-SIR-essay-12

An endemic future?

A feature of the SIR model as stated here is that the rate of new infectives eventually falls to zero; the outbreak comes to an end. In the real world, however, diseases can become endemic, meaning that there is always a background rate of new infections that can smolder until such time as the susceptible population recovers. One mechanism for this is births. The classic childhood illnesses of your grandparents’ timeβ€”measles, mumps, rubella, even polioβ€”were endemic and new outbreaks would occur as the number of susceptible children accumulated over years.

Let’s explore another possibility about which there has been considerable speculation. Imagine that β€œrecovered” people regain their susceptibility at a low rate, perhaps over the course of a year or more.

This would change the R component of the SIR model to look like RΛ™=Ξ±Iβˆ’Ξ³R where that flow out of R would become a flow into S. The value of Ξ³ sets the time scale for becoming susceptible again.

  1. What are the appropriate units for Ξ³?

people/day

days/person

1/persons

1/days

1/(person-days)

question id: using-SIR-3

Essay 13: Explain how an endemic state would show up in the graph of I(t) versus t.

question id: using-SIR-essay-13

Congratulations on finishing the project! The R code below will help you play around with the model to understand even more.

Objectives

MAKE THE PROJECT ABOUT THE DYNAMICS OF NEWTON’S METHOD, Maybe about zero-finding and optimization on functions of two variables.

Raw material that was previously an exercise.

Last semester we introduced an iterative technique for finding the zeros of a function f(x), that is, finding a value x⋆ such that f(x⋆)=0. The method, called Newton’s method, involves making a starting guess x0 for the location of the zero and then refining this guess according to the famous formula xi+1=xiβˆ’f(xi)βˆ‚xf(xi)

We can use this method to find, for instance, 10. We do this by creating a function that’s easy to calculate which has a zero at x⋆=10: f(x)≑x2βˆ’10

Finding βˆ‚xf(x) is easy, so the famous formula becomes, for the special case of our f() (1)xi+1≑N(xi)≑xiβˆ’xi2βˆ’102xi

We’ve called the dynamics function N(), in honor of Newton. Applying N() to xi is called β€œtaking a Newton step.”

Start with a very rough guess for x⋆, say x0=1. Applying the formula once gives x1=1βˆ’βˆ’9/2=5.5.

Using , implement the function N(x) defined in . Apply it once to x0=1 to make sure that you have the dynamics right.

Active R chunk 2
  1. Using N() as the dynamics and starting with x0=1, what is x5?
5.5       3.659091       3.141593       3.196005       3.162456       3.162354       3.162278      

question id: newtons-method-1

  1. Modify N() in to find 20. Starting at x0=1, how many times do you have to apply your new N() to get an answer right to within 1% of the true number?

After 2 steps we get 4.202

After 3 steps we get 4.713.

After 3 steps we get 4.472.

After 4 steps we get 4.472.

After 4 steps we get 4.478.

question id: newtons-method-2

  1. Modify your N() once again to find 103. (That is, the cube-root of 10.) Starting at x0=1, take 3 Newton steps. What is x3?

2.154

2.320

2.875

2.912

question id: newtons-method-3

No answers yet collected
Γ—

R History Command Contents

Download R History File