Skip to content

Commit cbac4df

Browse files
authored
Merge pull request #25 from pennsignals/r0_explainer
#23 explained R0 in terms of beta and gamma
2 parents b3321b4 + 3128fcf commit cbac4df

File tree

2 files changed

+50
-23
lines changed

2 files changed

+50
-23
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

app.py

Lines changed: 50 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,21 @@
5858
total_infections = current_hosp / Penn_market_share / hosp_rate
5959
detection_prob = initial_infections / total_infections
6060

61+
S, I, R = S, initial_infections / detection_prob, 0
62+
63+
intrinsic_growth_rate = 2 ** (1 / doubling_time) - 1
64+
65+
recovery_days = 14.0
66+
# mean recovery rate, gamma, (in 1/days).
67+
gamma = 1 / recovery_days
68+
69+
# Contact rate, beta
70+
beta = (
71+
intrinsic_growth_rate + gamma
72+
) / S # {rate based on doubling time} / {initial S}
73+
74+
r_naught = beta / gamma * S
75+
6176
st.title("COVID-19 Hospital Impact Model for Epidemics")
6277
st.markdown(
6378
"""*This tool was developed by the [Predictive Healthcare team](http://predictivehealthcare.pennmedicine.org/) at
@@ -102,18 +117,48 @@
102117
103118
104119
### Parameters
105-
First, we need to express the two parameters $\\beta$ and $\\gamma$ in terms of quantities we can estimate.
106120
107-
- The $\\gamma$ parameter represents 1 over the mean recovery time in days. Since the CDC is recommending 14 days of self-quarantine, we'll use $\\gamma = 1/14$.
108-
- Next, the AHA says to expect a doubling time $T_d$ of 7-10 days. That means an early-phase rate of growth can be computed by using the doubling time formula:
109-
"""
121+
The model's parameters, $\\beta$ and $\\gamma$, determine the virulence of the epidemic.
122+
123+
$$\\beta$$ can be interpreted as the _effective contact rate_:
124+
""")
125+
st.latex("\\beta = \\tau \\times c")
126+
127+
st.markdown(
128+
"""which is the transmissibility ($\\tau$) multiplied by the average number of people exposed ($$c$$). The transmissibility is the basic virulence of the pathogen. The number of people exposed $c$ is the parameter that can be changed through social distancing.
129+
130+
131+
$\\gamma$ is the inverse of the mean recovery time, in days. I.e.: if $\\gamma = 1/{recovery_days}$, then the average infection will clear in {recovery_days} days.
132+
133+
An important descriptive parameter is the _basic reproduction number_, or $R_0$. This represents the average number of people who will be infected by any given infected person. When $R_0$ is greater than 1, it means that a disease will grow. Higher $R_0$'s imply more rapid growth. It is defined as """.format(recovery_days=int(recovery_days) , c='c'))
134+
st.latex("R_0 = \\beta /\\gamma")
135+
136+
st.markdown("""
137+
138+
R0 gets bigger when
139+
140+
- there are more contacts between people
141+
- when the pathogen is more virulent
142+
- when people have the pathogen for longer periods of time
143+
144+
A doubling time of {doubling_time} days and a recovery time of {recovery_days} days -- imply an $R_0$ of {r_naught:.2f}.
145+
146+
To use the model, we need to express the two parameters $\\beta$ and $\\gamma$ in terms of quantities we can estimate.
147+
148+
- $\\gamma$: the CDC is recommending 14 days of self-quarantine, we'll use $\\gamma = 1/{recovery_days}$.
149+
- To estimate $$\\beta$$ directly, we'd need to know transmissibility and social contact rates. since we don't know these things, we can extract it from known _doubling times_. The AHA says to expect a doubling time $T_d$ of 7-10 days. That means an early-phase rate of growth can be computed by using the doubling time formula:
150+
""".format(doubling_time=doubling_time,
151+
recovery_days=recovery_days,
152+
r_naught=r_naught
153+
)
110154
)
111155
st.latex("g = 2^{1/T_d} - 1")
112156

113157
st.markdown(
114158
"""
115159
- Since the rate of new infections in the SIR model is $g = \\beta S - \\gamma$, and we've already computed $\\gamma$, $\\beta$ becomes a function of the initial population size of susceptible individuals.
116-
$$\\beta = (g + \\gamma)/s$$
160+
$$\\beta = (g + \\gamma)$$.
161+
117162
118163
### Initial Conditions
119164
@@ -165,22 +210,6 @@ def sim_sir(S, I, R, beta, gamma, n_days, beta_decay=None):
165210
return s, i, r
166211

167212

168-
## RUN THE MODEL
169-
170-
S, I, R = S, initial_infections / detection_prob, 0
171-
172-
intrinsic_growth_rate = 2 ** (1 / doubling_time) - 1
173-
174-
recovery_days = 14.0
175-
# mean recovery rate, gamma, (in 1/days).
176-
gamma = 1 / recovery_days
177-
178-
# Contact rate, beta
179-
beta = (
180-
intrinsic_growth_rate + gamma
181-
) / S # {rate based on doubling time} / {initial S}
182-
183-
184213
n_days = st.slider("Number of days to project", 30, 200, 60, 1, "%i")
185214

186215
beta_decay = 0.0

0 commit comments

Comments
 (0)