forked from brendancol/PM_COVID
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Analyses.R
224 lines (201 loc) · 12.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
library("dplyr")
library("pscl")
library("MASS")
library(NBZIMM)
library("lme4")
# main analysis
glmm.zinb.off = glmm.zinb(fixed = Deaths ~ mean_pm25 +scale(poverty) + scale(popdensity) +scale(medianhousevalue)
+scale(medhouseholdincome) + scale(pct_owner_occ) +scale(hispanic)
+scale(education) +scale(pct_blk) + scale(older_pecent)
+ scale(totalTestResults) +
+ scale(beds)
+ scale(mean_bmi) + scale(smoke_rate)
+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
+ offset(log(population)),
random = ~ 1 | state, data = (aggregate_pm_census_cdc_test_beds))
summary(glmm.zinb.off)
fixed(glmm.zinb.off)$dist[2,1]
fixed(glmm.zinb.off)$dist[2,1] - 1.96*fixed(glmm.zinb.off)$dist[2,2]
fixed(glmm.zinb.off)$dist[2,1] + 1.96*fixed(glmm.zinb.off)$dist[2,2]
fixed(glmm.zinb.off)$dist[2,3]
glmm.zinb.log = glmm.zinb(fixed = Deaths ~ mean_pm25 +scale(poverty) + scale(popdensity) +scale(medianhousevalue)
+scale(medhouseholdincome) + scale(pct_owner_occ) +scale(hispanic)
+scale(education) +scale(pct_blk) + scale(older_pecent)
+ scale(beds)
+ scale(mean_bmi) + scale(smoke_rate)
+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
+ scale(totalTestResults)
+ scale(log(population)),
random = ~ 1 | state, data = (aggregate_pm_census_cdc_test_beds))
summary(glmm.zinb.log)
fixed(glmm.zinb.log)$dist[2,1]
fixed(glmm.zinb.log)$dist[2,1] - 1.96*fixed(glmm.zinb.log)$dist[2,2]
fixed(glmm.zinb.log)$dist[2,1] + 1.96*fixed(glmm.zinb.log)$dist[2,2]
fixed(glmm.zinb.log)$dist[2,3]
glmm.zinb.nonlog = glmm.zinb(fixed = Deaths ~ mean_pm25 +scale(poverty) + scale(popdensity) +scale(medianhousevalue)
+scale(medhouseholdincome) + scale(pct_owner_occ) +scale(hispanic)
+scale(education) +scale(pct_blk) + scale(older_pecent)
+ scale(beds)
+ scale(mean_bmi) + scale(smoke_rate)
+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
+ scale(totalTestResults)
+ scale((population)),
random = ~ 1 | state, data = (aggregate_pm_census_cdc_test_beds))
summary(glmm.zinb.nonlog)
fixed(glmm.zinb.nonlog)$dist[2,1]
fixed(glmm.zinb.nonlog)$dist[2,1] - 1.96*fixed(glmm.zinb.nonlog)$dist[2,2]
fixed(glmm.zinb.nonlog)$dist[2,1] + 1.96*fixed(glmm.zinb.nonlog)$dist[2,2]
fixed(glmm.zinb.nonlog)$dist[2,3]
# - beds
glmm.zinb.off = glmm.zinb(fixed = Deaths ~ mean_pm25 +scale(poverty) + scale(popdensity) +scale(medianhousevalue)
+scale(medhouseholdincome) + scale(pct_owner_occ) +scale(hispanic)
+scale(education) +scale(pct_blk) + scale(older_pecent)
#+ scale(beds)
+ scale(mean_bmi) + scale(smoke_rate)
+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
+ scale(totalTestResults)
+ offset(log(population)),
random = ~ 1 | state, data = (aggregate_pm_census_cdc_test_beds))
summary(glmm.zinb.off)
fixed(glmm.zinb.off)$dist[2,1]
fixed(glmm.zinb.off)$dist[2,1] - 1.96*fixed(glmm.zinb.off)$dist[2,2]
fixed(glmm.zinb.off)$dist[2,1] + 1.96*fixed(glmm.zinb.off)$dist[2,2]
fixed(glmm.zinb.off)$dist[2,3]
# - tested
glmm.zinb.off = glmm.zinb(fixed = Deaths ~ mean_pm25 +scale(poverty) + scale(popdensity) +scale(medianhousevalue)
+scale(medhouseholdincome) + scale(pct_owner_occ) +scale(hispanic)
+scale(education) +scale(pct_blk) + scale(older_pecent)
+ scale(beds)
+ scale(mean_bmi) + scale(smoke_rate)
+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
#+ scale(totalTestResults)
+ offset(log(population)),
random = ~ 1 | state, data = (aggregate_pm_census_cdc_test_beds))
summary(glmm.zinb.off)
fixed(glmm.zinb.off)$dist[2,1]
fixed(glmm.zinb.off)$dist[2,1] - 1.96*fixed(glmm.zinb.off)$dist[2,2]
fixed(glmm.zinb.off)$dist[2,1] + 1.96*fixed(glmm.zinb.off)$dist[2,2]
fixed(glmm.zinb.off)$dist[2,3]
# - smoking + bmi
glmm.zinb.off = glmm.zinb(fixed = Deaths ~ mean_pm25 +scale(poverty) + scale(popdensity) +scale(medianhousevalue)
+scale(medhouseholdincome) + scale(pct_owner_occ) +scale(hispanic)
+scale(education) +scale(pct_blk) + scale(older_pecent)
+ scale(beds)
#+ scale(mean_bmi) + scale(smoke_rate)
+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
+ scale(totalTestResults)
+ offset(log(population)),
random = ~ 1 | state, data = (aggregate_pm_census_cdc_test_beds))
summary(glmm.zinb.off)
fixed(glmm.zinb.off)$dist[2,1]
fixed(glmm.zinb.off)$dist[2,1] - 1.96*fixed(glmm.zinb.off)$dist[2,2]
fixed(glmm.zinb.off)$dist[2,1] + 1.96*fixed(glmm.zinb.off)$dist[2,2]
fixed(glmm.zinb.off)$dist[2,3]
# - temp + humidity
glmm.zinb.off = glmm.zinb(fixed = Deaths ~ mean_pm25 +scale(poverty) + scale(popdensity) +scale(medianhousevalue)
+scale(medhouseholdincome) + scale(pct_owner_occ) +scale(hispanic)
+scale(education) +scale(pct_blk) + scale(older_pecent)
+ scale(beds)
+ scale(mean_bmi) + scale(smoke_rate)
#+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
+ scale(totalTestResults)
+ offset(log(population)),
random = ~ 1 | state, data = (aggregate_pm_census_cdc_test_beds))
summary(glmm.zinb.off)
fixed(glmm.zinb.off)$dist[2,1]
fixed(glmm.zinb.off)$dist[2,1] - 1.96*fixed(glmm.zinb.off)$dist[2,2]
fixed(glmm.zinb.off)$dist[2,1] + 1.96*fixed(glmm.zinb.off)$dist[2,2]
fixed(glmm.zinb.off)$dist[2,3]
# exclude NY
glmm.zinb.off = glmm.zinb(fixed = Deaths ~ mean_pm25 +scale(poverty) + scale(popdensity) +scale(medianhousevalue)
+scale(medhouseholdincome) + scale(pct_owner_occ) +scale(hispanic)
+scale(education) +scale(pct_blk) + scale(older_pecent)
+ scale(beds)
+ scale(mean_bmi) + scale(smoke_rate)
+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
+ scale(totalTestResults)
+ offset(log(population)),
random = ~ 1 | state, data = subset(aggregate_pm_census_cdc_test_beds,Province_State != "New York"))
summary(glmm.zinb.off)
fixed(glmm.zinb.off)$dist[2,1]
fixed(glmm.zinb.off)$dist[2,1] - 1.96*fixed(glmm.zinb.off)$dist[2,2]
fixed(glmm.zinb.off)$dist[2,1] + 1.96*fixed(glmm.zinb.off)$dist[2,2]
fixed(glmm.zinb.off)$dist[2,3]
# exclude <10 confirmed
glmm.zinb.off = glmm.zinb(fixed = Deaths ~ mean_pm25 +scale(poverty) + scale(popdensity) +scale(medianhousevalue)
+scale(medhouseholdincome) + scale(pct_owner_occ) +scale(hispanic)
+scale(education) +scale(pct_blk) + scale(older_pecent)
+ scale(beds)
+ scale(mean_bmi) + scale(smoke_rate)
+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
+ scale(totalTestResults)
+ offset(log(population)),
random = ~ 1 | state, data = subset(aggregate_pm_census_cdc_test_beds,Confirmed >=10))
summary(glmm.zinb.off)
fixed(glmm.zinb.off)$dist[2,1]
fixed(glmm.zinb.off)$dist[2,1] - 1.96*fixed(glmm.zinb.off)$dist[2,2]
fixed(glmm.zinb.off)$dist[2,1] + 1.96*fixed(glmm.zinb.off)$dist[2,2]
fixed(glmm.zinb.off)$dist[2,3]
# 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
glmm.zinb.off = glmm.zinb(fixed = Deaths ~ factor(q_pm) +scale(poverty) + scale(popdensity) +scale(medianhousevalue)
+scale(medhouseholdincome) + scale(pct_owner_occ) +scale(hispanic)
+scale(education) +scale(pct_blk) + scale(older_pecent)
+ scale(beds)
+ scale(mean_bmi) + scale(smoke_rate)
+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
+ scale(totalTestResults)
+ offset(log(population)),
random = ~ 1 | state, data = (aggregate_pm_census_cdc_test_beds))
summary(glmm.zinb.off)
fixed(glmm.zinb.off)$dist[2,1]
fixed(glmm.zinb.off)$dist[2,1] - 1.96*fixed(glmm.zinb.off)$dist[2,2]
fixed(glmm.zinb.off)$dist[2,1] + 1.96*fixed(glmm.zinb.off)$dist[2,2]
fixed(glmm.zinb.off)$dist[2,3]
fixed(glmm.zinb.off)$dist[3,1]
fixed(glmm.zinb.off)$dist[3,1] - 1.96*fixed(glmm.zinb.off)$dist[3,2]
fixed(glmm.zinb.off)$dist[3,1] + 1.96*fixed(glmm.zinb.off)$dist[3,2]
fixed(glmm.zinb.off)$dist[3,3]
fixed(glmm.zinb.off)$dist[4,1]
fixed(glmm.zinb.off)$dist[4,1] - 1.96*fixed(glmm.zinb.off)$dist[4,2]
fixed(glmm.zinb.off)$dist[4,1] + 1.96*fixed(glmm.zinb.off)$dist[4,2]
fixed(glmm.zinb.off)$dist[4,3]
fixed(glmm.zinb.off)$dist[5,1]
fixed(glmm.zinb.off)$dist[5,1] - 1.96*fixed(glmm.zinb.off)$dist[5,2]
fixed(glmm.zinb.off)$dist[5,1] + 1.96*fixed(glmm.zinb.off)$dist[5,2]
fixed(glmm.zinb.off)$dist[5,3]
# + q_popdensity
glmm.zinb.off = glmm.zinb(fixed = Deaths ~ mean_pm25 +scale(poverty) + factor(q_popdensity) +scale(medianhousevalue)
+scale(medhouseholdincome) + scale(pct_owner_occ) +scale(hispanic)
+scale(education) +scale(pct_blk) + scale(older_pecent)
+ scale(beds)
+ scale(mean_bmi) + scale(smoke_rate)
+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
+ scale(totalTestResults)
+ offset(log(population)),
random = ~ 1 | state, data = (aggregate_pm_census_cdc_test_beds))
#summary(glmm.zinb.off)
fixed(glmm.zinb.off)$dist[2,1]
fixed(glmm.zinb.off)$dist[2,1] - 1.96*fixed(glmm.zinb.off)$dist[2,2]
fixed(glmm.zinb.off)$dist[2,1] + 1.96*fixed(glmm.zinb.off)$dist[2,2]
fixed(glmm.zinb.off)$dist[2,3]
# Negative binomial
mode.nb.random.off = glmer.nb(Deaths ~ mean_pm25 +scale(poverty) +scale(medianhousevalue) + scale(popdensity)
+scale(medhouseholdincome) + scale(pct_owner_occ) +scale(hispanic)
+scale(education) +scale(pct_blk) + scale(older_pecent)
+ scale(beds)
+ scale(mean_bmi) + scale(smoke_rate)
+ scale(mean_summer_temp) + scale(mean_winter_temp) + scale(mean_summer_rm) + scale(mean_winter_rm)
+ scale(totalTestResults)
+ (1|state)
+ offset(log(population)), data = aggregate_pm_census_cdc_test_beds)
summary(mode.nb.random.off)