@@ -42,49 +42,30 @@ def __init__(self, p: Parameters):
42
42
43
43
self .keys = ("susceptible" , "infected" , "recovered" )
44
44
45
+ # An estimate of the number of infected people on the day that
46
+ # the first hospitalized case is seen
47
+ #
45
48
# Note: this should not be an integer.
46
- # We're appoximating infected from what we do know.
47
- # TODO market_share > 0, hosp_rate > 0
48
49
infected = (
49
50
1.0 / p .market_share / p .hospitalized .rate
50
51
)
51
52
52
53
susceptible = p .population - infected
53
54
54
- intrinsic_growth_rate = get_growth_rate (p .doubling_time )
55
-
56
55
gamma = 1.0 / p .infectious_days
57
-
58
- # Contact rate, beta
59
- beta = (
60
- (intrinsic_growth_rate + gamma )
61
- / susceptible
62
- * (1.0 - p .relative_contact_rate )
63
- ) # {rate based on doubling time} / {initial susceptible}
64
-
65
- # r_t is r_0 after distancing
66
- r_t = beta / gamma * susceptible
67
-
68
- # Simplify equation to avoid division by zero:
69
- # self.r_naught = r_t / (1.0 - relative_contact_rate)
70
- r_naught = (intrinsic_growth_rate + gamma ) / gamma
56
+ self .gamma = gamma
71
57
72
58
self .susceptible = susceptible
73
59
self .infected = infected
74
60
self .recovered = p .recovered
75
61
76
- self .beta = beta
77
- self .gamma = gamma
78
- self .beta_t = get_beta (intrinsic_growth_rate , self .gamma , self .susceptible , p .relative_contact_rate )
79
- self .intrinsic_growth_rate = intrinsic_growth_rate
80
-
81
62
if p .date_first_hospitalized is None and p .doubling_time is not None :
63
+ # Back-projecting to when the first hospitalized case would have been admitted
82
64
logger .info ('Using doubling_time: %s' , p .doubling_time )
83
- self .i_day = 0
84
- self .beta = (
85
- (intrinsic_growth_rate + gamma )
86
- / susceptible
87
- )
65
+
66
+ intrinsic_growth_rate = get_growth_rate (p .doubling_time )
67
+
68
+ self .beta = get_beta (intrinsic_growth_rate , gamma , self .susceptible , 0.0 )
88
69
89
70
self .i_day = 0 # seed to the full length
90
71
self .beta_t = self .beta
@@ -94,8 +75,6 @@ def __init__(self, p: Parameters):
94
75
self .beta_t = get_beta (intrinsic_growth_rate , self .gamma , self .susceptible , p .relative_contact_rate )
95
76
self .run_projection (p )
96
77
97
- self .r_t = self .beta_t / gamma * susceptible
98
- self .r_naught = self .beta / gamma * susceptible
99
78
logger .info ('Set i_day = %s' , i_day )
100
79
p .date_first_hospitalized = p .current_date - timedelta (days = i_day )
101
80
logger .info (
@@ -105,6 +84,7 @@ def __init__(self, p: Parameters):
105
84
self .i_day )
106
85
107
86
elif p .date_first_hospitalized is not None and p .doubling_time is None :
87
+ # Fitting spread parameter to observed hospital census (dates of 1 patient and today)
108
88
self .i_day = (p .current_date - p .date_first_hospitalized ).days
109
89
logger .info (
110
90
'Using date_first_hospitalized: %s; current_date: %s; i_day: %s' ,
@@ -131,7 +111,6 @@ def __init__(self, p: Parameters):
131
111
self .beta_t = get_beta (intrinsic_growth_rate , self .gamma , self .susceptible , p .relative_contact_rate )
132
112
self .run_projection (p )
133
113
134
- self .intrinsic_growth_rate = intrinsic_growth_rate
135
114
self .population = p .population
136
115
else :
137
116
logger .info (
@@ -148,6 +127,9 @@ def __init__(self, p: Parameters):
148
127
self .susceptible = self .raw_df ['susceptible' ].values [self .i_day ]
149
128
self .recovered = self .raw_df ['recovered' ].values [self .i_day ]
150
129
130
+ self .intrinsic_growth_rate = intrinsic_growth_rate
131
+
132
+ # r_t is r_0 after distancing
151
133
self .r_t = self .beta_t / gamma * susceptible
152
134
self .r_naught = self .beta / gamma * susceptible
153
135
0 commit comments