-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBaltimore_20200408.R
163 lines (130 loc) · 5.85 KB
/
Baltimore_20200408.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
## 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_March19 <- as.numeric(as.Date("2020-03-19") - as.Date("2020-03-01"))
t_May14 <- as.numeric(as.Date("2020-05-14") - as.Date("2020-03-01"))
nsim <- 500
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)
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")
## Scenario 1A: R0 2 - 3, uncontrolled ####
all_sim <- matrix(NA,1,(Ncomp*7)+3)
colnames(all_sim) <- cnames.allsim
for(n in 1:nsim){
R0vec <- runif(length(time), min = 2, max = 3)
tmp <- sair_step_variableR0(stoch = TRUE, stoch.init = TRUE,
R0vec, Ncomp, ICs, params, time, delta.t)
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_20200408/scenario1A_lowR0_uncontrolled.csv")
## Scenario 1B: R0 2 - 3, 30-40% reduction March 19 - May 14 ####
all_sim <- matrix(NA,1,(Ncomp*7)+3)
colnames(all_sim) <- cnames.allsim
for(n in 1:nsim){
R0vec <- runif(length(time), min = 2, max = 3)
R0vec[t_March19:t_May14] <- runif(length(t_March19:t_May14), 2*(1-0.4), 3*(1-0.3))
tmp <- sair_step_variableR0(stoch = TRUE, stoch.init = TRUE,
R0vec, Ncomp, ICs, params, time, delta.t)
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_20200408/scenario1B_lowR0_MildDistancing.csv")
## Scenario 1C: R0 2 - 3, 45-65% reduction March 19 - May 14, 48-76% May 15 - Dec 26 ####
all_sim <- matrix(NA,1,(Ncomp*7)+3)
colnames(all_sim) <- cnames.allsim
for(n in 1:nsim){
R0vec <- runif(length(time), min = 2, max = 3)
R0vec[t_March19:t_May14] <- runif(length(t_March19:t_May14), 2*(1-0.65), 3*(1-0.45))
R0vec[(t_May14+1):length(time)] <- runif(length((t_May14+1):length(time)), 2*(1-0.76), 3*(1-0.48))
tmp <- sair_step_variableR0(stoch = TRUE, stoch.init = TRUE,
R0vec, Ncomp, ICs, params, time, delta.t)
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_20200408/scenario1C_lowR0_ModDistancing.csv")
## Scenario 2A: R0 3.5-4, uncontrolled ####
all_sim <- matrix(NA,1,(Ncomp*7)+3)
colnames(all_sim) <- cnames.allsim
for(n in 1:nsim){
R0vec <- runif(length(time), min = 3.5, max = 4)
tmp <- sair_step_variableR0(stoch = TRUE, stoch.init = TRUE,
R0vec, Ncomp, ICs, params, time, delta.t)
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_20200408/scenario2A_highR0_uncontrolled.csv")
## Scenario 2B: R0 3.5-4, 30-40% reduction March 19 - May 14 ####
all_sim <- matrix(NA,1,(Ncomp*7)+3)
colnames(all_sim) <- cnames.allsim
for(n in 1:nsim){
R0vec <- runif(length(time), min = 3.5, max = 4)
R0vec[t_March19:t_May14] <- runif(length(t_March19:t_May14), 3.5*(1-0.4), 4*(1-0.3))
tmp <- sair_step_variableR0(stoch = TRUE, stoch.init = TRUE,
R0vec, Ncomp, ICs, params, time, delta.t)
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_20200408/scenario2B_highR0_MildDistancing.csv")
## Scenario 2C: R0 3.5 - 4, 45-65% reduction March 19 - May 14, 48-76% May 15 - Dec 26 ####
all_sim <- matrix(NA,1,(Ncomp*7)+3)
colnames(all_sim) <- cnames.allsim
for(n in 1:nsim){
R0vec <- runif(length(time), min = 3.5, max = 4)
R0vec[t_March19:t_May14] <- runif(length(t_March19:t_May14), 3.5*(1-0.65), 4*(1-0.45))
R0vec[(t_May14+1):length(time)] <- runif(length((t_May14+1):length(time)), 3.5*(1-0.76), 4*(1-0.48))
tmp <- sair_step_variableR0(stoch = TRUE, stoch.init = TRUE,
R0vec, Ncomp, ICs, params, time, delta.t)
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_20200408/scenario2C_highR0_ModDistancing.csv")