[PYTHON] [SIR model analysis] Peak out of infection numbers in Japan and around the world ♬

I recalculated with the following data this morning, so I will post the result. ** The content of this article was written by an amateur, and the responsibility should be judged at the reader's own risk. ** ** The theory was added for clarity (4.12.2020)

For the data, download and use the three files (time_series_covid19_confirmed_global.csv, time_series_covid19_deaths_global.csv, time_series_covid19_recovered_global.csv) from the following reference ①. For some Japanese data, read the data in Reference ② and rewrite confirmed in the above file. French and British territories are deleted from the three files because the data does not work. [Data acquisition] ①COVID-19/csse_covid_19_data/csse_covid_19_time_series (2) New coronavirus seen in data and graphs @ NTV NEWS

・ Theory (as easy to understand as possible)

The following SIR model is used. (See above for derivation)

{\begin{align}
\frac{dS}{dt} &= -\gamma R I \\
\frac{dI}{dt} &=  \gamma (R - 1) I \\
\frac{dr}{dt} &=  \gamma I \\
\end{align} 
}

The meanings of these formulas are as follows: ** First equation; the number of uninfected $ S $ on the next day decreases by $ \ gamma R $ times the number of existing infections $ I $ ** ** Second equation; the number of infections on the next day increases by $ \ gamma (R-1) $ times the number of existing infections $ I $ ** ** Third equation; the number of cures (+ deaths + quarantine (0 this time)) on the next day increases by $ \ gamma $ times the number of existing infections $ I $ ** That is, it can be seen that the relationship between the second equation is the inflow from the first equation and the outflow from the third equation. In the above equation, the number of existing infections $ I $ and the cumulative number of cures $ r $ are the observed values, and the numerical differentiation $ \ frac {dI} {dt}, \ frac {dr} {dt} $ is used using them. By

** ・ From the second equation $ \ gamma (R-1) $ ** ** ・ From the third equation $ \ gamma $ ** Is calculated, and as a result, $ \ gamma $ and $ R $ are calculated. Also, parameters related to medical collapse: Ratio of existing infections $ I $ to removed (= recovery + deaths) $ r $

\frac{I}{r+D}

Is being calculated. (Indicated as $ \ frac {I} {R + D} $ in the graph) If the number of cures increases to 1 or less, the number of existing infections will not increase anymore, and medical collapse will be avoided. On the other hand, if it remains large, medical collapse will eventually occur, and the number of cures will decrease and increase. However, if the number of deaths (or mortality rate, these are measured values) increases, this index will decrease, but it is still a medical collapse and caution is required. Therefore, as the meaning of the coefficients of this equation ** ・ $ \ gamma $ is a coefficient that depends on the nature of the virus and the medical facility and medical system ** ** ・ $ R $ is called the effective reproduction number, which is a coefficient that can be reduced by so-called behavioral change (transformation) ** It can be said that.

The variables have the following relationship. $ R $; removed (= recovery + death + quarantine) is lowercase to avoid confusion with the effective reproduction number.

{\begin{align}
R &=  R_0 \frac{S}{N}\\
R_0 &= \frac{\beta}{\gamma} \\ 
\end{align} 
}

In addition, each of the above three files Cumulative number of infections = time_series_covid19_confirmed_global.csv Number of cures = time_series_covid19_recovered_global.csv Number of deaths = time_series_covid19_deaths_global.csv is. If you calculate this every day, you will be able to find $ \ gamma $, $ R $ for each day.

・ The code is placed below

(Updated; Derived by the above theory; The result does not change, and the fitting is changed in 10 days from the calculation date) (4.13.2020) ・ Collive_particles / fitting_gamma_R_II.py (Before update; derived with gamma * (R-1)) ・ Collive_particles / fitting_gamma_R.py

What I did; Graph of each country

·Japan ·world ·America ・ Italy, Spain, France, Switzerland ・ Korea, Iran ・ Wuhan, Beijing, Hong Kong, Taiwan ·India

·Japan

The number of existing infections (red plot in the above figure) suddenly changed its slope in late March, accelerating the spread of infection. The above effective reproduction number R_est increased and $ \ gamma (R-1) $ remained at a high number and entered the dangerous area. removed_Japan_gamma_R_5.png Feature (1) Red plot in the above figure; almost straight line with continuous expansion (2) Green plot in the above figure; The rate of increase in the number of males remains low ⇒ Healing of infected persons before the spread of infection ⇒ Prediction; Healing of infected persons during the subsequent expansion period ③ Black plot I / (R + D) in the above figure; worsening due to spread of infection ⇒ prediction; then peaks and decreases ④ Blue plot R in the figure below; the number of effective reproductions exceeds 10 and is the 15th largest value.

However, the graph of $ \ gamma (R-1) $ is as follows Last time, it increased monotonously, but now it has flattened and decreased, so it is a sign that the spread of infection will subside! removed_Japan_gammaR_5.png

·world

Although the number of existing infections is on the rise, it is more likely that $ \ gamma (R-1) $ will enter a declining stage and the peak number of infections will be visible. removed_world_gamma_R_5.png (1) Red plot in the above figure; the increasing trend has slowed down (2) Green plot in the above figure; monotonously increasing (3) Black plot I / (R + D) in the above figure; exterpolate_world_gamma_R_5.png (4) The number of existing infected persons has become dull compared to this, as the slope of the forecast straight line for monotonous increase has become smaller. Situation where up to 10 million people do not go removed_world_gammaR_5.png (5) From the above graph, the downward trend of $ \ gamma (R-1) $ continues, and the number of existing infected people will reach its peak in about 11 days. This graph has fallen weekly twice in a row, and it's interesting to see what happens this week.

·America

Similar to global trends, the number of existing infections is on the rise, but saturation has begun to appear, and $ \ gamma (R-1) $ has entered a declining phase, increasing the likelihood of peak infections. removed_US_gamma_R_5.png The cumulative number of infections is about 500,000, but the data appear to be stable and managed. (1) Red plot in the above figure; the increasing trend is slowing down (2) Green plot in the above figure; increasing trend but seems to have slowed down ③ Black plot I / (R + D) in the above figure; slowly decreasing, but the number of cures is still small removed_US_gammaR_5.png ④ The number of infections is likely to peak soon. However, with this prediction straight line, two straight lines, one for one week and the other for 20 days, can be drawn, so it is thought that the number of infections will peak during this period. exterpolate_US_gamma_R_5.png (5) In the above figure, even if the number of infections is the shortest, it is likely that the number of existing infections will reach 1 million.

・ Italy, Spain, France, Switzerland, Germany

The effects of lockdown have begun to appear in European countries, and the number of infections is almost at its peak, but $ \ gamma (R-1) $ is stagnant and the situation is unpredictable. Lockdown time (from Twitter); around March 20 (Northern Italy 3/8, Spain 3/14, Germany 3/16, France 3/17)

·Italy

removed_Italy_gamma_R_5.png ① Red plot in the above figure; almost flat (2) Green plot in the above figure; steadily increasing ③ Black plot I / (R + D) in the above figure; it decreases stably and linearly, but it takes time because the slope is small. removed_Italy_gammaR_5.png ④ It seems that it is steadily decreasing, but it may be a little dull because it is lined up side by side here. If it continues to decrease, the number of existing infections will reach its peak in another week. The situation does not allow prejudice.

·Spain

removed_Spain_gamma_R_5.png (1) Red plot in the above figure; saturated. Where it will start to decrease (2) Green plot in the above figure; increased linearly and recovered to almost the same level as the number of existing infections. ③ Black plot I / (R + D) in the above figure; Reflecting the above, it linearly approached 1 and came to almost 1. removed_Spain_gammaR_5.png (4) However, this figure shows that $ \ gamma (R-1) $ has slowed down before 0.05, and the situation is unpredictable. If there is no problem, the number of infections will peak in 3-4 days.

·France

removed_France_gamma_R_5.png (1) Red plot in the above figure; It seems that it has peaked, but I am a little worried because there is data. (2) Green plot in the above figure; It is steadily increasing and is likely to reach the same value as the number of existing infections soon. ③ Black plot I / (R + D) in the above figure; It is on a downward trend, but the slope is small, so medical institutions are likely to continue to face difficult situations. removed_France_gammaR_5.png ④ I can't say anything because the data is rough. There is a tentative downward trend, and the actual peak number of infections is likely to take 20 days or more.

·Switzerland

removed_Switzerland_gamma_R_5.png (1) Red plot in the above figure; The number of infections seems to have peaked, but the decrease is extremely slow. (2) Green plot in the above figure; It increased steadily and became the same value as the number of infections, but the increase slowed down. (3) Black plot I / (R + D) in the above figure; The slope became smaller before 1, but it became about 1. Still unpredictable removed_Switzerland_gammaR_5.png ④ After all, it seems that it will take some time to finish. The situation is still unpredictable.

·Germany

removed_Germany_gamma_R_5.png (1) Red plot in the above figure; the number of infections exceeded the peak with behavior similar to Switzerland. (2) Green plot in the above figure; Although it is squeaky, it reached a value similar to the peak number of infections, but the increase slowed down. (3) Black plot I / (R + D) in the above figure; Similar to Switzerland, the slope became smaller before 1 but it became about 1. Still unpredictable ④ Blue plot in the figure below; Effective reproduction number = 1 is just around the corner, so it's almost over. removed_Germany_gammaR_5.png ⑤ Similar to Switzerland, it seems that it will take about a week to end, the situation is still unpredictable.

・ Korea, Iran

The number of infections reached its peak, but the situation after that was severe.

·Korea

removed_Korea, South_gamma_R_5.png (1) Red plot in the above figure; It looks like after the peak number of infections, but it is declining slowly and it seems to be quite long. (2) Green plot in the above figure; The number of cures is becoming saturated, and it is difficult to achieve 100% cure. (3) Black plot I / (R + D) in the above figure; I thought that it would decrease sharply with a convex downward when it became 1 or less, but it decreased slowly. In other words, it does not heal easily. removed_Korea, South_gammaR_5.png ④ The above figure means that $ \ gamma (R-1) $ never becomes 0 and the infection has occurred before. After all, it may not be possible to end unless the world ends.

·Iran

removed_Iran_gamma_R_5.png (1) Red plot in the above figure; the number of infections exceeded the peak (2) Green plot in the above figure; crossed the peak number of infections as in Korea ③ Black plot I / (R + D) in the above figure; It will be less than 1 about 4 days ago and will finally end. removed_Iran_gammaR_5.png ④ The above figure shows that $ \ gamma (R-1) $ is not less than 0, and the situation is still unpredictable.

・ Wuhan, Beijing, Hong Kong, Taiwan

China is said to be over, but what about the reality?

・ Wuhan

removed_Hubei_gamma_R_5.png (1) Red plot in the above figure; a considerable number of people have been discharged, but hundreds of people still remain as extant infected persons. (2) Green plot in the above figure; It can be said that it is almost horizontal and saturated as a whole. ③ Black plot I / (R + D) in the above figure; decreased to about $ 5x10 ^ {-3} $ ④ Blue plot in the figure below; It means that the infection stopped when the effective reproduction number = 1. exterpolate_Hubei_gamma_R_5.png ⑤ The number of existing infections is likely to remain in January. removed_Hubei_gammaR_5.png ⑥ As you can imagine from the behavior of $ R $ above, I thought that $ \ gamma (R-1) $ would be negative, but it didn't happen, and I finally got 0 by pulling a great tail.

·Beijing

removed_Beijing_gamma_R_5.png (1) Red plot in the above figure; The number of infections peaked once, but it is the second peak in the world trend. It also started to decrease 10 days ago. (2) Green plot in the above figure; The infected person in the second wave healed and started to rise. (3) Black plot I / (R + D) in the above figure; hidden in the large number of the first wave, but the increase and decrease are similar to the infection number curve. ④ Blue plot in the figure below; The number of effective reproductions is coming here and is becoming 1. It's almost over removed_Beijing_gammaR_5.png ⑤ Same as ④, finally $ \ gamma (R-1) = 0 $

·Hong Kong

removed_Hong Kong_gamma_R_5.png (1) Red plot in the above figure; Hong Kong is the same trend as the world. Finally exceeded the peak number of infections (2) Green plot in the above figure; it increases linearly. Will soon cross the number of infections ③ Black plot I / (R + D) in the above figure; it is far from 1, but it started to descend. ④ Blue plot in the figure below; The number of effective reproductions is currently in second place and is on a downward trend, and is likely to reach one soon. removed_Hong Kong_gammaR_5.png

·India

The population is large, the number of effective reproductions is 10 or more, and it is in the expansion period, so it is necessary to pay close attention. removed_India_gamma_R_5.png ① Red plot in the above figure: The infection is likely to spread in the future (2) Green plot in the above figure; increasing linearly ③ Black plot I / (R + D) in the above figure; the number in the 10th place is a constant value. ④ Blue plot in the figure below; effective reproduction number = almost constant with a large numerical value of about 10. removed_India_gammaR_5.png ⑤ The error is large, but it seems to be almost constant. exterpolate_India_gamma_R_5.png ⑥ Although it is simply drawn by linear approximation, the measured value may have started to slump a little, but the momentum is likely to spread the infection as a whole.

Summary

・ I tried to arrange the situation of Japan, the world and each country by processing the same data. ・ Japan has the largest effective reproduction number of 15, which is a very dangerous situation. I want to reduce the contact rate between people as much as possible (80% or more) to suppress the spread of infection ・ The world is at the stage where the peak number of infections has begun to appear. ・ In Europe, the peak number of infections has begun to appear, and it seems that the end can be expected, but the situation is unpredictable. ・ In South Korea, etc., it takes time to end after the peak number of infections. ・ Wuhan and others seemed to end once, but it still takes time to end. ・ Beijing and Hong Kong are about to end the second wave with the peak number of infections ・ India is spreading infection and has a large population, so it may be difficult in the future.

・ Maybe not in the article, but I would like to continue to watch trends every day.

Bonus; Mr. Nishiura's story; Promotion of such a lifestyle

As I understood from Mr. Nishiura's explanation, the following two points are important. ** ① From the third equation, enhance the medical system, increase $ \ gamma $, and increase the healing speed (quarantine rate) ** ** ② From the second equation, if the contact with the infected person is made as small as possible, $ R-1 $ can be made small, and if $ R $ can be reduced to 1 or less, the infection can be stopped **

So, I will explain Mr. Nishiura's story as Uwan below. In the above SIR model, the number of existing infected persons has an exponential (rat-calculated) solution from the second equation. The murine calculation increases slowly as the number of children decreases. This coefficient, $ \ gamma (R-1) $, corresponds to the number of children, and if it is made small, especially 0 or less, it starts to decrease exponentially. In other words, $ R <1 $ should be realized. By the way, in Germany now it is $ R_0 \ fallingdotseq 2.5 $, and if you rewrite it as $ R = R_0 (1-p) $,

R_0(1-p) < 1

If possible, $ R-1 <0 $ can be realized. Substituting $ R_0 $ above

p=1-1/R_0=0.6

Although it is the above in the calculation, there are some infections beyond this calculation, so it is necessary to reduce it by about 80%. Below is a more decent explanation. 【reference】 ・ [The reason why Professor Hiroshi Nishiura, who is "80% uncle", sticks to this number to prevent the expansion of corona](https://www.buzzfeed.com/jp/naokoiwanaga/covid-19- nishiura)

However, as mentioned above, Germany is one of the best countries in the world, and in Japan it is currently increasing to about $ R \ fallingdotseq 15 $. If this is $ R_0 = 15 $, then a reduction of 93% or more is required. This is related to the number of infections that are directly related to the infection, as can be seen from the formula. So if the infected person is quarantined, this can be 100%. However, this is difficult for infectious diseases that take a long time to develop (tests have some effect but have limitations). In addition, it has been reported that an asymptomatic infected person is infected this time. Therefore, the goal is to have zero contact between all potential infected persons. Even if you say 0 contact, there is something like a contact radius that satisfies the conditions for infection. It is said to be 2m this time. In the simulation below, the infection radius is set and the infection probability when entering the radius is set to 30%, and various calculations are made, so please refer to the image. ・ [Introduction to Simulation] I tried playing by simulating corona infection ♬

So, from the above evaluation calculation, online consultation, online treatment, online conference and online drinking party, virtual 〇〇, and even when you need to meet people, sufficient contact space (at least 2 m or more) and ventilation (at least 2 m interval) and ventilation ( 100% infected people if you try to wash your hands and face to prevent infection by delaying infection (reducing the density of microdroplets and aerosols), using masks (preventing the spread of your own droplets and temporarily protecting the droplets of others) I think it is possible to cut off the contact.

・ Do not go out
・ Do not gather
·mask
・ Hand wash

It can be said that this practice is one of the most important acts in future life.

Recommended Posts

[SIR model analysis] Peak out of infection numbers in Japan and around the world ♬
[SIR model analysis] Peak out of infection numbers in Japan and around the world ♬ Part 2
[SIR model analysis] Determination of γ * (R-1) and peak out of infection number ♬ World edition
[SIR model analysis] Peak out of infections in various parts of Japan ♬
Implement the mathematical model "SIR model" of infectious diseases in OpenModelica (reflecting mortality rate and reinfection rate)
Open an Excel file in Python and color the map of Japan
Display the status of COVID 19 infection in Japan with Splunk (GitHub version)
Implement the mathematical model "SIR model" of infectious diseases in OpenModelica (see the effect of the vaccine)
[SIR model analysis] Transform the formula to determine γ and the effective reproduction number R ♬
I used Python to find out about the role choices of the 51 "Yachts" in the world.
Specify the lighting Model of SCN Material in Pythonista
The simplest Python memo in Japan (classes and objects)
The story of building the fastest Linux environment in the world
Count the number of parameters in the deep learning model
I checked out the versions of Blender and Python
I tried to predict the infection of new pneumonia using the SIR model: ☓ Wuhan edition ○ Hubei edition
Implement the mathematical model "SIR model" of infectious diseases with OpenModelica (example of repeating regulation and deregulation)