[PYTHON] [Introduction to infectious disease model] I tried fitting and playing ♬

This time, I extended the SIR model and tried fitting with the SIHR model. ** This article was also written by an amateur, so please handle the content at your own risk **

In the previous SIR model, since S-I-R progresses in a chain at a certain rate, the delay of the transition from the current I to R cannot be reproduced. Therefore, it is assumed that the I-R process actually heals after a certain isolation state such as Hospital or Home. The differential equation of time evolution is as follows. For the time being, it is assumed that the H and R states do not increase the number of infected people.

{\begin{align}
\frac{dS}{dt} &= -\beta \frac{SI}{N} \\
\frac{dI}{dt} &=  \beta \frac{SI}{N} -\gamma I \\
\frac{dH}{dt} &=  \gamma I-\delta I \\
\frac{dR}{dt} &=  \delta I \\
\end{align} 
}

[Reference] Here are three references to help you understand the land of infectious diseases. The first article is very interesting (pdf) ・ [Mathematical Infectious Diseases-Hisashi Inaba, The University of Tokyo @ Lecture at the 7th Annual Meeting of the University of Tokyo "Medical Care and Actuaries"] ) ・ Prediction of infectious disease epidemics: Quantitative issues in infectious disease mathematical models @ Hiroshi Nishiura, Hisashi InabaDifferential equations and mathematical epidemiology of infectious diseases @ Hisashi Inaba

What i did

・ Situation in Japan ・ Situation of each country ending ・ Increasing situation in each country

・ Situation in Japan

First, the graph as of April 30 of Japan, which is the target, is shown. The horizontal axis starts from days_from_22_Jan_20, which is exactly the 100th day. original_data_Japan_430linear.png The number of existing infections (red plot), the number of cures (green plot), and the number of deaths (blue plot) in this graph are shown in semi-logarithm as follows. It is a beautiful parallel curve. In other words, it can be seen that I-R and I-D transitions occur at a constant rate. It can be seen that the slightly wavy part indicates the rapid spread of infection. Furthermore, it cannot be determined, but at the same time, it can be inferred at what time each transition occurs. original_data_Japan_430.png Looking at the graph, looking at the bar graph of the number of new infections, it has completely peaked out, and after that, the number of existing infections is likely to start decreasing. Certainly, the number of hospitalizations nationwide turned negative on May 1st yesterday. However, it has become positive again today. The biggest concern is whether or not it will end properly in the future. The results (conditions will be described later) are as follows. The fitting results and predictions of the daily number of new infections are shown in the day_est red plot, and the number of existing infections and the number of cures can be fitted respectively. In addition, this time the fitting of the number of deaths is abandoned in the model. However, since the number of deaths and the number of cures can be predicted to be similar for a while, it can be predicted that the number will still increase from the transition of the number of males. SIHR_Japan_f1=1f2=1s0=20893.png If you plot the number of new infections on a semi-logarithm basis, Mr. Omi was talking at a press conference of experts last night, but you can see the inclination. And it can be seen that the slope is smaller after it starts to decrease than the part where it increases. In other words, there is a possibility of prolongation. In general, the graph at the bottom shows that the number of existing infections (hospitalization) will be halved in a month and a half. To speed this up, as Mr. Nishiura mentioned, reduce the contact rate with infected people. In the above formula, it means lowering $ \ beta $. Another way is to raise $ \ gamma $ to increase the cure rate. It will substantially reduce the number of execution reproductions ($ \ frac {\ beta} {\ gamma} \ frac {S} {N} $). When this value is 1 or less, infection transmission cannot occur and the infected person disappears spontaneously. Well, to put it in words, if the number of infected people decreases and the infection can be cured more and more, the infection will disappear spontaneously. SIHR_Japanf1_1f2_1;b_6.81e-06d_2.69e-02g_8.41e-02r0_5.29S0_20893I0_1R0_0.png Actually, the value as N is changed from the actual observed value, but since the discussion is troublesome, I will summarize the idea. By the way, the effective reproduction number R = 1.03 until last night in Japan, the infection rate is $ \ gamma (R-1) = 7.7e ^ {-4} $, and the situation is that 0 new infections are finally realized. Is. The basic reproduction number is 5.09, which is a fairly high value, so if an infected person comes to an unprotected population, it can be said that the speed of infection spread is fast.

・ Situation of each country ending

Look at each country in the same way

Switzerland

Switzerland was the best fit. The end has come to an end as follows. The effective reproduction number is 0.21 and the infection rate is -0.049, and the number of new infections peaked at over 1000, but has decreased to about 100. In Switzerland as well, the slope at the time of increase and decrease is about four times that at the time of increase, and the slope at the time of decrease is about the same as in Japan (single digit / 40 days). SIHR_Switzerland_f1=1f2=1s0=35646.png SIHR_Switzerlandf1_1f2_1;b_6.17e-06d_6.22e-02g_1.05e-01r0_3.54S0_35646I0_1R0_0.png

Germany

It is Germany that is ending cleanly. The effective reproduction number was 0.22, the infection rate was -0.054, and the number of new infections peaked at 7,000, but has now decreased to about 1,000. It is still more than the peak in Japan, but the rate of decrease is large. The problem in Germany is the rate at which the number of new infections declines. Compared to Japan and Switzerland, the slope is slightly smaller and the base remains, which may become a new source of infection. It can be said that the situation is still unpredictable. ** Looking at this graph, we can see that the appearance of the death number curve is the same as the translation of the healing number curve. ** ** SIHR_Germany_f1=1f2=1s0=193772.png SIHR_Germanyf1_1f2_1;b_1.25e-06d_6.93e-02g_1.26e-01r0_3.49S0_193772I0_1R0_0.png

Korea

It is reported that South Korea is an excellent country, so let's take a look. It is as follows. The effective reproduction number is 0.04, and the infection rate is -0.051. However, the bar graph for new infections shows that it did not decrease from 100 for almost a month. Then, when the number of existing infections and the number of cures crossed, it started to decrease about a month ago and finally decreased to about 10. In other words, what we should learn is the fact that we must be alert even after the end of this process. SIHR_Korea, South_f1=1f2=1s0=16170.png SIHR_Korea, Southf1_1f2_1;b_1.70e-05d_5.34e-02g_3.15e-02r0_5.15S0_16170I0_1R0_0.png

Thailand

Although it is not well known, Thailand is relatively excellent. As many of you may remember, from the beginning, as in Japan, we have been competing for infected people alongside Japan and Singapore. Thailand was the first to end in these three countries. The effective reproduction number is 0.49, and the infection rate is -0.055. The rate of decrease in the bar graph of the number of new infections (1 digit / 20 days) has also decreased with the same large slope as the recent one in South Korea, and the number of new infections has decreased to 10. The feature is that it has become a flat plateau near the peak. It can be evaluated that this suppressed the peak, but it can be said that the peak was prolonged. You will need to look back on what the content was. SIHR_Thailand_f1=1f2=1s0=6905.png SIHR_Thailandf1_1f2_1;b_3.26e-05d_1.07e-01g_4.00e-02r0_2.10S0_6905I0_1R0_0_.png

Italy

Italy, which is progressing slowly and has been clamoring for the collapse of medical care, is likely to come to an end. Fitting is inadequate in Italy as the peak is sloppy and prolonged. However, the effective reproduction number is 0.13 and the infection rate is -0.024. However, the decrease is so slow that it cannot be said that it has ended sufficiently. At the peak, the number of new infections was more than 6,500, but now it has decreased to about 2,000. Above all, the number of existing infected people has started to decrease and has decreased to about 100,000. And above all, the number of cures has been steadily increasing, and it seems that the collapse of medical care has probably been avoided.

USA

Well, it's a country that is wondering if it's okay to put it in here. The results are as follows In other words, the number of new infections has peaked and has not decreased. Therefore, the fitting is inadequate, and the results are for reference only. For the time being, the effective reproduction number is 0.53 and the infection rate is -0.016, so it should decrease, but it seems that the infection has reached its 5th peak (almost every week) and the infection is spreading repeatedly. Moreover, when viewed on a linear scale, the cumulative number of cures is 200,000, but the increase seems to be slow. To be clear, it can be said that the corona of the world will not disappear unless the infection in this country stops. I think it's time to work hard and put up with it. SIHR_US_f1=1f2=1s0=1517346.png SIHR_USf1_1f2_1;b_1.35e-07d_3.53e-02g_2.64e-02r0_5.82S0_1517346I0_1R0_0_.png

・ Increasing situation in each country

After all, let's take a look at India and Russia.

Russia

It's a period of great expansion. We were able to calculate the effective reproduction number of 2.85 and the infection rate of 0.063. However, S0 may be a little too big. It is still before the peak, and since it is in the expansion period, it is unknown how much the number of infections will increase, so this value is set. Still, overall it seems to be saturated. The number of new infections will peak in a few days, and the number of infections is likely to peak in about two weeks (however, it cannot be guaranteed because it will change if the parameters are changed a little). SIHR_Russia_f1=1f2=1s0=373370.png SIHR_Russiaf1_1f2_1;b_4.17e-07d_3.40e-02g_4.66e-02r0_4.58S0_373370I0_1R0_0.png

India

The next concern is India. India was about to start seeing a little peak last time. We were able to calculate the effective reproduction number of 1.57 and the infection rate of 0.030. The number of new infections has almost peaked, and the number of existing infections is likely to peak in the next week. The number of cures is approaching the existing infection curve and appears to be ahead of Russia. SIHR_India_f1=1f2=1s0=89416.png SIHR_Indiaf1_1f2_1;b_1.84e-06d_5.19e-02g_7.42e-02r0_3.17S0_89416I0_1R0_0.png

Summary

・ Expanded the model to SIHR to improve fitting accuracy ・ Implemented and considered fittings from Japan and other countries ・ It can be said that Japan has reached the point where it can be put to an end in a breath, but when looking at the situation in each country, the recent behavior of Tokyo and Hokkaido, and above all, the problem will become bigger unless the situation of nosocomial infections is improved. It can be said that the situation is unforgivable. ・ It can be seen that each country that is ending is in a difficult situation.

・ Finally, I would like to carry out statistical treatment on the introduction of the distribution function and the accuracy of the obtained quantities.

bonus

The problem with the differential equation this time is that S0 is unclear. Once it is finished, it can be evaluated to a certain extent, but it is difficult to determine an appropriate S0 in the situation before the end. Below, I will post the fitting situation in Japan when S0 is changed briefly. ** Furthermore, if behavior change is actually effective, the slope of the decrease, that is, each coefficient of the differential equation, is not constant, so it is better to think that this analysis method still shows a general tendency. .. ** ** SIHR_Japan_f1=1f2=1s0=13929.png SIHR_Japan_f1=1f2=1s0=16714.png SIHR_Japan_f1=1f2=1s0=20893.png SIHR_Japan_f1=1f2=1s0=25072.png SIHR_Japan_f1=1f2=1s0=27858.png

Recommended Posts

[Introduction to infectious disease model] I tried fitting and playing ♬
[Introduction to PID] I tried to control and play ♬
[Introduction to AWS] I tried playing with voice-text conversion ♪
[Introduction to AWS] I tried porting the conversation app and playing with text2speech @ AWS ♪
[Introduction to simulation] I tried playing by simulating corona infection ♬ Part 2
[Introduction to infectious disease model] All parts of Japan are ending ... ♬
[Introduction to AWS] Text-Voice conversion and playing ♪
[Introduction to Infectious Disease Model] World Infection Status as Seen by MACD ♬
I implemented the VGG16 model in Keras and tried to identify CIFAR10
I implemented DCGAN and tried to generate apples
I tried to implement TOPIC MODEL in Python
I made an image classification model and tried to move it on mobile
[Introduction to infectious disease model] Looking at the logarithmic graph. .. .. It's the second wave! ??
I tried to debug.
I tried to paste
I tried to read and save automatically with VOICEROID2 2
I tried to implement and learn DCGAN with PyTorch
I tried adding post-increment to CPython. Overview and summary
I tried adding system calls and scheduler to Linux
[Introduction to Pytorch] I tried categorizing Cifar10 with VGG16 ♬
I tried to implement Grad-CAM with keras and tensorflow
I tried to install scrapy on Anaconda and couldn't
[Introduction to Infectious Disease Models] What is the difference between the April epidemic and this epidemic? .. .. ‼
I tried to predict and submit Titanic survivors with Kaggle
I tried to learn PredNet
[I tried using Pythonista 3] Introduction
[Introduction to pytorch] Preprocessing by audio I / O and torch audio (> <;)
I tried to get Web information using "Requests" and "lxml"
I tried to implement PCANet
Introduction to Nonlinear Optimization (I)
[Introduction to Pandas] I tried to increase exchange data by data interpolation ♬
I tried to illustrate the time and time in C language
Fitting to ARMA, ARIMA model
I tried to reintroduce Linux
I tried to introduce Pylint
Mongodb Shortest Introduction (3) I tried to speed up even millions
I tried to enumerate the differences between java and python
I tried to summarize SparseMatrix
I tried to make GUI tic-tac-toe with Python and Tkinter
[Introduction to Tensorflow] Understand Tensorflow properly and try to make a model
I tried to touch jupyter
[Introduction to Mac] Convenient Mac apps and settings that I use
I tried to implement StarGAN (1)
I displayed the chat of YouTube Live and tried playing
[Introduction to infectious disease model] Looking at the logarithmic graph. .. .. One week from "the second wave"!
I tried to divide with a deep learning language model
I tried to implement SSD with PyTorch now (model edition)
I tried fitting the exponential function and logistics function to the number of COVID-19 positive patients in Tokyo
I tried to visualize bookmarks flying to Slack with Doc2Vec and PCA
Introduction to Nonparametric Bayes 2 (Indian Buffet Process and Latent Feature Model)
I tried to implement anomaly detection using a hidden Markov model
I tried to let Pepper talk about event information and member information
I tried to make a periodical process with Selenium and Python
I tried to create Bulls and Cows with a shell program
I tried to easily detect facial landmarks with python and dlib
[Introduction to SIR model] Consider the fitting result of Diamond Princess ♬
I tried to extract players and skill names from sports articles
I tried to implement Deep VQE
I tried to create Quip API
I tried to touch Python (installation)
[Introduction to Python3 Day 1] Programming and Python