Friday, March 20, 2020

Spare the hospitals!

There’s been a lot of attention – and rightly so – on the idea of "flattening the curve," and specifically on the goal of keeping the rate of serious cases below the capacity of the medical system.

If we succeed in that, we win in two ways.

First, critical CoVID-19 patients can get the care they need. At the moment, Italy is the most publicized case of an overwhelmed medical system, and doctors there are having to make awful decisions about which patients get life-saving treatment and which don’t.

Second, if the medical system gets overwhelmed, people with all sorts of medical conditions can’t get the treatment they need. Heart attack? Cancer treatment? Accident? Sorry, we’re busy, and the doctors, nurses are exhausted from trying to keep up with the CoVID-19 cases. If we keep the new virus under control, other people can continue to get treatment.

To reflect this problem, I’ve made two changes to the earlier model.

One of these is that there’s a defined level of hospital capacity.

For the other, the model makes a distinction between mild cases and severe ones. This is still a pretty big simplification, because there’s a meaningful difference between “severe,” which requires hospitalization, and “critical,” which requires hospitalization plus specialized equipment in limited supply.

The details of the model are below, or in the “Model Info” tab of the model.

If you just want to play with it, download the NetLogo Web version of the model from this link: https://drive.google.com/file/d/1CjFPbK9L6wMYTt9Ern_eb3cHLoA1JV-3/view?usp=sharing.



Save it to a useful place on your computer and open it up, and you should see the model.

Tuesday, March 17, 2020

Pandemic economy

“How are we going to pay for it?”

In all the understandable worry about how the CoVID-19 pandemic will play out, a common component is people’s concern about how this will affect the economy: people’s jobs, savings, access to health insurance.

And when people lose their jobs, or even just see reductions in working hours, there are very real problems with how people are going to even maintain access to food, or pay their utilities.

More generally, there’s the question of, “How are we going to pay for the country’s response to the coronavirus?”

The first thing to realize is that that is definitely the wrong question to be asking first.

At the same time, it is definitely a question that needs to be asked.

The upfront right questions are:
  1. What things need to be done?
  2. Are those things physically, logistically possible?
My understanding of the expert advice is that we need people to:
  1. Massively reduce their physical interaction with other people.
  2. Get tested (I’ve seen differing advice on who exactly should get tested. In a situation with insufficient numbers of test kits, there will be some sort of prioritization based on the nature and severity of symptoms, and the extent to which someone is necessarily going to be interacting with wider circles of people, e.g., health professionals.).
  3. Get treatment if they develop a severe case.
For right now, that’s it.

If that’s our program, then a few things absolutely need to keep running:
  1. Food production and distribution.
  2. Medical services, from hospitals through the manufacture and distribution of pharmaceuticals and medical supplies.
  3. Utilities (electricity, natural gas, water, sewer).
  4. Public safety (there will still be heart attacks needing transportation to hospitals; buildings will still catch fire; and even with reduced traffic on the roads, there will still be accidents).
Some additional things need to keep going to some extent to support those “must have” activities, for example:
  1. Production of metal and plastic for food packaging.
  2. Production of motor fuel for necessary commuting and shipping.
Other things absolutely need to not happen, most prominently:
  1. Pretty much the whole nexus of culture / entertainment / leisure / tourism: restaurants, theaters, museums, theme parks, etc.
  2. Other retail besides food and medicine.
That’s a lot of people who won’t be working, and for most of them, not working means not having an income, and any sort of income replacement from the government will be less than 100%, so “optional” purchases go right out the window. Manufacturing activities like the car industry should probably be limiting their operations in the interest of social distancing, but with so many people losing income, it’s going to be an atrocious time to be selling cars, so there’s very limited need to be making them at the moment.

This has short-term and long-term consequences, but the those two things are very different from each other. The short-term consequences are physical and unavoidable. The long-term consequences are social and financial, and in principle, they don’t have to happen.

Sunday, March 15, 2020

Distance in pictures

Yesterday I posted a Web-enabled version of a model to simulate the spread of a virus under different levels of social distancing.

I realize not everyone has the time or opportunity to download the model and run it themselves.

Also, the version of NetLogo that runs on your laptop has some functions that the Web version can't do. Among those things is that the laptop version can take a particular set of parameter values, run the model a bunch of times, save the results each time, then take a different set of parameter values and again run the model several times.

That allows each run to be random, while still enabling you to see the larger patterns associated with particular parameter values.

In case you didn't get a chance to read yesterday's post, social distancing is captured by reductions in the variable SPEED, which controls how quickly people move around in the world of the model. At lower speeds, people make fewer contacts with other people, which in a crude way mimics the effect of social distancing.

For the graphs below, I set the value for SPEED at 0.2, then 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, and 1.0.

That is, I went from very strong levels of social distancing (speed = 0.2) to no social distancing (speed = 1.0).

At each level of social distancing, I ran the model 20 times.

Each time, I stopped the model after 400 days, or when the virus burned itself out, whichever came sooner.

The model starts with a population of 10,000 people. (The Web version only has 5,000, but the laptop version runs faster, so it's viable to have twice as large an area with twice as many people.)

With new cases per day, the base model (speed = 1.0) sees a peak of almost 90 new cases per day, just shy of 90 days into the spread of the disease.

Out of a population of 10,000, that's almost 1% of the population getting infected in a single day.

If we adopt social distancing down to speed = 0.7, the new cases peak at about 40 per day.

With speed = 0.5, we barely break 10 cases per day (0.1% of the population).

Not surprisingly, this variation in rates of new cases per day translates into vastly different numbers of people sick at any one time.

In the base case (speed = 1.0), the sick population reaches almost 1,800 -- which is almost 18% of the whole population sick at one time.

With speed = 0.7, we keep that to "only" 800.

At speed = 0.5, we hover around 200 for a while before slowly making our way down.

Both of these diagrams illustrate the idea of "flattening the curve."

The third graph shows the total number of people who die from the virus, as that number mounts day by day. With no social distancing, the death toll settles in at around 180 (or 1.8% of the population; see the explanation of the final graph below as to why it settles out).

Increasing levels of social distancing lead to modestly decreasing final death tallies. With speed = 0.6 or 0.5, it's clear the model would have to run for longer than 400 days to see where the total would settle out. But with very stringent measures, the deaths are apparently kept to about 20, or even in the single digits.


The fourth and final graph shows the cumulative number of people who get infected.

With no social distancing, that number levels off at around 8,500, or 85% of the population. The remaining 15% escape because the virus burns itself out:  there are so few susceptible individuals around that, even without social distancing, it can't find them in time to keep perpetuating itself. That's why the death toll settles out at about 1.8% of the population, even though in these model runs the virus is assumed to carry with it a 2% chance of death. Less than 2% of the population dies, because the virus itself dies out before it can infect everyone.

The same dynamic is at work with speed = 0.9, 0.8, and 0.7.

For moderately strong social distancing (speed = 0.6, or 0.5), the model needs to run longer than 400 days to see where it will settle out.

At speed = 0.4, the total infected seems to be stabilizing around 1,000 (or 10% of the population.

At very stringent social distancing (speed = 0.3, or 0.2), the virus dies out with no more than a few percent ever having become infected.

On the one hand, it's great that strong social distancing measures can bring about such effective containment of the virus.

On the other, that containment means that the great majority of people are still susceptible. And that in turn means that if you let up on your containment, the virus is still primed to take off.

I'll explore that further in a couple of days, but tomorrow's model will go in a different direction.

One of the observations of CoVID-19 is that its lethality has been between 0.5% and 1% in countries that have kept it contained (e.g., South Korea), while settling in at more like 3% or 4% in places where the spread got away from the authorities (Wuhan, Italy, Iran).

Tomorrow's model adds some detail to show the interaction between the speed with the viral wave hits and the capacity of the medical system to treat people.

A note on NetLogo
NetLogo is a relatively accessible platform for doing agent-based modeling, where you set up a world in a computer by defining the behaviors of the many individual "agents" operating in the world, then you turn it on and see what happens. You tweak the rules of behavior for your individual agents, and you see how that changes the behavior of the world as a whole.

The program is a free download (though they request registration) from their home page at http://www.ccl.sesp.northwestern.edu/netlogo/.

If you've done coding in other languages, you'll probably find it not too hard to learn NetLogo's code.

Even if you're new to coding, you can open up the program, choose a model from the "Models Library", and play around with it (look under the "File" tab).

Or you can download a model, like the one used to produce these data, available at https://drive.google.com/file/d/1tfbuGOe4IrscMcQgV93aw1y83yi4TvPq/view?usp=sharing.

Once you have NetLogo on your computer, if you double-click a NetLogo file, it will automatically open the software and the particular program as well.

In most models, you can click "setup" and then click "go" and just see what happens.

Then you can read the "Info" tab to see what you're doing.


As you get more adventuresome, you can turn to the "Code" tab and see the guts of the thing.

Enjoy!

Saturday, March 14, 2020

Keep your distance!

I haven't written anything on this blog for ... quite a while.

I'm coming back to it to share a model that may help you visualize the effect of social distancing. Instructions on making it work are below.

When you run the model, you can observe how quickly the virus spreads, how many people in total get infected, and how many people die.
What your screen might look like after 54 days of the model
When you change the degree of social distancing, you can observe changes in all of those factors.

The model is a modification of a pre-existing model of virus transmission. In that model, a small number of people start off infected. People move around randomly, and any time an infected person shares a space with a susceptible person, there's a chance that infection will occur. After a certain amount of time, the disease runs its course: the person either recovers and has acquired immunity, or they die.

The modification I made was to allow the user to change the speed with which people move around the world. Of course this is far from being a perfect representation of social distancing, but it does capture one essential element of that practice: reducing the speed of people's movement in the model reduces the frequency with which people make new contacts.

The default speed of movement is 1. The user can choose any value between 0 and 1, in increments of 0.1. If you choose a lower value, you're choosing a more thoroughgoing implementation of social distancing.

If you scroll down on your screen, you'll see tabs you can open up for the "Command Center", for "NetLogo Code", and for "Model Info". The first two of those aren't much use to you unless you know NetLogo, but if you click on "Model Info" you'll get a bunch of information about how to use the model.
Click on "Model Info" to learn much more

Some results from the fancier laptop version of the model are in the follow-up post.

Getting and using the model
Click or right-click the link below to download the file to a convenient place on your computer. When you open the file, it should automatically open the web page for NetLogo Web and allow you to run the program.
https://drive.google.com/file/d/1KtoYSCMvExdN_xaNBBM1tiWuZhF6SD3O/view?usp=sharing