-
Notifications
You must be signed in to change notification settings - Fork 0
/
plosone_revise-resubmit_paper1.do
382 lines (333 loc) · 12.1 KB
/
plosone_revise-resubmit_paper1.do
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
* full sample analyses
* PLOSOne R&R
set more off
clear all
cd "H:\Personal\food environment paper 1"
use food_environment_2013_paper1.dta, clear
cd "C:\Users\wue04\Box Sync\home-food-env"
*** analytics
global sample !missing(x) & !missing(age) & !missing(grade) & !missing(bds) & ///
!missing(ethnic) & !missing(x_sch) & home>2640 & sch>2640 & district<=32 & ///
eth!=6 & !missing(boro) & !missing(boro_sch) & !missing(native) //789520
rename FF FFOR
foreach var in FFOR BOD C6P WS {
label var `var' "dist to nearest `var'"
label var `var'_sch "dist to nearest `var' from school"
label var n`var'1320 "num of `var' in 1320 ft"
label var n`var'1320_sch "num of `var' in 1320 ft from school"
}
.
* create race and poverty intereaction
* create school levels
{
gen poor_race=1 if poor==0 & eth==5
replace poor_race=2 if poor==0 & eth==4
replace poor_race=3 if poor==0 & eth==3
replace poor_race=4 if poor==0 & eth==2
replace poor_race=5 if poor==1 & eth==5
replace poor_race=6 if poor==1 & eth==4
replace poor_race=7 if poor==1 & eth==3
replace poor_race=8 if poor==1 & eth==2
label var poor_race "interaction race and poverty"
label define interaction 1 "NP white" 2 "NP black" 3 "NP hisp" 4 "NP asian" ///
5 "poor white" 6 "poor black" 7 "poor hisp" 8 "poor asian", replace
label values poor_race ineraction
gen level=1 if grade<=5 & grade>=0
replace level=2 if grade<=8 & grade>=6
replace level=3 if grade<=12 & grade>=9
label var level "school level"
label define level 1 "k-5" 2 "6-8" 3 "9-12"
label values level level
tab grade level
}
.
* create flow diagram
count //1129918
* district 1-32
count if district<=32 //1027067
* have home and school address
count if !missing(x) & !missing(x_sch) & district<=32 & ///
!missing(boro) & !missing(boro_sch) //888815
* have demographic info
count if !missing(x) & !missing(age) & !missing(grade) & !missing(bds) & ///
!missing(ethnic) & !missing(x_sch) & district<=32 & ///
eth!=6 & !missing(boro) & !missing(boro_sch) & !missing(native) //821854
* live more than half a mile from city border
count if !missing(x) & !missing(age) & !missing(grade) & !missing(bds) & ///
!missing(ethnic) & !missing(x_sch) & home>2640 & sch>2640 & district<=32 & ///
eth!=6 & !missing(boro) & !missing(boro_sch) & !missing(native) //789520
*** table 1 socio-demo
{
tab eth if $sample
tab poor if $sample
tab female if $sample
tab poor if $sample
tab native if $sample
tab sped if $sample
tab eng if $sample
tab lep if $sample
sum grade age if $sample
tab boro if $sample
* by race/ethnicity
forvalues race=2/5 {
tab female if $sample & eth==`race'
tab poor if $sample & eth==`race'
tab native if $sample & eth==`race'
tab sped if $sample & eth==`race'
tab eng if $sample & eth==`race'
tab lep if $sample & eth==`race'
sum grade age if $sample & eth==`race'
tab boro if $sample & eth==`race'
}
.
* by poverty status
foreach poor in 1 0 {
tab female if $sample & poor==`poor'
tab poor if $sample & poor==`poor'
tab native if $sample & poor==`poor'
tab sped if $sample & poor==`poor'
tab eng if $sample & poor==`poor'
tab lep if $sample & poor==`poor'
sum grade age if $sample & poor==`poor'
tab boro if $sample & poor==`poor'
}
.
}.
* table 2
* distance to nearest food outlet
sum BOD* FF* WS* C6P* if $sample, d
forvalues poor=0/1 {
forvalues race=2/5 {
sum BOD* FF* WS* C6P* if $sample & eth==`race' & poor==`poor'
}
}
.
* make histograms to see why mean and median are different
{
hist nBOD1320 if $sample, bin(127) ///
xtitle("Number of corner stores") title("Corner store") ///
xlab(`=0' "0" `=50' "50" `=127' "max" `=25' "25" `=15.65' "mean", labsize(tiny))
graph save figures\histogram_corner_store.gph, replace
hist nFFOR1320 if $sample, bin(242) ///
xtitle("Number of fast food restaurants") title("Fast food") ///
xlab(`=0' "0" `=50' "50" `=100' "100" `=242' "max" `=17.31' "mean", labsize(tiny))
graph save figures\histogram_fast_food.gph, replace
hist nWS1320 if $sample, bin(220) ///
xtitle("Number of wait service restaurants") title("Wait service") ///
xlab(`=0' "0" `=50' "50" `=150' "150" `=50' "50" `=150' "150" `=220' "max" `=8.02' "mean", labsize(tiny))
graph save figures\histogram_wait_service.gph, replace
hist nC6P1320 if $sample, bin(10) ///
xtitle("Number of supermarkets") title("Supermarket") ///
xlab(`=0' "0" `=2' "2" `=5' "5" `=10' "max" `=1.19' "mean", labsize(tiny))
graph save figures\histogram_supermarket.gph, replace
}
.
* test statistical significance between diff races
* home
foreach var in BOD FF WS C6P {
reg `var' i.poor_race if $sample
pwcompare poor_race, mcompare(bon) effects
}
.
* school: clustered SE at bds level with bonferroni correction
foreach var in BOD FF WS C6P {
reg `var'_sch i.poor_race if $sample, cluster(bds)
pwcompare poor_race, mcompare(bon) effects
}
.
* table 3-5: num of food outlets within buffers
*** count num of food outlets from schools
foreach dist in 1320 528 2640 {
sum nBOD`dist'_sch nFF`dist'_sch nWS`dist'_sch nC6P`dist'_sch if $sample
bys eth: sum nBOD`dist'_sch nFF`dist'_sch nWS`dist'_sch nC6P`dist'_sch if $sample & poor==0
bys eth: sum nBOD`dist'_sch nFF`dist'_sch nWS`dist'_sch nC6P`dist'_sch if $sample & poor==1
}
sum nBOD1320* nFFOR1320* nWS1320* nC6P1320* if $sample, d //get median
* t test
foreach dist in 1320 528 2640 {
foreach var in BOD FF WS C6P {
reg n`var'`dist'_sch i.poor_race if $sample, cluster(bds)
pwcompare poor_race, mcompare(bon) effects
}
}
.
* R&R additional work
* add SD to tables
* tabls s1
estpost tabstat BOD BOD_sch FFOR FFOR_sch WS WS_sch C6P C6P_sch if $sample, ///
by(poor_race) stats(sd) column(statistics)
esttab using raw-tables\table1-7_with_sd_20190109.rtf, ///
cells("sd(fmt(%12.0f))") replace title("s1")
estpost tabstat nBOD1320 nBOD1320_sch nFFOR1320 nFFOR1320_sch nWS1320 ///
nWS1320_sch nC6P1320 nC6P1320_sch if $sample, ///
by(poor_race) stats(sd) column(statistics)
esttab using raw-tables\table1-7_with_sd_20190109.rtf, ///
cells("sd(fmt(%12.0f))") append title("s2")
estpost tabstat nBOD528 nBOD528_sch nFFOR528 nFFOR528_sch nWS528 ///
nWS528_sch nC6P528 nC6P528_sch if $sample, ///
by(poor_race) stats(sd) column(statistics)
esttab using raw-tables\table1-7_with_sd_20190109.rtf, ///
cells("sd(fmt(%12.0f))") append title("s3")
estpost tabstat nBOD2640 nBOD2640_sch nFFOR2640 nFFOR2640_sch nWS2640 ///
nWS2640_sch nC6P2640 nC6P2640_sch if $sample, ///
by(poor_race) stats(sd) column(statistics)
esttab using raw-tables\table1-7_with_sd_20190109.rtf, ///
cells("sd(fmt(%12.0f))") append title("s4")
* breakdown by grade
forvalues i=1/3 {
estpost tabstat BOD BOD_sch FFOR FFOR_sch WS WS_sch C6P C6P_sch if $sample & level==`i', ///
by(poor_race) stats(sd) column(statistics)
esttab using raw-tables\table1-7_with_sd_20190109.rtf, ///
cells("sd(fmt(%12.0f))") append title("mean-dist-level-`i'")
estpost tabstat nBOD1320 nBOD1320_sch nFFOR1320 nFFOR1320_sch nWS1320 ///
nWS1320_sch nC6P1320 nC6P1320_sch if $sample & level==`i', ///
by(poor_race) stats(sd) column(statistics)
esttab using raw-tables\table1-7_with_sd_20190109.rtf, ///
cells("sd(fmt(%12.0f))") append title("count0.25-level-`i'")
estpost tabstat nBOD528 nBOD528_sch nFFOR528 nFFOR528_sch nWS528 ///
nWS528_sch nC6P528 nC6P528_sch if $sample & level==`i', ///
by(poor_race) stats(sd) column(statistics)
esttab using raw-tables\table1-7_with_sd_20190109.rtf, ///
cells("sd(fmt(%12.0f))") append title("count0.1-level-`i'")
estpost tabstat nBOD2640 nBOD2640_sch nFFOR2640 nFFOR2640_sch nWS2640 ///
nWS2640_sch nC6P2640 nC6P2640_sch if $sample & level==`i', ///
by(poor_race) stats(sd) column(statistics)
esttab using raw-tables\table1-7_with_sd_20190109.rtf, ///
cells("sd(fmt(%12.0f))") append title("count0.5-level-`i'")
}
.
/*
* compare school level resutls with old model (no clustered SE)
foreach dist in 1320 528 2640 {
foreach var in BOD FF WS C6P {
reg n`var'`dist'_sch i.poor_race if $sample
pwcompare poor_race, mcompare(bon) effects
}
}
. */
* home
* count the num of food outlets
foreach dist in 1320 528 2640 {
sum nBOD`dist' nFFOR`dist' nWS`dist' nC6P`dist' if $sample
bys eth: sum nBOD`dist' nFF`dist' nWS`dist' nC6P`dist' if $sample & poor==0
bys eth: sum nBOD`dist' nFF`dist' nWS`dist' nC6P`dist' if $sample & poor==1
}
.
* t test
foreach dist in 528 {
foreach var in BOD FFOR WS C6P {
reg n`var'`dist' i.poor_race if $sample
pwcompare poor_race, mcompare(bon) effects
}
}
.
*** t test schools, 1) poor vs non-poor; 2) race;
*** no interactions
* clustered SE
foreach dist in 1320 528 2640 {
foreach x in poor ethnic2 {
foreach var in BOD FFOR WS C6P {
reg n`var'`dist'_sch i.`x' if $sample, cluster(bds)
pwcompare `x', mcompare(bon) effects
}
}
}
.
foreach x in poor ethnic2 {
foreach var in BOD FFOR WS C6P {
reg `var'_sch i.`x' if $sample, cluster(bds)
pwcompare `x', mcompare(bon) effects
}
}
.
* no clustered SE
foreach dist in 1320 528 2640 {
foreach x in poor ethnic2 {
foreach var in BOD FFOR WS C6P {
reg n`var'`dist'_sch i.`x' if $sample
pwcompare `x', mcompare(bon) effects
}
}
}
.
foreach x in poor ethnic2 {
foreach var in BOD FFOR WS C6P {
reg `var'_sch i.`x' if $sample
pwcompare `x', mcompare(bon) effects
}
}
.
*pwmean FFOR_sch, over(i.poor_race) mcompare(bon) effects //with bonferroni correction
* joint f tests
* for both home and school level measurements
tab poor_race if $sample, gen(poor_race)
foreach var in BOD FFOR WS C6P { //home level
reg `var' poor_race1 poor_race2 poor_race3 poor_race4 ///
poor_race5 poor_race6 poor_race7 poor_race8
test poor_race1 poor_race2 poor_race3 poor_race4 ///
poor_race5 poor_race6 poor_race7 poor_race8
}
.
foreach dist in 1320 528 2640 { //home level
foreach var in BOD FFOR WS C6P {
reg n`var'`dist' poor_race1 poor_race2 poor_race3 poor_race4 ///
poor_race5 poor_race6 poor_race7 poor_race8
test poor_race1 poor_race2 poor_race3 poor_race4 ///
poor_race5 poor_race6 poor_race7 poor_race8
}
}
.
foreach var in BOD FFOR WS C6P { //school level
reg `var'_sch poor_race1 poor_race2 poor_race3 poor_race4 ///
poor_race5 poor_race6 poor_race7 poor_race8, cluster(bds)
test poor_race1 poor_race2 poor_race3 poor_race4 ///
poor_race5 poor_race6 poor_race7 poor_race8
}
.
foreach dist in 1320 { //school level
foreach var in BOD FFOR WS C6P {
reg n`var'`dist'_sch poor_race1 poor_race2 poor_race3 poor_race4 ///
poor_race5 poor_race6 poor_race7 poor_race8, cluster(bds)
test poor_race1 poor_race2 poor_race3 poor_race4 ///
poor_race5 poor_race6 poor_race7 poor_race8
}
}
.
* count of food outlets in AY2013
* 2012-9-1: 19237
* 2013-8-31: 19601
* also re-align food ctegories
use "G:\Dr.Brian Elbel’s Projects\CURRENT PROJECTS\GEO R01\Data\Food Environment Data\food_sources_01032018.dta", clear
count if (start<19601 & (stop==.|stop>19601))|(start<19237 & (stop==.|stop>19237)) //42,841
keep no name address boronum category ingrading nosqft largechain estabno start stop
tab cat
count if missing(nosq) & ingra==0 //2768 stores
tab cat if missing(nosq) & ingra==0 //2768 stores
gen cat2="FFOR" if category=="Restaurant - Fast Food"|category=="Restaurant - Other"
replace cat2="WS" if category=="Restaurant - Wait Service"
replace cat2="C6P" if category=="Chain Supermarket"
replace cat2="C6P" if (category=="Ind Supermarket"|category=="Large Grocery"| ///
category=="Small Grocery") & nosq>=6000
replace cat2="BOD" if category=="Bodega/Conv Store"|category=="Small Grocery"| ///
(category=="Large Grocery" & nosqft<=6000)|(category=="Ind Supermarket" & nosqft<=6000)
replace cat2=category if missing(cat2)
tab cat2 if (start<19601 & (stop==.|stop>19601))|(start<19237 & (stop==.|stop>19237))
/*
* create poorXrace variable
gen poor_race=1 if poor==1 & eth==2
replace poor_race=2 if poor==1 & eth==3
replace poor_race=3 if poor==1 & eth==4
replace poor_race=4 if poor==1 & eth==5
replace poor_race=5 if poor==0 & eth==2
replace poor_race=6 if poor==0 & eth==3
replace poor_race=7 if poor==0 & eth==4
replace poor_race=8 if poor==0 & eth==5
label define poor_race 1 "poor Asian" 2 "poor Hisp" 3 "poor black" 4 "poor white" ///
5 "non-poor Asian" 6 "non-poor Hisp" 7 "non-poor black" 8 "non-poor white", replace
label values poor_race poor_race
tab poor_race if $sample
forvalues i=1/8 {
unique(bds) if $sample & poor_race==`i'
}
.
*/