forked from waternk/PM_COVID
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Analyses.R
393 lines (360 loc) · 27.8 KB
/
Analyses.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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
library("dplyr")
library("MASS")
library("lme4")
library("glmmTMB")
library("gamm4")
# Main
mode.nb.random.off.main = glmer.nb(Deaths ~ mean_pm25 + factor(q_popdensity)
+ scale(poverty) + scale(log(medianhousevalue))
+ scale(log(medhouseholdincome)) + scale(pct_owner_occ)
+ scale(education) + scale(pct_blk) + scale(hispanic)
+ scale(older_pecent) + scale(prime_pecent) + scale(mid_pecent)
+ scale(date_since_social) + scale(date_since)
+ scale(beds/population)
+ scale(obese) + scale(smoke)
+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
+ (1|state)
+ offset(log(population)), data = aggregate_pm_census_cdc_test_beds)
summary(mode.nb.random.off.main)
exp(summary(mode.nb.random.off.main)[10]$coefficients[2,1])
exp(summary(mode.nb.random.off.main)[10]$coefficients[2,1] - 1.96*summary(mode.nb.random.off.main)[10]$coefficients[2,2])
exp(summary(mode.nb.random.off.main)[10]$coefficients[2,1] + 1.96*summary(mode.nb.random.off.main)[10]$coefficients[2,2])
summary(mode.nb.random.off.main)[10]$coefficients[2,4]
# - beds
mode.nb.random.off.beds = glmer.nb(Deaths ~ mean_pm25 + factor(q_popdensity)
+ scale(poverty) + scale(log(medianhousevalue))
+ scale(log(medhouseholdincome)) + scale(pct_owner_occ)
+ scale(education) + scale(pct_blk) + scale(hispanic)
+ scale(older_pecent) + scale(prime_pecent) + scale(mid_pecent)
+ scale(date_since_social) + scale(date_since)
#+ scale(beds/population)
+ scale(obese) + scale(smoke)
+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
+ (1|state)
+ offset(log(population)), data = aggregate_pm_census_cdc_test_beds)
summary(mode.nb.random.off.beds)
exp(summary(mode.nb.random.off.beds)[10]$coefficients[2,1])
exp(summary(mode.nb.random.off.beds)[10]$coefficients[2,1] - 1.96*summary(mode.nb.random.off.beds)[10]$coefficients[2,2])
exp(summary(mode.nb.random.off.beds)[10]$coefficients[2,1] + 1.96*summary(mode.nb.random.off.beds)[10]$coefficients[2,2])
summary(mode.nb.random.off.beds)[10]$coefficients[2,4]
# - smoking + bmi
mode.nb.random.off.brfss = glmer.nb(Deaths ~ mean_pm25 + factor(q_popdensity)
+ scale(poverty) + scale(log(medianhousevalue))
+ scale(log(medhouseholdincome)) + scale(pct_owner_occ)
+ scale(education) + scale(pct_blk) + scale(hispanic)
+ scale(older_pecent) + scale(prime_pecent) + scale(mid_pecent)
+ scale(date_since_social) + scale(date_since)
+ scale(beds/population)
#+ scale(obese) + scale(smoke)
+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
+ (1|state)
+ offset(log(population)), data = aggregate_pm_census_cdc_test_beds)
summary(mode.nb.random.off.brfss)
exp(summary(mode.nb.random.off.brfss)[10]$coefficients[2,1])
exp(summary(mode.nb.random.off.brfss)[10]$coefficients[2,1] - 1.96*summary(mode.nb.random.off.brfss)[10]$coefficients[2,2])
exp(summary(mode.nb.random.off.brfss)[10]$coefficients[2,1] + 1.96*summary(mode.nb.random.off.brfss)[10]$coefficients[2,2])
summary(mode.nb.random.off.brfss)[10]$coefficients[2,4]
# - temp + humidity
mode.nb.random.off.weather = glmer.nb(Deaths ~ mean_pm25 + factor(q_popdensity)
+ scale(poverty) + scale(log(medianhousevalue))
+ scale(log(medhouseholdincome)) + scale(pct_owner_occ)
+ scale(education) + scale(pct_blk) + scale(hispanic)
+ scale(older_pecent) + scale(prime_pecent) + scale(mid_pecent)
+ scale(date_since_social) + scale(date_since)
+ scale(beds/population)
+ scale(obese) + scale(smoke)
#+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
+ (1|state)
+ offset(log(population)), data = aggregate_pm_census_cdc_test_beds)
summary(mode.nb.random.off.weather)
exp(summary(mode.nb.random.off.weather)[10]$coefficients[2,1])
exp(summary(mode.nb.random.off.weather)[10]$coefficients[2,1] - 1.96*summary(mode.nb.random.off.weather)[10]$coefficients[2,2])
exp(summary(mode.nb.random.off.weather)[10]$coefficients[2,1] + 1.96*summary(mode.nb.random.off.weather)[10]$coefficients[2,2])
summary(mode.nb.random.off.weather)[10]$coefficients[2,4]
# - outbreak
mode.nb.random.off.outbreak = glmer.nb(Deaths ~ mean_pm25 + factor(q_popdensity)
+ scale(poverty) + scale(log(medianhousevalue))
+ scale(log(medhouseholdincome)) + scale(pct_owner_occ)
+ scale(education) + scale(pct_blk) + scale(hispanic)
+ scale(older_pecent) + scale(prime_pecent) + scale(mid_pecent)
+ scale(date_since_social) #+ scale(date_since)
+ scale(beds/population)
+ scale(obese) + scale(smoke)
+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
+ (1|state)
+ offset(log(population)), data = aggregate_pm_census_cdc_test_beds)
summary(mode.nb.random.off.outbreak)
exp(summary(mode.nb.random.off.outbreak)[10]$coefficients[2,1])
exp(summary(mode.nb.random.off.outbreak)[10]$coefficients[2,1] - 1.96*summary(mode.nb.random.off.outbreak)[10]$coefficients[2,2])
exp(summary(mode.nb.random.off.outbreak)[10]$coefficients[2,1] + 1.96*summary(mode.nb.random.off.outbreak)[10]$coefficients[2,2])
summary(mode.nb.random.off.outbreak)[10]$coefficients[2,4]
# exclude NY Metro
mode.nb.random.off.nyc = glmer.nb(Deaths ~ mean_pm25 + factor(q_popdensity)
+ scale(poverty) + scale(log(medianhousevalue))
+ scale(log(medhouseholdincome)) + scale(pct_owner_occ)
+ scale(education) + scale(pct_blk) + scale(hispanic)
+ scale(older_pecent) + scale(prime_pecent) + scale(mid_pecent)
+ scale(date_since_social) + scale(date_since)
+ scale(beds/population)
+ scale(obese) + scale(smoke)
+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
+ (1|state)
+ offset(log(population)),data = subset(aggregate_pm_census_cdc_test_beds,!(fips %in% c("09001","42089","36111","09009","36059","36103","34013",
"34019","34027","34037","34039","42103","34023","34025","34029",
"34035", "34003", "34017", "34031","36005","36047","36061",
"36079","36081", "36085", "36087", "36119", "36027",
"36071", "09005", "34021"))))
summary(mode.nb.random.off.nyc)
exp(summary(mode.nb.random.off.nyc)[10]$coefficients[2,1])
exp(summary(mode.nb.random.off.nyc)[10]$coefficients[2,1] - 1.96*summary(mode.nb.random.off.nyc)[10]$coefficients[2,2])
exp(summary(mode.nb.random.off.nyc)[10]$coefficients[2,1] + 1.96*summary(mode.nb.random.off.nyc)[10]$coefficients[2,2])
summary(mode.nb.random.off.nyc)[10]$coefficients[2,4]
# exclude <10 confirmed
mode.nb.random.off.large = glmer.nb(Deaths ~ mean_pm25 + factor(q_popdensity)
+ scale(poverty) + scale(log(medianhousevalue))
+ scale(log(medhouseholdincome)) + scale(pct_owner_occ)
+ scale(education) + scale(pct_blk) + scale(hispanic)
+ scale(older_pecent) + scale(prime_pecent) + scale(mid_pecent)
+ scale(date_since_social) + scale(date_since)
+ scale(beds/population)
+ scale(obese) + scale(smoke)
+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
+ (1|state)
+ offset(log(population)), data = subset(aggregate_pm_census_cdc_test_beds,Confirmed >=10))
summary(mode.nb.random.off.large)
exp(summary(mode.nb.random.off.large)[10]$coefficients[2,1])
exp(summary(mode.nb.random.off.large)[10]$coefficients[2,1] - 1.96*summary(mode.nb.random.off.large)[10]$coefficients[2,2])
exp(summary(mode.nb.random.off.large)[10]$coefficients[2,1] + 1.96*summary(mode.nb.random.off.large)[10]$coefficients[2,2])
summary(mode.nb.random.off.large)[10]$coefficients[2,4]
# rural
mode.nb.random.off.rural = glmer.nb(Deaths ~ mean_pm25 + factor(q_popdensity)
+ scale(poverty) + scale(log(medianhousevalue))
+ scale(log(medhouseholdincome)) + scale(pct_owner_occ)
+ scale(education) + scale(pct_blk) + scale(hispanic)
+ scale(older_pecent) + scale(prime_pecent) + scale(mid_pecent)
+ scale(date_since_social) + scale(date_since)
+ scale(beds/population)
+ scale(obese) + scale(smoke)
+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
+ (1|state)
+ offset(log(population)), data = subset(aggregate_pm_census_cdc_test_beds,X2013.code>4))
summary(mode.nb.random.off.rural)
exp(summary(mode.nb.random.off.rural)[10]$coefficients[2,1])
exp(summary(mode.nb.random.off.rural)[10]$coefficients[2,1] - 1.96*summary(mode.nb.random.off.rural)[10]$coefficients[2,2])
exp(summary(mode.nb.random.off.rural)[10]$coefficients[2,1] + 1.96*summary(mode.nb.random.off.rural)[10]$coefficients[2,2])
summary(mode.nb.random.off.rural)[10]$coefficients[2,4]
#urban
mode.nb.random.off.urban = glmer.nb(Deaths ~ mean_pm25 + factor(q_popdensity)
+ scale(poverty) + scale(log(medianhousevalue))
+ scale(log(medhouseholdincome)) + scale(pct_owner_occ)
+ scale(education) + scale(pct_blk) + scale(hispanic)
+ scale(older_pecent) + scale(prime_pecent) + scale(mid_pecent)
+ scale(date_since_social) + scale(date_since)
+ scale(beds/population)
+ scale(obese) + scale(smoke)
+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
+ (1|state)
+ offset(log(population)), data = subset(aggregate_pm_census_cdc_test_beds,X2013.code<=4))
summary(mode.nb.random.off.urban)
exp(summary(mode.nb.random.off.urban)[10]$coefficients[2,1])
exp(summary(mode.nb.random.off.urban)[10]$coefficients[2,1] - 1.96*summary(mode.nb.random.off.urban)[10]$coefficients[2,2])
exp(summary(mode.nb.random.off.urban)[10]$coefficients[2,1] + 1.96*summary(mode.nb.random.off.urban)[10]$coefficients[2,2])
summary(mode.nb.random.off.urban)[10]$coefficients[2,4]
# main analysis with category PM
aggregate_pm_census_cdc_test_beds$q_pm = 1
quantile_pm = quantile(aggregate_pm_census_cdc_test_beds$mean_pm25,c(0.2,0.4,0.6,0.8))
aggregate_pm_census_cdc_test_beds$q_pm[aggregate_pm_census_cdc_test_beds$mean_pm25<=quantile_pm[1]] = 1
aggregate_pm_census_cdc_test_beds$q_pm[aggregate_pm_census_cdc_test_beds$mean_pm25>quantile_pm[1] &
aggregate_pm_census_cdc_test_beds$mean_pm25<=quantile_pm[2]] = 2
aggregate_pm_census_cdc_test_beds$q_pm[aggregate_pm_census_cdc_test_beds$mean_pm25>quantile_pm[2] &
aggregate_pm_census_cdc_test_beds$mean_pm25<=quantile_pm[3]] = 3
aggregate_pm_census_cdc_test_beds$q_pm[aggregate_pm_census_cdc_test_beds$mean_pm25>quantile_pm[3] &
aggregate_pm_census_cdc_test_beds$mean_pm25<=quantile_pm[4]] = 4
aggregate_pm_census_cdc_test_beds$q_pm[aggregate_pm_census_cdc_test_beds$mean_pm25>quantile_pm[4]] = 5
mode.nb.random.off.catepm = glmer.nb(Deaths ~ factor(q_pm) + factor(q_popdensity)
+ scale(poverty) + scale(log(medianhousevalue))
+ scale(log(medhouseholdincome)) + scale(pct_owner_occ)
+ scale(education) + scale(pct_blk) + scale(hispanic)
+ scale(older_pecent) + scale(prime_pecent) + scale(mid_pecent)
+ scale(date_since_social) + scale(date_since)
+ scale(beds/population)
+ scale(obese) + scale(smoke)
+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
+ (1|state)
+ offset(log(population)), data = (aggregate_pm_census_cdc_test_beds))
summary(mode.nb.random.off.urban)
exp(summary(mode.nb.random.off.catepm)[10]$coefficients[2,1])
exp(summary(mode.nb.random.off.catepm)[10]$coefficients[2,1] - 1.96*summary(mode.nb.random.off.catepm)[10]$coefficients[2,2])
exp(summary(mode.nb.random.off.catepm)[10]$coefficients[2,1] + 1.96*summary(mode.nb.random.off.catepm)[10]$coefficients[2,2])
summary(mode.nb.random.off.catepm)[10]$coefficients[2,4]
exp(summary(mode.nb.random.off.catepm)[10]$coefficients[3,1])
exp(summary(mode.nb.random.off.catepm)[10]$coefficients[3,1] - 1.96*summary(mode.nb.random.off.catepm)[10]$coefficients[3,2])
exp(summary(mode.nb.random.off.catepm)[10]$coefficients[3,1] + 1.96*summary(mode.nb.random.off.catepm)[10]$coefficients[3,2])
summary(mode.nb.random.off.catepm)[10]$coefficients[3,4]
exp(summary(mode.nb.random.off.catepm)[10]$coefficients[4,1])
exp(summary(mode.nb.random.off.catepm)[10]$coefficients[4,1] - 1.96*summary(mode.nb.random.off.catepm)[10]$coefficients[4,2])
exp(summary(mode.nb.random.off.catepm)[10]$coefficients[4,1] + 1.96*summary(mode.nb.random.off.catepm)[10]$coefficients[4,2])
summary(mode.nb.random.off.catepm)[10]$coefficients[4,4]
exp(summary(mode.nb.random.off.catepm)[10]$coefficients[5,1])
exp(summary(mode.nb.random.off.catepm)[10]$coefficients[5,1] - 1.96*summary(mode.nb.random.off.catepm)[10]$coefficients[5,2])
exp(summary(mode.nb.random.off.catepm)[10]$coefficients[5,1] + 1.96*summary(mode.nb.random.off.catepm)[10]$coefficients[5,2])
summary(mode.nb.random.off.catepm)[10]$coefficients[5,4]
# tested
mode.nb.random.off.tested = glmer.nb(Deaths ~ mean_pm25 + factor(q_popdensity)
+ scale(poverty) + scale(log(medianhousevalue))
+ scale(log(medhouseholdincome)) + scale(pct_owner_occ)
+ scale(education) + scale(pct_blk) + scale(hispanic)
+ scale(older_pecent) + scale(prime_pecent) + scale(mid_pecent)
+ scale(date_since_social) + scale(date_since)
+ scale(beds/population)
+ scale(obese) + scale(smoke)
+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
+ (1|state)
+ scale(totalTestResults)
+ offset(log(population)), data = (aggregate_pm_census_cdc_test_beds))
summary(mode.nb.random.off.tested)
exp(summary(mode.nb.random.off.tested)[10]$coefficients[2,1])
exp(summary(mode.nb.random.off.tested)[10]$coefficients[2,1] - 1.96*summary(mode.nb.random.off.tested)[10]$coefficients[2,2])
exp(summary(mode.nb.random.off.tested)[10]$coefficients[2,1] + 1.96*summary(mode.nb.random.off.tested)[10]$coefficients[2,2])
summary(mode.nb.random.off.tested)[10]$coefficients[2,4]
# cli
mode.nb.random.off.symptom = glmer.nb(Deaths ~ mean_pm25 + factor(q_popdensity)
+ scale(poverty) + scale(log(medianhousevalue))
+ scale(log(medhouseholdincome)) + scale(pct_owner_occ)
+ scale(education) + scale(pct_blk) + scale(hispanic)
+ scale(older_pecent) + scale(prime_pecent) + scale(mid_pecent)
+ scale(date_since_social) + scale(date_since)
+ scale(beds/population)
+ scale(obese) + scale(smoke)
+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
+ scale(cli)
+ (1|Province_State)
+ offset(log(population)), data = (aggregate_pm_census_cdc_test_beds))
summary(mode.nb.random.off.symptom)
exp(summary(mode.nb.random.off.symptom)[10]$coefficients[2,1])
exp(summary(mode.nb.random.off.symptom)[10]$coefficients[2,1] - 1.96*summary(mode.nb.random.off.symptom)[10]$coefficients[2,2])
exp(summary(mode.nb.random.off.symptom)[10]$coefficients[2,1] + 1.96*summary(mode.nb.random.off.symptom)[10]$coefficients[2,2])
summary(mode.nb.random.off.symptom)[10]$coefficients[2,4]
# mobility
mode.nb.random.off.mobi = glmer.nb(Deaths ~ mean_pm25 + factor(q_popdensity)
+ scale(poverty) + scale(log(medianhousevalue))
+ scale(log(medhouseholdincome)) + scale(pct_owner_occ)
+ scale(education) + scale(pct_blk) + scale(hispanic)
+ scale(older_pecent) + scale(prime_pecent) + scale(mid_pecent)
+ scale(date_since_social) + scale(date_since)
+ scale(beds/population)
+ scale(obese) + scale(smoke)
+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
+ scale(mean_visited_change) + scale(mean_ratio)
+ (1|Province_State)
+ offset(log(population)), data = (aggregate_pm_census_cdc_test_beds_mobility))
summary(mode.nb.random.off.mobi)
exp(summary(mode.nb.random.off.mobi)[10]$coefficients[2,1])
exp(summary(mode.nb.random.off.mobi)[10]$coefficients[2,1] - 1.96*summary(mode.nb.random.off.mobi)[10]$coefficients[2,2])
exp(summary(mode.nb.random.off.mobi)[10]$coefficients[2,1] + 1.96*summary(mode.nb.random.off.mobi)[10]$coefficients[2,2])
summary(mode.nb.random.off.mobi)[10]$coefficients[2,4]
# log(popdensity)
mode.nb.random.off.main.logpopdensity = glmer.nb(Deaths ~ mean_pm25 + scale(log(popdensity))
+ scale(poverty) + scale(log(medianhousevalue))
+ scale(log(medhouseholdincome)) + scale(pct_owner_occ)
+ scale(education) + scale(pct_blk) + scale(hispanic)
+ scale(older_pecent) + scale(prime_pecent) + scale(mid_pecent)
+ scale(date_since_social) + scale(date_since)
+ scale(beds/population)
+ scale(obese) + scale(smoke)
+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
+ (1|state)
+ offset(log(population)), data = aggregate_pm_census_cdc_test_beds)
summary(mode.nb.random.off.main.logpopdensity)
exp(summary(mode.nb.random.off.main.logpopdensity)[10]$coefficients[2,1])
exp(summary(mode.nb.random.off.main.logpopdensity)[10]$coefficients[2,1] - 1.96*summary(mode.nb.random.off.main.logpopdensity)[10]$coefficients[2,2])
exp(summary(mode.nb.random.off.main.logpopdensity)[10]$coefficients[2,1] + 1.96*summary(mode.nb.random.off.main.logpopdensity)[10]$coefficients[2,2])
summary(mode.nb.random.off.main.logpopdensity)[10]$coefficients[2,4]
# log
mode.nb.random.log = glmer.nb(Deaths ~ mean_pm25 + factor(q_popdensity)
+ scale(poverty) + scale(log(medianhousevalue))
+ scale(log(medhouseholdincome)) + scale(pct_owner_occ)
+ scale(education) + scale(pct_blk) + scale(hispanic)
+ scale(older_pecent) + scale(prime_pecent) + scale(mid_pecent)
+ scale(date_since_social) + scale(date_since)
+ scale(beds/population)
+ scale(obese) + scale(smoke)
+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
+ (1|state)
+ scale(log(population)), data = (aggregate_pm_census_cdc_test_beds))
summary(mode.nb.random.log)
exp(summary(mode.nb.random.log)[10]$coefficients[2,1])
exp(summary(mode.nb.random.log)[10]$coefficients[2,1] - 1.96*summary(mode.nb.random.log)[10]$coefficients[2,2])
exp(summary(mode.nb.random.log)[10]$coefficients[2,1] + 1.96*summary(mode.nb.random.log)[10]$coefficients[2,2])
summary(mode.nb.random.log)[10]$coefficients[2,4]
mode.nb.random.nonlog = glmer.nb(Deaths ~ mean_pm25 + factor(q_popdensity)
+ scale(poverty) + scale(log(medianhousevalue))
+ scale(log(medhouseholdincome)) + scale(pct_owner_occ)
+ scale(education) + scale(pct_blk) + scale(hispanic)
+ scale(older_pecent) + scale(prime_pecent) + scale(mid_pecent)
+ scale(date_since_social) + scale(date_since)
+ scale(beds/population)
+ scale(obese) + scale(smoke)
+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
+ (1|state)
+ scale((population)), data = (aggregate_pm_census_cdc_test_beds))
summary(mode.nb.random.nonlog)
exp(summary(mode.nb.random.nonlog)[10]$coefficients[2,1])
exp(summary(mode.nb.random.nonlog)[10]$coefficients[2,1] - 1.96*summary(mode.nb.random.nonlog)[10]$coefficients[2,2])
exp(summary(mode.nb.random.nonlog)[10]$coefficients[2,1] + 1.96*summary(mode.nb.random.nonlog)[10]$coefficients[2,2])
summary(mode.nb.random.nonlog)[10]$coefficients[2,4]
# zero inflated
glmmTMB.off.main = glmmTMB(Deaths ~ mean_pm25 + factor(q_popdensity)
+ scale(poverty) + scale(log(medianhousevalue))
+ scale(log(medhouseholdincome)) + scale(pct_owner_occ)
+ scale(education) + scale(pct_blk) + scale(hispanic)
+ scale(older_pecent) + scale(prime_pecent) + scale(mid_pecent)
+ scale(date_since_social) + scale(date_since)
+ scale(beds/population)
+ scale(obese) + scale(smoke)
+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
+ offset(log(population)) + (1 | state), data = aggregate_pm_census_cdc_test_beds,
family = nbinom2, ziformula = ~ 1
)
exp(summary(glmmTMB.off.main)[6]$coefficients$cond[2,1])
exp(summary(glmmTMB.off.main)[6]$coefficients$cond[2,1] - 1.96*summary(glmmTMB.off.main)[6]$coefficients$cond[2,2])
exp(summary(glmmTMB.off.main)[6]$coefficients$cond[2,1] + 1.96*summary(glmmTMB.off.main)[6]$coefficients$cond[2,2])
summary(glmmTMB.off.main)[6]$coefficients$cond[2,4]
# fixed NB
glm.nb.off = glm.nb(Deaths ~ mean_pm25 + factor(q_popdensity)
+ scale(poverty) + scale(log(medianhousevalue))
+ scale(log(medhouseholdincome)) + scale(pct_owner_occ)
+ scale(education) + scale(pct_blk) + scale(hispanic)
+ scale(older_pecent) + scale(prime_pecent) + scale(mid_pecent)
+ scale(date_since_social) + scale(date_since)
+ scale(beds/population)
+ scale(obese) + scale(smoke)
+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
+ factor(state)
+ offset(log(population)), data = aggregate_pm_census_cdc_test_beds)
summary(glm.nb.off)
# spatial-correlation gamm
gamm.off.main = gamm4(Deaths ~ mean_pm25 + factor(q_popdensity)
+ scale(poverty) + scale(log(medianhousevalue))
+ scale(log(medhouseholdincome)) + scale(pct_owner_occ)
+ scale(education) + scale(pct_blk) + scale(hispanic)
+ scale(older_pecent) + scale(prime_pecent) + scale(mid_pecent)
+ scale(date_since_social) + scale(date_since)
+ scale(beds/population)
+ scale(obese) + scale(smoke)
+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
+ offset(log(population)) + s(Lat) + s(Long_), data = aggregate_pm_census_cdc_test_beds,
family=negbin(1), random = ~(1|state))
exp(summary(gamm.off.main.bi))
# non-linear pm
gamm.off.main.spm25 = gamm4(Deaths ~ s(mean_pm25) + factor(q_popdensity)
+ scale(poverty) + scale(log(medianhousevalue))
+ scale(log(medhouseholdincome)) + scale(pct_owner_occ)
+ scale(education) + scale(pct_blk) + scale(hispanic)
+ scale(older_pecent) + scale(prime_pecent) + scale(mid_pecent)
+ scale(date_since_social) + scale(date_since)
+ scale(beds/population)
+ scale(obese) + scale(smoke)
+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
+ offset(log(population)) + s(Lat) + s(Long_), data = aggregate_pm_census_cdc_test_beds,
family=negbin(1), random = ~(1|state))