SERVING THE QUANTITATIVE FINANCE COMMUNITY

Cuchulainn
Topic Author
Posts: 61609
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

### Re: Models for Covid-19

Some practical questions which will crop up, so I ask them now.

1. How can I print this figure only (and not the whole bunch of posts).
2. What are the axes' units (y = fraction?, s = S/N?, x = time (days etc.). I reckon absolute numbers for y? My chickenpox prototype used fractions.
3. Are the values of S.I, R, H and D of the same size to get them into a nice single plot? Of course, each one can get its own plot.

http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget

Paul
Posts: 10505
Joined: July 20th, 2001, 3:28 pm

### Re: Models for Covid-19

2. I haven't mentioned units in the ODEs, so they are as they come out of the numerics. But good idea to think of units. Let's make time years, that will mean that when we get parameters they will have meaning.

3. I didn't scale in any way. Axis could go up to 10 i.e. N. Perhaps best to divide all output by N, to get fraction of population. With my parameters they all work on same scale. With better parameters we hope that deaths will need a different scaling.

Cuchulainn
Topic Author
Posts: 61609
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

### Re: Models for Covid-19

2. For the chicken pox the annual birthrate had to be divided by 52 and e.g. the graph of $I(t)$ is up to 20/25 weeks (it's 50 years since I did dimensional analysis). Realising this subtle point allowed me to reproduce the results. Not unimportant.

I learned a new word today "physiological time unit" $\neq$ chrono time unit.
"degree days"
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget

Herd
Posts: 562
Joined: October 2nd, 2003, 12:48 pm

### Re: Models for Covid-19

Paul
Posts: 10505
Joined: July 20th, 2001, 3:28 pm

### Re: Models for Covid-19

trackstar
Posts: 27308
Joined: August 28th, 2008, 1:53 pm

### Re: Models for Covid-19

The Global Impact of COVID-19 and Strategies for Mitigation and Suppression - Report 12 March 26 2020

and

https://www.imperial.ac.uk/media/imperi ... 3-2020.pdf

If any further information on this front, I will put it on the Pandemic Models thread in the OT for convenience.

Paul
Posts: 10505
Joined: July 20th, 2001, 3:28 pm

### Re: Models for Covid-19

Why are they so coy with their maths?

trackstar
Posts: 27308
Joined: August 28th, 2008, 1:53 pm

### Re: Models for Covid-19

Why are they so coy with their maths?
for the same reason that men are so coy with their XX,000 lines of code or their gigantic C and Fortran libraries from ancient times.

They need someone else to come in and tidy things up a bit?

Cuchulainn
Topic Author
Posts: 61609
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

### Re: Models for Covid-19

Why are they so coy with their maths?
Anyone remember Edward Woodward?

"Adding manpower to a late software project makes it later." Fred Brooks
You only need 2-3 key people for any software project.
Last edited by Cuchulainn on March 27th, 2020, 12:13 am, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget

Cuchulainn
Topic Author
Posts: 61609
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

### Re: Models for Covid-19

Why are they so coy with their maths?
for the same reason that men are so coy with their XX,000 lines of code or their gigantic C and Fortran libraries from ancient times.

They need someone else to come in and tidy things up a bit?
Clean the decks, actually. I agree with the legendary Fred Brooks (father of IBM 360, before everyone's here time, lol).
Start again!
https://en.wikipedia.org/wiki/Fred_Brooks

http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget

trackstar
Posts: 27308
Joined: August 28th, 2008, 1:53 pm

### Re: Models for Covid-19

Clean the decks, actually. I agree with the legendary Fred Brooks (father of IBM 360, before everyone's here time, lol).
Start again!
Well, time is circular, is it not?
One more picture, for the road - patron saints of code

katastrofa
Posts: 8982
Joined: August 16th, 2007, 5:36 am
Location: Alpha Centauri

### Re: Models for Covid-19

Quick implementation of SEIHR in Python (no differentiation between households and other yet):
import numpy as np
from scipy.integrate import odeint
import matplotlib.pyplot as plt

N = 6.6e6 #population size
N_INFECTED = N/1e3

def covid19(x,t):

a1 = 0.1/14*100 #probability of contracting from infected (10% risk of infection if in contact for 14 days, 100 contacts within this period)
a2 = a1/10 #probability of contracting from presymptomatic (during virus incubation period)
d = 1/21 #rate of recovery from infection without hospitalisation (average recovery in 2.5 weeks)
e = 1/35 #rate of complete recovery at hospital
f = e*0.16 #rate of death at hospital (only hospitalised die in this model)
g = d*0.2 #rate of intected degrading to critical cases requiring hospitalisation (20% requires hospitalisation)
k = 1/4 #rate of developing infection, where the average incubation time is 1/k

S = x[0]
E = x[1]
I = x[2]
H = x[3]
R = x[4]

dSdt = -a1/N*S*I - a2/N*S*E #susceptible stock
dEdt = a1/N*S*I + a2/N*S*E - k*E #exposed stock
dIdt = k*E - g*I - d*I #infected stock
dHdt = g*I - e*H - f*H #hospitalised stock
dRdt = d*I + e*H #recovered stock

return [dSdt,dEdt,dIdt,dHdt,dRdt]

x0 = [N-3*N_INFECTED,N_INFECTED,N_INFECTED,N_INFECTED,0]
t0 = 0
t1 = 180
dt = 0.01
t = np.linspace(t0,t1,int((t1-t0)/dt))

x = odeint(covid19,x0,t)

S = x[:,0]
E = x[:,1]
I = x[:,2]
H = x[:,3]
R = x[:,4]
D = N-(S+E+I+R+H)

plt.figure(figsize = (10,10))

plt.plot(t,S,label='Susceptible')
plt.plot(t,E,label='Exposed')
plt.plot(t,I,label='Infected')
plt.plot(t,R,label='Recovered')
plt.plot(t,H,label='Hospitalised')
plt.plot(t,D, label='Deceased')
plt.legend()

plt.figure(figsize = (10,10))

plt.plot(t,D/(R+D),label='Fatality rate')

Paul
Posts: 10505
Joined: July 20th, 2001, 3:28 pm

### Re: Models for Covid-19

You can make f a function of H easily, no?

If you don't want to do many households just do two: One group with infected, one group with no one infected.

katastrofa
Posts: 8982
Joined: August 16th, 2007, 5:36 am
Location: Alpha Centauri

### Re: Models for Covid-19

I tried to use realistic parameters based on available data and medical reports that I read daily, but I didn't research it thoroughly - they might have changed. That's why I plan to put the model in an optimiser to fit the params to data trends. First I want to remove some unrealistic assumptions of SIR models though.

katastrofa
Posts: 8982
Joined: August 16th, 2007, 5:36 am
Location: Alpha Centauri

### Re: Models for Covid-19

"You can make f a function of H easily, no?"

Good point.
    S = x[0]
E = x[1]
I = x[2]
H = x[3]
R = x[4]

a1 = 0.1/14*100 #probability of contracting from infected (10% risk of infection if in contact for 14 days, 100 contacts within this period)
a2 = a1/10 #probability of contracting from presymptomatic (during virus incubation period)
d = 1/21 #rate of recovery from infection without hospitalisation (average recovery in 2.5 weeks)
e = 1/35 #rate of complete recovery at hospital
if H < 20000:
f = e*0.16 #rate of death at hospital (only hospitalised die in this model)
else: #overstretched hospitals
f = 3*e*0.16
g = d*0.2 #rate of intected degrading to critical cases requiring hospitalisation (20% requires hospitalisation)
k = 1/4 #rate of developing infection, where the average incubation time is 1/k

#the rest of the previous code