Building a #SEIRD (Susceptible/Exposed/Infected/Recovered/Dead) model of the #Coronavirus in #MinskySoftware

The conventional model of infections is known as SEIR for “Susceptible/Exposed/Infected/Recovered”. This paper is one of many to produce such a model, with the relatively novel feature that it includes “resusceptibility”: the possibility that people who have been infected and have recovered might lose immunity and get it again.

Figure 1: The paper

In equations, it is as follows (in a simplified form omitting births and ordinary deaths, which is a reasonable simplifying assumption, given how quickly Covid-19 spreads):

Figure 2: The ordinary differential equations of the core model

Bryan Wisk, who is the founder of Asymmetric Return Capital, a long-time friend, and one of my patrons, volunteered to have this model developed by his staff in Minsky, and asked for some quick guidance on how to do so: hence this video. In it, I start to develop this model but don’t finish it—I’ll leave that for Bryan’s staff.

The paper itself has a “dashboard” of the model, but to run it, you need a copy of the commercial program in which it was written: Simulink, Matlab’s system dynamics program. This program is used by engineers all over the planet, and it is very expensive for non-academics. Getting a price upfront from Matlab is very difficult, but let’s say you won’t get much change out of $2,000 for an annual Simulink licence.

 

Figure 3: The Matlab Dashboard

Simulink has a lot of features and capabilities that Minsky doesn’t have, but there are shortcomings in its core functionalities that we’ve attempted to overcome in Minsky.

One is that, in Simulink, all calculations are passed “by wire”: if you want to use the output of one set of equations as an input to another, you have to draw a wire from one to the other. In Minsky, you can name the result of a set of equations—for example, “Die”—and then use that variable name elsewhere on the diagram, without needing to draw wires. This reduces model clutter compared to Simulink and almost all other system dynamics programs.

Figure 4: A Simulink model of a helicopter Flight Control System

Minsky also supports the mathematical formatting language LaTeX. In Simulink and to my knowledge all other system dynamics programs, if you want to use a variable called “”, you literally have to write the text “gamma”, and that’s what you see. In Minsky, you type \gamma, and what you see on its design canvas is . You can also use superscripts and subscripts, using the control characters _ and ^ respectively.

These are definite advances for Minsky, but if that were all there were to it, Minsky wouldn’t even exist. Minsky’s real reason for being is the unique double-entry bookkeeping feature we call “Godley Tables”. These are used to ensure that all financial flows are modelled properly, as having a source and a destination. Though our intention with the Godley Tables was to allow financial dynamics to be modelled easily, it also makes sense here when you are recording movements of people between different mutually exclusive categories. The first step in designing this Minsky model was to enter the total population (N) as an Asset, the number susceptible (S), Exposed (E), Infected (I) and Dead (D) as Liabilities, and those who have Recovered (R) as the Equity.

Minsky takes this as an input and generates the Ordinary Differential Equations automatically in the background. These are identical in structure to the equations in Figure 2, but the individual components have yet to be defined:

    

Figure 5: The initial equations in Minsky

The next step in building the model was to enter the parameters in the paper, and here there were two problems: they were scattered throughout the paper; and there were unnecessary steps taken by the authors that shows (I think!) that they are unfamiliar with the basic system dynamics concept of a time constant. This is a measure of how quickly a system state would take to reach a target level, expressed in the unit of time that makes sense for the system. With the Coronavirus, the sensible unit of time is a day, and one key “time constant” is how fast it takes for someone to go from being exposed to the disease to being actually infected. In the paper, this is called the incubation time, set at 5.1 days, and the symbol they use for it is .

This is all very sensible in system dynamics terms. The parameter is easily interpreted: if you increase its value to, say, 7, you are modelling the case where it takes about 7 days to get infected after exposure. Reduce it to 3, you are modelling where the process takes 3 days.

Unfortunately, they don’t use in their equations, but instead use , which they define on page 4 as “”. Then has the incomprehensible value of 0.196078. This is how I reproduced that in Minsky:

Figure 6: Defining as in Minsky

If I was doing this work myself and had the time, I would rewrite the equations in terms of time constants and get rid of this unnecessary step. But since I was doing this mainly to develop an instructional video for Bryan’s staff, I stuck with their equations and did this for several parameters in the model.

Figure 7: All the parameters in the model

The next step was to copy the stock (N,S,E,I,D, and R) and flow (Exp, Get, Die, Rec and GetAgain) variables from the Godley Table, which in common with so many aspects of Minsky, is on the right-mouse-button menu:

Figure 8: Copying the stock and flow variables onto the canvas

I didn’t complete the task—again, this was to instruct someone else in how to use Minsky rather than a job I intended doing from go to whoa—but I did complete a few of the definitions, including exposure, infection, and the death rates for the two different cohorts, young and over 65.

Figure 9: Defining Exposure and Infection in Minsky

Figure 10: Definitions for Die and DieOld in Minsky

One thing that will prove a bit tricky for Bryan’s staff is the use of a time delay in the original model between when the disease and its first infections occur and when policy is developed:

Figure 11: The time delay of between the occurrence of the disease and infections and the policy response

Minsky doesn’t support time delays, largely for purist technical reasons. They introduce a discrete time element into a continuous time modelling framework, and I believe that discrete time modelling—dividing time into arbitrary units called “periods”—has been a major factor in Post Keynesian economics making far less progress in dynamics than it should have. So what you have to use instead is a first order time lag: you define another variable (say Slag) and define this as something that converges to S with a lag. As an equation, this is:

    

Figure 12: First order time lag mathematics

As a Minsky flowchart, it is:

Figure 13: Implementing a first order time lag in Minsky

These variables S lag and I lag then replace and in the model:

    

This means that the Minsky model won’t quite match the simulation by the Simulink data, and some fine tuning will be needed to go from the delay they used (30 days) to a suitable time lag (I guessed at 14 days here). But those, in the customary words of the University lecturer, I leave as an exercise for the reader.

Over to you, Bryan and staff.