[PYTHON] Verify the effect of leave as a countermeasure against the new coronavirus with the SEIR model

Introduction

As of March 5, 2020, Japan's situation regarding the new coronavirus (COVID-19) has been taken very seriously, including immigration restrictions from other countries. Although the government has requested that all elementary, junior high and high schools be closed all over the country, and some have questioned the effect, it is also understood that political judgment is necessary because it is difficult to show scientific grounds. I can do it. This article uses the SEIR model, which is one of the mathematical models of infectious diseases, to verify whether it is possible to control the peak of infection by taking a certain period of time off from a school or business establishment (with a scale of 1000 people). is. However, this article is a simulation under limited assumptions and does not provide scientific confirmation or academic evidence. We do not take any responsibility as it may be helpful or incorrect. For most of the programs, I referred to this article.

Prerequisites

Details of the SEIR model are omitted in this article, but in Wikipedia According to

It is composed of, and its acronym is called SEIR model. It seems. SEIR model parameters include

there is. According to Ministry of Health, Labor and Welfare, the incubation period is "according to WHO's knowledge, the incubation period is currently Is 1-12.5 days (mostly 5-6 days), "so let's assume 5.5 days. The duration of infection is unknown, but it is said that fever will continue for about 4 days after the onset and then recover or become severe, so it is assumed to be 8 days. (If the condition becomes severe, it is considered that the patient will be hospitalized, but the mildly ill person shall recover while living a normal life without being aware of it.) The most important is the infection rate, but based on the data provided by the Ministry of Health, Labor and Welfare, we have done the following.

Infection rate

According to Q & A of the Ministry of Health, Labor and Welfare, the frequency with which one infected person causes secondary infection is shown in the figure below. It seems. Q14.jpg From this data, using uniform random numbers, Define a function that calculates the rate R0 (basic reproduction number) that produces a secondary infection.

def COVID19R0(er):
    if np.random.rand() < er:
        # good environment
        if np.random.rand() < 0.8:
            R0 = 0
        else:
            R0 = np.random.randint(1,4)*1.0
    else:
        # bad environment
        R0 = np.random.randint(0,12)*1.0
    return R0

Here, er is defined as the probability that the source of infection was in a poorly ventilated environment.

Additional parameters

We also want to evaluate the impact of the leave, so we will introduce the following parameters.

Based on R0 and these parameters, I modified the SEIR model as follows:

#define differencial equation of seir model
def seir_eq5(v,t, keys):
    er = keys['er']
    lp = keys['lp']
    ip = keys['ip']
    tb = keys['tb']
    te = keys['te']
    #
    if t >= tb and t <= te: #Holiday period
        R0 = 0 #Completely closed (when there are no people in the school / business office)
    else:
        R0 = COVID19R0(er)
    #
    ds = - R0/ip * v[2] if v[0] >= 0 else 0 # note: s >= 0
    de = -ds - (1/lp) * v[1]
    di = (1/lp)*v[1] - (1/ip)*v[2]
    dr = (1/ip)*v[2]
    return [ds, de, di, dr]

Other programs

Import the library to run the simulation.

import numpy as np
import matplotlib.pyplot as plt

Define a function to solve the ODE.

def my_odeint(deq, ini_state, tseq, keys):
    sim = None
    v = np.array(ini_state).astype(np.float64)
    dt = (tseq[1] - tseq[0])*1.0
    for t in tseq:
        dv = deq(v,t, keys)
        v = v + np.array(dv) * dt
        if sim is None:
            sim = v
        else:
            sim = np.vstack((sim, v))
    return sim

Code that calculates and graphs the results.

#solve seir model
ini_state=[999,0,1,0]
t_max=180
dt=0.01
t=np.arange(0,t_max,dt)
#
keys = {'er':0.5, 'lp':5.5, 'ip':8, 'tb':0, 'te':0}
sim = my_odeint(seir_eq5, ini_state, t, keys)
#
plt.rcParams["font.size"] = 12
fig, ax = plt.subplots(figsize=(10,5))
ax.plot(t,sim)
ax.set_xticks(np.linspace(0,t_max,19))
ax.set_yticks(np.linspace(0,1000,11))
ax.grid(which='both')
ax.legend(['Susceptible','Exposed','Infected','Recovered'])
plt.show()

Here, er (probability that the source of infection was in a poorly ventilated environment) was assumed to be 0.5.

simulation result

We will start with one infected person on the 0th day out of 1000 offices.

The first is when you do not take any leave.

nonstop.png The peak is about the 60th day, and there are days when there are up to about 320 infected people.

This is the case when we are closed for 20 days from a very early stage (30th day).

tb30te50.png The peak is about the 95th day, and there are days when there are up to about 310 infected people. It is interesting that the peak delay days (35 = 95-60) are longer than the holidays (20 days).

This is the case when the patient is closed for 20 days from the stage when the infection begins to rise rapidly (day 50).

tb50te70.png Peaks are dispersed on days 52 and 90, with up to about 200 infected days occurring on day 90.

This is the case when the patient is closed for 20 days from the stage when the infection begins to subside (60th day).

tb60te80.png The result is the same as if you do not take any leave. This is thought to be because on the 60th day, there were no people who were not immune to S: infection (Susceptible).

Consideration

From the above, the following trends can be derived from the simulation regarding the peak control of infection by taking a certain period (20 days) of absence from schools and business establishments (with a scale of 1000 people).

Therefore, if you want to take a leave of absence, it may be most effective to do it from "the stage when the infection starts to rise rapidly" to "before the infection starts to subside".

Furthermore ...

Reference link

I referred to the following page.

Recommended Posts

Verify the effect of leave as a countermeasure against the new coronavirus with the SEIR model
Let's simulate the effect of introducing a contact tracking app as a countermeasure against the new coronavirus
GUI simulation of the new coronavirus (SEIR model)
I tried to predict the behavior of the new coronavirus with the SEIR model.
Let's explain the difference in how the new coronavirus spreads between Japan and other countries with a cluster countermeasure model
Analyze the topic model of becoming a novelist with GensimPy3
Plot the spread of the new coronavirus
Save the result of the life game as a gif with python
I tried to predict the number of domestically infected people of the new corona with a mathematical model
The story of the student who developed the new coronavirus countermeasure site (Ishikawa version)
Estimate the peak infectivity of the new coronavirus
I tried to create a model with the sample of Amazon SageMaker Autopilot
I tried to automatically send the literature of the new coronavirus to LINE with Python
A model that identifies the guitar with fast.ai
Factfulness of the new coronavirus seen in Splunk
I tried to make something like a chatbot with the Seq2Seq model of TensorFlow
The theory that the key to controlling infection with the new coronavirus is hyperdispersion of susceptibility
I tried to visualize the characteristics of new coronavirus infected person information with wordcloud
Let's put out a ranking of the number of effective reproductions of the new coronavirus by prefecture
Get the variable name of the variable as a character string.
Take a screenshot of the LCD with Python-LEGO Mindstorms
Visualize the characteristic vocabulary of a document with D3.js
Let's test the medical collapse hypothesis of the new coronavirus
Tasks at the start of a new python project
Output the output result of sklearn.metrics.classification_report as a CSV file
Calculate the product of matrices with a character expression?
(First post) A story about numerical calculation of influenza and new pneumonia coronavirus with Tensorflow
Severe Acute Respiratory Syndrome: Understanding the Role of Social Distance Strategy with a Simple Model
If the people of Tokyo become seriously ill with the new coronavirus, they may be taken to a hospital in Kagoshima prefecture.