Introduction
We are creating a Python package CovsirPhy that allows you to easily download and analyze COVID-19 data (such as the number of PCR positives). We plan to publish articles on analysis examples using packages and knowledge gained in creating them (Python, GitHub, Sphinx, ...).
The English version of the document is Covsir Phy: COVID-19 analysis with phase-dependent SIRs, Kaggle: COVID-19 data with SIR model.
** This time, I will introduce the basic model SIR model. ** No actual data is available. English version: Usage (details: theoretical datasets)
CovsirPhy can be installed by the following method! Please use Python 3.7 or above, or Google Colaboratory.
--Stable version: pip install covsirphy --upgrade
--Development version: pip install" git + https://github.com/lisphilar/covid19-sir.git#egg=covsirphy "
#For data display
from pprint import pprint
# CovsirPhy
import covsirphy as cs
cs.__version__
# '2.8.0'
Execution environment | |
---|---|
OS | Windows Subsystem for Linux |
Python | version 3.8.5 |
When Susceptible contacts Infected, the probability of getting infected is defined as Effective contact rate $ \ beta $ [1 / min]. $ \ Gamma $ [1 / min] is the probability of moving from Infected to Recovered [^ 1] [^ 2].
\begin{align*}
\mathrm{S} \overset{\beta I}{\longrightarrow} \mathrm{I} \overset{\gamma}{\longrightarrow} \mathrm{R} \\
\end{align*}
As total population $ N = S + I + R $
\begin{align*}
& \frac{\mathrm{d}S}{\mathrm{d}T}= - N^{-1}\beta S I \\
& \frac{\mathrm{d}I}{\mathrm{d}T}= N^{-1}\beta S I - \gamma I \\
& \frac{\mathrm{d}R}{\mathrm{d}T}= \gamma I \\
\end{align*}
You can handle it as it is, but it will be dimensionless because the parameter range is limited to $ (0, 1) $. Although not mentioned in this article, it is effective when calculating parameters from actual data.
$ (S, I, R) = N \ times (x, y, z) $, $ (T, \ beta, \ gamma) = (\ tau t, \ tau ^ {-1} \ rho, \ tau ^ {-1} \ sigma) $, $ 1 \ leq \ tau \ leq 1440 $ [min]
\begin{align*}
& \frac{\mathrm{d}x}{\mathrm{d}t}= - \rho x y \\
& \frac{\mathrm{d}y}{\mathrm{d}t}= \rho x y - \sigma y \\
& \frac{\mathrm{d}z}{\mathrm{d}t}= \sigma y \\
\end{align*}
At this time,
\begin{align*}
& 0 \leq (x, y, z, \rho, \sigma) \leq 1 \\
\end{align*}
(Basic / Effective) Reproduction number The Reproduction number is defined as follows [^ 3].
\begin{align*}
R_t = \rho \sigma^{-1} = \beta \gamma^{-1}
\end{align*}
Set the parameter $ (\ rho, \ sigma) = (0.2, 0.075) $ and the initial value and graph.
# Parameters
pprint(cs.SIR.EXAMPLE, compact=True)
# {'param_dict': {'rho': 0.2, 'sigma': 0.075},
# 'population': 1000000,
# 'step_n': 180,
# 'y0_dict': {'Fatal or Recovered': 0, 'Infected': 1000, 'Susceptible': 999000}}
(Basic / Effective) Number of reproductions:
# Reproduction number
eg_dict = cs.SIR.EXAMPLE.copy()
model_ins = cs.SIR(
population=eg_dict["population"],
**eg_dict["param_dict"]
)
model_ins.calc_r0()
# 2.67
graph display:
# Set tau value and start date of records
example_data = cs.ExampleData(tau=1440, start_date="01Jan2020")
# Add records with SIR model
model = cs.SIR
area = {"country": "Full", "province": model.NAME}
example_data.add(model, **area)
# Change parameter values if needed
# example_data.add(model, param_dict={"rho": 0.4, "sigma": 0.0150}, **area)
# Records with model variables
df = example_data.specialized(model, **area)
# Plotting
cs.line_plot(
df.set_index("Date"),
title=f"Example data of {model.NAME} model",
y_integer=True,
filename="sir.png "
)
Introducing the model SIR-F model, which is a modified version of the basic model SIR model for COVID-19.
Recommended Posts