-
Notifications
You must be signed in to change notification settings - Fork 0
/
Baltimore_20200514.R
206 lines (170 loc) · 8.96 KB
/
Baltimore_20200514.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
## Setup ####
require(socialmixr)
require(magrittr)
require(stringr)
require(reshape2)
require(dplyr)
require(ggplot2)
require(truncnorm)
source("asyptomatic_age.R")
age.limits <- c(0,5,10,15,20,25,35,45,55,60,65,75,85,90)
prop_symptomatic <- c(0.141, 0.106, 0.074, 0.184, 0.293, 0.387, 0.438,
0.535, 0.693, 0.816, 0.765, 0.749, 0.535, 0.535)
delta.t <- 1/1
time <- seq(1,300,by = delta.t)
t_March13 <- as.numeric(as.Date("2020-03-13") - as.Date("2020-03-01"))
t_March30 <- as.numeric(as.Date("2020-03-30") - as.Date("2020-03-01"))
t_April19 <- as.numeric(as.Date("2020-04-19") - as.Date("2020-03-01"))
t_April26 <- as.numeric(as.Date("2020-04-26") - as.Date("2020-03-01"))
t_May15 <- as.numeric(as.Date("2020-05-15") - as.Date("2020-03-01"))
t_May30 <- as.numeric(as.Date("2020-05-30") - as.Date("2020-03-01"))
t_June15 <- as.numeric(as.Date("2020-06-15") - as.Date("2020-03-01"))
t_July1 <- as.numeric(as.Date("2020-07-01") - as.Date("2020-03-01"))
t_July31 <- as.numeric(as.Date("2020-07-31") - as.Date("2020-03-01"))
t_Aug1<- as.numeric(as.Date("2020-08-01") - as.Date("2020-03-01"))
t_Aug15<- as.numeric(as.Date("2020-08-15") - as.Date("2020-03-01"))
t_Oct1<- as.numeric(as.Date("2020-10-01") - as.Date("2020-03-01"))
Rt_stay_at_home_phase3 <- c(0.8, 1.08) #Baltimore average April 27 - May 4
Rt_stay_at_home_phase2 <- c(1.016, 1.107) #Baltimore average April 20 - April 26
Rt_stay_at_home_phase1 <- c(1.016, 1.288) #Baltimore average March 30 - April 19
Rt_safer_at_home <- c(1.148, 1.198) # georgia average May 1 - 10
Rt_mod_sd <- c(1.337, 1.990) # Baltimore average March 20 - 29
Rt_unc <- c(2, 3)
nsim <- 1000
start_index <- seq(1, nsim*length(time)+1, by = length(time))
all_prelim_info <- setup_seir_model(stoch = TRUE,
R0 = 2,
c_scale_vec = 1,
prop_symptomatic = prop_symptomatic,
sd.dw = 0.1,
healthcare_n = 26890)
Ncomp = all_prelim_info$Ncomp
ICs = all_prelim_info$ICs
params = list(C = all_prelim_info$C,
W = all_prelim_info$W,
beta0 = all_prelim_info$beta0,
beta1 = all_prelim_info$beta1,
phase = all_prelim_info$phase,
mu = all_prelim_info$mu,
v = all_prelim_info$v,
N=all_prelim_info$N,
gamma=all_prelim_info$gamma,
sigma = all_prelim_info$sigma,
prop_symptomatic=all_prelim_info$prop_symptomatic,
sd.dw = all_prelim_info$sd.dw)
cnames.allsim <- c('run_index', 'time',
paste0("S", 1:Ncomp),
paste0("E", 1:Ncomp),
paste0("A", 1:Ncomp),
paste0("I", 1:Ncomp),
paste0("R", 1:Ncomp),
paste0("incid_A", 1:Ncomp),
paste0("incid_I", 1:Ncomp),
"R0",
"Reff")
## ---- Scenario 1 ---- ####
# stay at home March 29 - June 15
# safer at home June 16 - Aug 15
# moderate social distancing Aug 16 - Dec 31
all_sim <- matrix(NA,1,(Ncomp*7)+4)
colnames(all_sim) <- cnames.allsim
for(n in 1:nsim){
R0vec <- rep(runif(1, min = 2, max = 3), length(time))
R0vec[t_March13:t_March30] <- runif(1, min = Rt_mod_sd[1], max = Rt_mod_sd[2])
R0vec[(t_March30+1):t_April19] <- runif(1, min = Rt_stay_at_home_phase1[1], max = Rt_stay_at_home_phase1[2])
R0vec[(t_April19+1):t_April26] <- runif(1, min = Rt_stay_at_home_phase2[1], max = Rt_stay_at_home_phase2[2])
R0vec[(t_April26+1):t_June15] <- runif(1, min = Rt_stay_at_home_phase3[1], max = Rt_stay_at_home_phase3[2])
R0vec[(t_June15+1):t_Aug15] <- runif(1, min = Rt_safer_at_home[1], max = Rt_safer_at_home[2])
R0vec[(t_Aug15+1):length(time)] <- runif(1, min = Rt_mod_sd[1], max = Rt_mod_sd[2])
c_scale_mat <- matrix(1, nrow = length(time), ncol=Ncomp)
tmp <- sair_step_variableR0(stoch = TRUE, stoch.init = TRUE,
R0vec = R0vec, Ncomp = Ncomp,
ICs = ICs, params = params,
time = time, delta.t = delta.t,
c_scale_mat = c_scale_mat)
run_index = rep(n, nrow(tmp))
tmp <- cbind(run_index, tmp)
all_sim <- rbind(all_sim, tmp)
}
all_sim <- all_sim[-1,]
write.csv(all_sim, file="output_20200514/scenario1.csv")
## ---- Scenario 2 --- ####
# stay at home March 29 - May 30
# safer at home June 1 - July 31
# moderate social distancing Aug 1 - Dec 31
all_sim <- matrix(NA,1,(Ncomp*7)+4)
colnames(all_sim) <- cnames.allsim
for(n in 1:nsim){
R0vec <- rep(runif(1, min = 2, max = 3), length(time))
R0vec[t_March13:t_March30] <- runif(1, min = Rt_mod_sd[1], max = Rt_mod_sd[2])
R0vec[(t_March30+1):t_April19] <- runif(1, min = Rt_stay_at_home_phase1[1], max = Rt_stay_at_home_phase1[2])
R0vec[(t_April19+1):t_April26] <- runif(1, min = Rt_stay_at_home_phase2[1], max = Rt_stay_at_home_phase2[2])
R0vec[(t_April26+1):t_May30] <- runif(1, min = Rt_stay_at_home_phase3[1], max = Rt_stay_at_home_phase3[2])
R0vec[(t_May30+1):t_July31] <- runif(1, min = Rt_safer_at_home[1], max = Rt_safer_at_home[2])
R0vec[(t_Aug1+1):length(time)] <- runif(1, min = Rt_mod_sd[1], max = Rt_mod_sd[2])
c_scale_mat <- matrix(1, nrow = length(time), ncol=Ncomp)
tmp <- sair_step_variableR0(stoch = TRUE, stoch.init = TRUE,
R0vec = R0vec, Ncomp = Ncomp,
ICs = ICs, params = params,
time = time, delta.t = delta.t,
c_scale_mat = c_scale_mat)
run_index = rep(n, nrow(tmp))
tmp <- cbind(run_index, tmp)
all_sim <- rbind(all_sim, tmp)
}
all_sim <- all_sim[-1,]
write.csv(all_sim, file="output_20200514/scenario2.csv")
## ---- Scenario 3 ---- ####
# stay at home March 29 - May 30
# safer at home June 1 - June 30
# moderate social distancing July 1 - Sept 30
# uncontrolled Oct 1 - Dec 31
all_sim <- matrix(NA,1,(Ncomp*7)+4)
colnames(all_sim) <- cnames.allsim
for(n in 1:nsim){
R0vec <- rep(runif(1, min = 2, max = 3), length(time))
R0vec[t_March13:t_March30] <- runif(1, min = Rt_mod_sd[1], max = Rt_mod_sd[2])
R0vec[(t_March30+1):t_April19] <- runif(1, min = Rt_stay_at_home_phase1[1], max = Rt_stay_at_home_phase1[2])
R0vec[(t_April19+1):t_April26] <- runif(1, min = Rt_stay_at_home_phase2[1], max = Rt_stay_at_home_phase2[2])
R0vec[(t_April26+1):t_May30] <- runif(1, min = Rt_stay_at_home_phase3[1], max = Rt_stay_at_home_phase3[2])
R0vec[(t_May30+1):(t_July1-1)] <- runif(1, min = Rt_safer_at_home[1], max = Rt_safer_at_home[2])
R0vec[t_July1:(t_Oct1-1)] <- runif(1, min = Rt_mod_sd[1], max = Rt_mod_sd[2])
c_scale_mat <- matrix(1, nrow = length(time), ncol=Ncomp)
tmp <- sair_step_variableR0(stoch = TRUE, stoch.init = TRUE,
R0vec = R0vec, Ncomp = Ncomp,
ICs = ICs, params = params,
time = time, delta.t = delta.t,
c_scale_mat = c_scale_mat)
run_index = rep(n, nrow(tmp))
tmp <- cbind(run_index, tmp)
all_sim <- rbind(all_sim, tmp)
}
all_sim <- all_sim[-1,]
write.csv(all_sim, file="output_20200514/scenario3.csv")
## ---- Scenario 4 --- ####
# stay at home March 29 - May 15
# safer at home May 16 - June 15
# moderate social distancing June 16 - Aug 15
# uncontrolled Aug 16 - Dec 31
all_sim <- matrix(NA,1,(Ncomp*7)+4)
colnames(all_sim) <- cnames.allsim
for(n in 1:nsim){
R0vec <- rep(runif(1, min = 2, max = 3), length(time))
R0vec[t_March13:t_March30] <- runif(1, min = Rt_mod_sd[1], max = Rt_mod_sd[2])
R0vec[(t_March30+1):t_April19] <- runif(1, min = Rt_stay_at_home_phase1[1], max = Rt_stay_at_home_phase1[2])
R0vec[(t_April19+1):t_April26] <- runif(1, min = Rt_stay_at_home_phase2[1], max = Rt_stay_at_home_phase2[2])
R0vec[(t_April26+1):t_May15] <- runif(1, min = Rt_stay_at_home_phase3[1], max = Rt_stay_at_home_phase3[2])
R0vec[(t_May15+1):t_June15] <- runif(1, min = Rt_safer_at_home[1], max = Rt_safer_at_home[2])
R0vec[(t_June15+1):t_Aug15] <- runif(1, min = Rt_mod_sd[1], max = Rt_mod_sd[2])
c_scale_mat <- matrix(1, nrow = length(time), ncol=Ncomp)
tmp <- sair_step_variableR0(stoch = TRUE, stoch.init = TRUE,
R0vec = R0vec, Ncomp = Ncomp,
ICs = ICs, params = params,
time = time, delta.t = delta.t,
c_scale_mat = c_scale_mat)
run_index = rep(n, nrow(tmp))
tmp <- cbind(run_index, tmp)
all_sim <- rbind(all_sim, tmp)
}
all_sim <- all_sim[-1,]
write.csv(all_sim, file="output_20200514/scenario4.csv")