File size: 75,664 Bytes
3fb2143
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
* Set Directory
clear
set more off
set scheme s1mono

cd "$path"
global data_files "$path/Data"
global out_files "$path/output"

**==============================================================================
* Table A1
use "$data_files/Raw/allcity_info", clear

label variable pm25 "AOD"
label variable number "\# Monitors"
label variable area "Size of Built-up Area (km2)"
label variable pop "Urban Population (10,000)"

eststo clear
estpost tabstat pm25 number area pop, by(mainsample) statistics(mean sd) columns(statistics) listwise nototal
esttab using "$out_files/TableA1.tex", replace tex main(mean) aux(sd) nogaps nodepvar compress fragment nostar noobs unstack nonote nomtitle label

**==============================================================================
* Table C1
use "$data_files/firm_enf.dta", clear
keep if min_dist<50 & starty<=2010
drop if revenue == .
drop if key == .

label variable any_air "Any Air Pollution Enforcement"
label variable any_air_shutdown "\quad Suspension"
label variable any_air_fine "\quad Fine"
label variable any_air_renovate "\quad Upgrading"
label variable any_air_warning "\quad Warning"
label variable air "\# Air Pollution Enforcement"
label variable any_water "Any Water Pollu. Enforc."
label variable any_waste "Any Solid Waste Pollu. Enforc."
label variable any_proc "Any Procedure Pollu. Enforc."

label variable min_dist_10 "Monitor within 10 km"
label variable min_dist "Distance to Monitor (km)"
label variable starty "Year Started"
label variable employment "Employment"
label variable revenue "Revenue"
label variable up "Upwind Firms"

eststo clear
estpost summarize any_air* air any_water any_waste any_proc up
esttab using "$out_files/TableC1a1.tex", replace cells("mean(fmt(a2)) sd(fmt(a2)) count") noobs nolines nogaps nodepvar compress fragment nonumbers label mlabels(none) tex
display "Periods: "
display "Frequency: "

keep if year==2010 & quarter==1

gen state = (ownership==1 | ownership==2)
gen private = (ownership==3)
gen foreign = (ownership==9)
gen rest = (ownership==4|ownership==5)

label variable state "Owner: SOEs"
label variable private "Owner: Private"
label variable foreign "Owner: Foreign"
label variable rest "Owner: Other"

eststo clear
estpost summarize min_dist_10 min_dist starty state private foreign rest employment revenue
esttab using "$out_files/TableC1a2.tex", replace cells("mean(fmt(a2)) sd(fmt(a2)) count") noobs nolines nogaps nodepvar compress fragment nonumbers label mlabels(none) tex
display "Periods: "
display "Frequency: "

use "$data_files/city_pm.dta", clear
drop if pm25 == .

label variable number "\# Monitors"
label variable area "Size of Built-up Area (km2)"
label variable pop "Urban Population (10,000)"
label variable age_year "Age of the Mayor"
label variable pre "Precipitation (mm)"
label variable tem_mean "Mean Temperature"
label variable pm25 "Aerosol Optical Depth"

eststo clear
estpost summarize number area pop age_year pre tem_mean pm25
esttab using "$out_files/TableC1b1.tex", replace cells("mean(fmt(a2)) sd(fmt(a2)) count") noobs nolines nogaps nodepvar compress fragment nonumbers label mlabels(none) tex
display "Periods: "
display "Frequency: "

use "$data_files/city_pm.dta", clear
label variable post1 "Post" 
label variable number "\# Mon"
label variable number_iv "Min \# Mon"

merge 1:1 city_cn year month using "$data_files/Raw/baidu.dta" 
keep if _merge == 3
drop _merge

label variable sear_freq_w1 "Search Index: air pollution"
label variable sear_freq_w2 "Search Index: haze/smoke"
label variable sear_freq_w3 "Search Index: PM25"
label variable sear_freq_w4 "Search Index: air mask"
label variable sear_freq_w5 "Search Index: air purifier"

eststo clear
estpost summarize sear* 
esttab using "$out_files/TableC1b3.tex", replace cells("mean(fmt(a2)) sd(fmt(a2)) count") noobs nolines nogaps nodepvar compress fragment nonumbers label mlabels(none) tex
display "Periods: "
display "Frequency: "

use "$data_files/city_enf.dta", clear

gen any_air_total = any_air+any_air_rest
label variable any_air_total "\# Firms Any Air Pollu. Enfor. (incl non-ASIF)"
label variable any_air "\# Firms Any Air Pollu. Enfor."

eststo clear
estpost summarize any_air any_air_total 
esttab using "$out_files/TableC1b2.tex", replace cells("mean(fmt(a2)) sd(fmt(a2)) count") noobs nolines nogaps nodepvar compress fragment nonumbers label mlabels(none) tex
display "Periods: "
display "Frequency: "

use "$data_files/monitor_api.dta", clear

label variable pm25api "Particulate Matter 2.5 (PM$\_2.5$)"
label variable pm10api "Particulate Matter 10 (PM$\_10$))"
label variable AQI "Air Quality Index (AQI) "

eststo clear
estpost summarize pm25api pm10api AQI
esttab using "$out_files/TableC1c.tex", replace cells("mean(fmt(a2)) sd(fmt(a2)) count") noobs nolines nogaps nodepvar compress fragment nonumbers label mlabels(none) substitute(\_ _) tex

**==============================================================================
* Table C4
use "$data_files/monitor_api.dta", clear

gen log_pm25api = log(pm25api)
gen log_pm10api = log(pm10api) 
gen log_aqi = log(AQI) 
replace log_aqi = . if log_pm25api == .

rename pm25 AOD
label variable AOD "AOD"

eststo clear
reghdfe log_pm25api AOD pre tem_mean, a(monitor_id year#month) cl(city_id)
eststo A
estadd ysumm, mean
reghdfe log_pm10api AOD pre tem_mean, a(monitor_id year#month) cl(city_id)
eststo B
estadd ysumm, mean
reghdfe log_aqi AOD pre tem_mean, a(monitor_id year#month) cl(city_id)
eststo C
estadd ysumm, mean
esttab A B C using "$out_files/TableC4.tex", replace b(a2) noconstant se(a2) nolines nogaps compress fragment nonumbers label mlabels(none) collabels() keep(AOD) drop() stats(ymean N, labels("Mean Outcome" "Observations")) starlevels(* 0.10 ** 0.05 *** 0.01) substitute(\_ _) tex

**==============================================================================
* Table C5
use "$data_files/firm_enf.dta", clear
drop if revenue == .
drop if key == .
keep if min_dist<50 & starty<=2010 & time==1

gen twodigit = int(industry/100)

lab def twodigit_lb 6 "Mining and Washing of Coal & 6" ///
 7 "Extraction of Petroleum and Natural Gas & 7" ///
 8 "Mining and Processing of Ferrous Metal Ores & 8" ///
 9 "Mining and Processing of Non-Ferrous Metal Ores & 9" ///
 10 "Mining and Processing of Nonmetallic Mineral & 10" ///
 11 "Mining Support & 11" ///
 12 "Other Mining & 12" ///
 13 "Agricultural and Sideline Food Processing & 13" ///
 14 "Fermentation & 14" ///
 15 "Beverage Manufacturing & 15" ///
 16 "Tobacco Manufacturing & 16" ///
 17 "Textile Mills & 17" ///
 18 "Wearing Apparel and Clothing Accessories Manufacturing & 18" ///
 19 "Leather, Fur and Related Products Manufacturing & 19" ///
 20 "Wood and Bamboo Products Manufacturing & 20" ///
 21 "Furniture Manufacturing & 21" ///
 22 "Products Manufacturing & 22" ///
 23 "Printing and Reproduction of Recorded Media & 23" ///
 24 "Education and Entertainment Articles Manufacturing & 24" ///
 25 "Petrochemicals Manufacturing & 25" ///
 26 "Chemical Products Manufacturing& 26" ///
 27 "Medicine Manufacturing & 27" ///
 28 "Chemical Fibers Manufacturing & 28" ///
 29 "Rubber Products Manufacturing & 29" ///
 30 "Plastic Products Manufacturing & 30" ///
 31 "Non-Metallic Mineral Products Manufacturing & 31" ///
 32 "Iron and Steel Smelting & 32" ///
 33 "Non-Ferrous Metal Smelting & 33" ///
 34 "Fabricated Metal Products Manufacturing & 34" ///
 35 "General Purpose Machinery Manufacturing & 35" ///
 36 "Special Purpose Machinery Manufacturing & 36" ///
 37 "Transport Equipment Manufacturing & 37" ///
 38 "Electrical machinery and equipment Manufacturing & 38" ///
 39 "Electrical Equipment Manufacturing & 39" ///
 40 "Computers and Electronic Products Manufacturing & 40" ///
 41 "General Instruments and Other Equipment Manufacturing & 41" ///
 42 "Craft-works Manufacturing  & 42" ///
 43 "Renewable Materials Recovery & 43" ///
 44 "Electricity and Heat Supply & 44" ///
 45 "Gas Production and Supply & 45" ///
 46 "Water Production and Supply & 46", add
 
label values twodigit twodigit_lb

eststo clear

estpost tabulate twodigit
esttab using "$out_files/TableC5.tex", replace tex cells("b(label(freq)) pct(fmt(2))") varlabels(`e(labels)', blist(Total)) nolines nogaps compress fragment label


**==============================================================================
* Table C6
use "$data_files/Raw/daily_monitor_api.dta", clear

* Construct daily indicators
gen above_100=0 & AQI!=.
replace above_100=1 if AQI>=100 & AQI!=.
gen above_200=0 & AQImax!=.
replace above_200=1 if AQImax>=200 & AQImax!=.

* Collapse data to monthly level
collapse (mean) above_200 pm25api pm10api AQI, by(year month city_id)

* Merge with weather data
merge 1:1 city_id year month using "$data_files/weather_monthly.dta"
keep if _merge == 3
drop _merge

gen quarter = int((month-1)/3)+1
collapse (mean) above_200 pm25api pm10api AQI pre tem_mean, by(year quarter city_id)

* Construct monthly variables
egen time=group(year quarter)
replace pre=. if pre==-9999

bysort city_id: egen med_pre=median(pre) 
gen high_pre=0 if pre!=.
replace high_pre=1 if pre>med_pre & pre!=.
label var high_pre "\$Rain_{>\tilde{x}}$"

gen log_pre=log(pre)
gen log_api25=log(pm25api)
gen log_aqi=log(AQI)
gen log_api10=log(pm10api)

gen tem_meand = int(tem_mean)

* Monthly pollution regressions
reghdfe log_api25 high_pre, absorb(time city_id tem_meand) cluster(city_id)
eststo A
estadd ysumm, mean
estadd scalar EN = e(N_full)
reghdfe log_api10 high_pre, absorb(time city_id  tem_meand) cluster(city_id)
eststo B
estadd ysumm, mean
estadd scalar EN = e(N_full)
reghdfe log_aqi high_pre, absorb(time city_id  tem_meand) cluster(city_id)
eststo C
estadd ysumm, mean
estadd scalar EN = e(N_full)
reghdfe above_200 high_pre if AQI!=., absorb(time city_id  tem_meand) cluster(city_id)
eststo D
estadd ysumm, mean
estadd scalar EN = e(N_full)

esttab A B C D using "$out_files/TableC6.tex", replace b(a2) noconstant se(a2) nolines nogaps compress fragment nonumbers label mlabels(none) collabels() drop(_cons) stats(ymean EN, labels("Mean Outcome" "Observations")) starlevels(* 0.10 ** 0.05 *** 0.01) substitute(\_ _) tex

**==============================================================================
* Table C7
use "$data_files/firm_enf.dta", clear
drop if revenue == .
drop if key == .

label var min_dist_10 "Mon\$\_{<10km}\$"
label var any_air "Any Enforcement (0/1)"
label var post "Post"
label var key "High Pollution"

* Table 
eststo clear
reghdfe any_air c.min_dist_10#c.post1 if min_dist<50 & starty<=2010, absorb(time id industry#time prov_id#time) cluster(city_id)
eststo A
estadd ysumm, mean
estadd scalar EN = e(N_full)
estadd local FirmFE = "Yes"
estadd local ITFE = "Yes"
estadd local PTFE = "Yes"
reghdfe any_water c.min_dist_10#c.post1 if min_dist<50 & starty<=2010, absorb(time id industry#time prov_id#time) cluster(city_id)
eststo B
estadd ysumm, mean
estadd scalar EN = e(N_full)
estadd local FirmFE = "Yes"
estadd local ITFE = "Yes"
estadd local PTFE = "Yes"
reghdfe any_waste c.min_dist_10#c.post1 if min_dist<50 & starty<=2010, absorb(time id industry#time prov_id#time) cluster(city_id)
eststo C
estadd ysumm, mean
estadd scalar EN = e(N_full)
estadd local FirmFE = "Yes"
estadd local ITFE = "Yes"
estadd local PTFE = "Yes"
reghdfe any_proc c.min_dist_10#c.post1 if min_dist<50 & starty<=2010, absorb(time id industry#time prov_id#time) cluster(city_id)
eststo D
estadd ysumm, mean
estadd scalar EN = e(N_full)
estadd local FirmFE = "Yes"
estadd local ITFE = "Yes"
estadd local PTFE = "Yes"
esttab A B C D using "$out_files/TableC7a.tex", replace b(a2) noconstant se(a2) nolines nogaps compress fragment nonumbers label mlabels(none) collabels() keep(c.min_dist_10*) stats(ymean EN FirmFE ITFE PTFE, labels("Mean Outcome" "Observations" "Firm FE" "Industry-Time FE" "Province-Time FE")) starlevels(* 0.10 ** 0.05 *** 0.01) substitute(\_ _) tex

merge m:1 city_id using "$data_files/Raw/city_info.dta", keepusing(disttocoast)
keep if _merge == 3
drop _merge

eststo clear
reghdfe any_air c.min_dist_10#c.post1 if min_dist<50 & starty<=2010, absorb(time id industry#time prov_id#time) cluster(city_id)
eststo A
estadd ysumm, mean
estadd scalar EN = e(N_full)
estadd local FirmFE = "Yes"
estadd local ITFE = "Yes"
estadd local PTFE = "Yes"
estadd local DTFE = "No"
estadd local FCTFE = "No"
estadd local CTFE = "No"
reghdfe any_air c.min_dist_10#c.post1 if min_dist<50 & starty<=2010, absorb(time id industry#time prov_id#time c.disttocoast#time) cluster(city_id)
eststo B
estadd ysumm, mean
estadd scalar EN = e(N_full)
estadd local FirmFE = "Yes"
estadd local ITFE = "Yes"
estadd local PTFE = "Yes"
estadd local DTFE = "Yes"
estadd local FCTFE = "No"
estadd local CTFE = "No"
reghdfe any_air c.min_dist_10#c.post1 if min_dist<50 & starty<=2010, absorb(time id industry#time prov_id#time c.disttocoast#time c.employment#time) cluster(city_id)
eststo C
estadd ysumm, mean
estadd scalar EN = e(N_full)
estadd local FirmFE = "Yes"
estadd local ITFE = "Yes"
estadd local PTFE = "Yes"
estadd local DTFE = "Yes"
estadd local FCTFE = "Yes"
estadd local CTFE = "No"
reghdfe any_air c.min_dist_10#c.post1 if min_dist<50 & starty<=2010, absorb(time id industry#time prov_id#time city_id#time) cluster(city_id)
eststo D
estadd ysumm, mean
estadd scalar EN = e(N_full)
estadd local FirmFE = "Yes"
estadd local ITFE = "Yes"
estadd local PTFE = "No"
estadd local DTFE = "No"
estadd local FCTFE = "Yes"
estadd local CTFE = "Yes"
esttab A B C D using "$out_files/TableC7b.tex", replace b(a2) noconstant se(a2) nolines nogaps compress fragment nonumbers label mlabels(none) collabels() keep(c.min_dist_10*) stats(ymean EN DTFE FCTFE CTFE FirmFE ITFE PTFE, labels("Mean Outcome" "Observations" "Distance to coast-Time FE" "Firm characteristics-Time FE" "City-Time FE" "Firm FE" "Industry-Time FE" "Province-Time FE" )) starlevels(* 0.10 ** 0.05 *** 0.01) substitute(\_ _) tex

**==============================================================================
* Table C8
use "$data_files/Raw/city_info.dta", clear
merge 1:1 city_id using "$data_files/share.dta"
drop if _merge == 2
drop _merge

label variable number "\# Monitors"
label variable number_iv "Min \# Monitors"

regress share_rev_10 number, r
eststo A
estadd ysumm, mean
regress share_emp_10 number, r
eststo B
estadd ysumm, mean
regress share_rev_5 number, r
eststo C
estadd ysumm, mean
regress share_emp_5 number, r
eststo D
estadd ysumm, mean
esttab A B C D using "$out_files/TableC8a.tex", replace b(a2) noconstant se(a2) label nolines nogaps compress fragment nonumbers mlabels(none) collabels() drop(_cons) stats(ymean N, labels("Mean Outcome" "Observations")) starlevels(* 0.10 ** 0.05 *** 0.01) substitute(\_ _) tex

ivregress 2sls share_rev_10 (number = number_iv), r
eststo A
estadd ysumm, mean
ivregress 2sls share_emp_10 (number = number_iv), r
eststo B
estadd ysumm, mean
ivregress 2sls share_rev_5 (number = number_iv), r
eststo C
estadd ysumm, mean
ivregress 2sls share_emp_5 (number = number_iv), r
eststo D
estadd ysumm, mean
esttab A B C D using "$out_files/TableC8b.tex", replace b(a2) noconstant se(a2) label nolines nogaps compress fragment nonumbers mlabels(none) collabels() drop(_cons) stats(ymean N, labels("Mean Outcome" "Observations")) starlevels(* 0.10 ** 0.05 *** 0.01) substitute(\_ _) tex

**==============================================================================
* Table C9
* Robustness: additional controls
use "$data_files/city_pm.dta", clear

label variable post1 "Post" 
label variable number "\# Mon"
label variable number_iv "Min \# Mon"

gen RD_Estimate = c.post1#c.number

eststo clear
reghdfe pm25 RD_Estimate c.post1#c.area c.post1#c.pop, a(city_id year#month pred tem_meand age_year incentive2#time) cluster(city_id)
estadd scalar EN = e(N_full)
eststo A
ivreghdfe pm25 c.post1#c.area c.post1#c.pop (RD_Estimate=c.post1#c.number_iv), a(city_id year#month pred tem_meand age_year incentive2#time) cluster(city_id)
estadd scalar EN = e(N_full)
eststo B
reghdfe pm25 RD_Estimate i.time#c.area i.time#c.pop, a(city_id year#month pred tem_meand age_year incentive2#time) cluster(city_id)
estadd scalar EN = e(N_full)
eststo C
ivreghdfe pm25 i.time#c.area i.time#c.pop i.time#c.background (RD_Estimate=c.post1#c.number_iv), a(city_id year#month pred tem_meand age_year incentive2#time) cluster(city_id)
estadd scalar EN = e(N_full)
eststo D
reghdfe pm25 RD_Estimate i.time#c.area i.time#c.pop i.time#c.background i.time#c.GDP, a(city_id year#month pred tem_meand age_year incentive2#time) cluster(city_id)
estadd scalar EN = e(N_full)
eststo E
ivreghdfe pm25 i.time#c.area i.time#c.pop i.time#c.background i.time#c.GDP (RD_Estimate=c.post1#c.number_iv), a(city_id year#month pred tem_meand age_year incentive2#time) cluster(city_id)
estadd scalar EN = e(N_full)
eststo F
esttab A B C D E F using "$out_files/TableC9a.tex", tex keep(RD_Estimate) transform(@/1, pattern(0 0 0 0)) replace b(a2) se(a2) label noconstant nolines nogaps compress fragment nonumbers mlabels(none) coeflabels(RD_Estimate "\# Monitors") stats(EN, labels( "Observations")) starlevels(* 0.10 ** 0.05 *** 0.01)

use "$data_files/city_enf.dta", clear

label variable post1 "Post"
label variable number "\# Mon"
label variable number_iv "Min \# Mon"

gen RD_Estimate = c.post1#c.number

eststo clear
reghdfe log_any_air RD_Estimate c.post1#c.area c.post1#c.pop, a(city_id year#quarter pred tem_meand age_year incentive2#time) cluster(city_id)
estadd scalar EN = e(N_full)
estadd local CFE = "Yes"
estadd local TTFE = "Yes"
estadd local CSPost = "Yes"
estadd local CSTFE = "No"
estadd local CCTFE = "No"
estadd local Weather = "Yes"
eststo A
ivreghdfe log_any_air c.post1#c.area c.post1#c.pop (RD_Estimate=c.post1#c.number_iv), a(city_id year#quarter pred tem_meand age_year incentive2#time) cluster(city_id)
estadd scalar EN = e(N_full)
estadd local CFE = "Yes"
estadd local TTFE = "Yes"
estadd local CSPost = "Yes"
estadd local CSTFE = "No"
estadd local CCTFE = "No"
estadd local Weather = "Yes"
eststo B
reghdfe log_any_air RD_Estimate i.time#c.area i.time#c.pop, a(city_id year#quarter pred tem_meand age_year incentive2#time) cluster(city_id)
estadd scalar EN = e(N_full)
estadd local CFE = "Yes"
estadd local TTFE = "Yes"
estadd local CSPost = "No"
estadd local CSTFE = "Yes"
estadd local CCTFE = "No"
estadd local Weather = "Yes"
eststo C
ivreghdfe log_any_air i.time#c.area i.time#c.pop (RD_Estimate=c.post1#c.number_iv), a(city_id year#quarter pred tem_meand age_year incentive2#time) cluster(city_id)
estadd scalar EN = e(N_full)
estadd local CFE = "Yes"
estadd local TTFE = "Yes"
estadd local CSPost = "No"
estadd local CSTFE = "Yes"
estadd local CCTFE = "No"
estadd local Weather = "Yes"
eststo D
reghdfe log_any_air RD_Estimate i.time#c.area i.time#c.pop i.time#c.background i.time#c.GDP, a(city_id year#quarter pred tem_meand age_year incentive2#time) cluster(city_id)
estadd scalar EN = e(N_full)
estadd local CFE = "Yes"
estadd local TTFE = "Yes"
estadd local CSPost = "No"
estadd local CSTFE = "Yes"
estadd local CCTFE = "Yes"
estadd local Weather = "Yes"
eststo E
ivreghdfe log_any_air i.time#c.area i.time#c.pop i.time#c.background i.time#c.GDP (RD_Estimate=c.post1#c.number_iv), a(city_id year#quarter pred tem_meand age_year incentive2#time) cluster(city_id)
estadd scalar EN = e(N_full)
estadd local CFE = "Yes"
estadd local TTFE = "Yes"
estadd local CSPost = "No"
estadd local CSTFE = "Yes"
estadd local CCTFE = "Yes"
estadd local Weather = "Yes"
eststo F
esttab A B C D E F using "$out_files/TableC9b.tex", tex keep(RD_Estimate) transform(@/1, pattern(0 0 0 0)) replace b(a2) se(a2) label noconstant nolines nogaps compress fragment nonumbers mlabels(none) coeflabels(RD_Estimate "\# Monitors") stats(EN CFE TTFE CSPost CSTFE CCTFE Weather, labels("Observations" "City FE" "Target-Time FE" "City size $\times$ Post" "City size-Time FE" "City char.-Time FE" "Weather")) starlevels(* 0.10 ** 0.05 *** 0.01)

**==============================================================================
* Table C10
* Robustness: Sample Restriction
use "$data_files/city_pm.dta", clear

gen prov_id = int(city_id/100)
drop if prov_id == 54 | prov_id == 65

label variable post1 "Post" 
label variable number "\# Mon"
label variable number_iv "Min \# Mon"

gen RD_Estimate = c.post1#c.number

reghdfe pm25 RD_Estimate c.post1#c.area c.post1#c.pop, a(city_id year#month pred tem_meand age_year incentive2#time) cluster(city_id)
estadd scalar EN = e(N_full)
eststo A
ivreghdfe pm25 c.post1#c.area c.post1#c.pop (RD_Estimate=c.post1#c.number_iv), a(city_id year#month pred tem_meand age_year incentive2#time) cluster(city_id)
estadd scalar EN = e(N_full)
eststo B  

use "$data_files/city_pm_rd.dta", clear

gen prov_id = int(city_id/100)
drop if prov_id == 54 | prov_id == 65

gen dist1 = area - 20 if cutoff == 1
replace dist1 = area - 50 if cutoff == 2

gen bench = pm25 if year < 2012
bys city_id cutoff: egen mean_bench = mean(bench)

gen above = dist1 > 0
gen RD_Estimate = c.post1#c.above

rdrobust pm25 dist1 if year>=2015, fuzzy(number) p(1) h(11.3) covs(cutoff mean_bench year month) kernel(uni) vce(cluster city_id)
estadd scalar EN = e(N_h_l) + e(N_h_r)
estadd scalar band = e(h_l)
eststo C
reghdfe pm25 RD_Estimate post1 above dist1 c.post1#c.dist1 c.above#c.dist1 c.post#c.above#c.dist1 cutoff if abs(dist1) < 11.3, a(time) cl(city_id)
estadd scalar EN = e(N_full)
estadd scalar band = 11.3
eststo D
esttab A B C D using "$out_files/TableC10a.tex", tex keep(RD_Estimate) transform(@/1.21 1/1.21, pattern(0 0 0 1)) replace b(a2) se(a2) label noconstant nolines nogaps compress fragment nonumbers mlabels(none) coeflabels(RD_Estimate "\# Monitors") stats(EN, labels( "Observations")) starlevels(* 0.10 ** 0.05 *** 0.01)

use "$data_files/city_enf.dta", clear

gen prov_id = int(city_id/100)
drop if prov_id == 54 | prov_id == 65

label variable post1 "Post" 
label variable number "\# Mon"
label variable number_iv "Min \# Mon"

gen RD_Estimate = c.post1#c.number

reghdfe log_any_air RD_Estimate c.post1#c.area c.post1#c.pop, a(city_id year#quarter pred tem_meand age_year incentive2#time) cluster(city_id)
estadd scalar EN = e(N_full)
eststo A
ivreghdfe log_any_air c.post1#c.area c.post1#c.pop (RD_Estimate=c.post1#c.number_iv), a(city_id year#quarter pred tem_meand age_year incentive2#time) cluster(city_id)
estadd scalar EN = e(N_full)
eststo B

use "$data_files/city_enf_rd.dta", clear

gen prov_id = int(city_id/100)
drop if prov_id == 54 | prov_id == 65

gen dist1 = area - 20 if cutoff == 1
replace dist1 = area - 50 if cutoff == 2

gen bench = log_any_air if year < 2012
bys city_id cutoff: egen mean_bench = mean(bench)

gen above = dist1 > 0
gen RD_Estimate = c.post1#c.above

rdrobust log_any_air dist1 if year>=2015, fuzzy(number) p(1) h(11.3) covs(cutoff mean_bench) kernel(uni) vce(cluster city_id)
estadd scalar EN = e(N_h_l) + e(N_h_r)
estadd scalar band = e(h_l)
estadd local kern = "Uniform"
eststo C
reghdfe log_any_air RD_Estimate post1 above dist1 c.post1#c.dist1 c.above#c.dist1 c.post1#c.above#c.dist1 cutoff if abs(dist1) < 11.3, a(time) cl(city_id)
estadd scalar EN = e(N_full)
estadd scalar band = 11.3
estadd local kern = "Uniform"
eststo D
esttab A B C D using "$out_files/TableC10b.tex", tex keep(RD_Estimate) transform(@/1.21 1/1.21, pattern(0 0 0 1)) replace b(a2) se(a2) label noconstant nolines nogaps compress fragment nonumbers mlabels(none) coeflabels(RD_Estimate "\# Monitors") stats(EN kern band, labels("Observations" "Kernel" "Bandwidth")) starlevels(* 0.10 ** 0.05 *** 0.01)


**==============================================================================
* Table C11
* asif vs all
use "$data_files/city_enf.dta", clear

gen log_any_air_total = log(any_air+any_air_rest+1)

label variable post1 "Post" 
label variable number "\# Mon"
label variable number_iv "Min \# Mon"

gen RD_Estimate = c.post1#c.number

reghdfe log_any_air_total RD_Estimate c.post1#c.area c.post1#c.pop, a(city_id year#quarter pred tem_meand age_year incentive2#time) cluster(city_id)
estadd scalar EN = e(N_full)
eststo A
ivreghdfe log_any_air_total c.post1#c.area c.post1#c.pop (RD_Estimate=c.post1#c.number_iv), a(city_id year#quarter pred tem_meand age_year incentive2#time) cluster(city_id)
estadd scalar EN = e(N_full)
eststo B

use "$data_files/city_enf_rd.dta", clear

gen log_any_air_total = log(any_air+any_air_rest+1)

gen dist1 = area - 20 if cutoff == 1
replace dist1 = area - 50 if cutoff == 2

gen bench = log_any_air_total if year < 2012
bys city_id cutoff: egen mean_bench = mean(bench)

gen above = dist1 > 0
gen RD_Estimate = c.post1#c.above

rdrobust log_any_air_total dist1 if year>=2015, fuzzy(number) p(1) h(11.3) covs(cutoff mean_bench year quarter) kernel(uni) vce(cluster city_id)
estadd scalar EN = e(N_h_l) + e(N_h_r)
estadd scalar band = e(h_l)
eststo C
reghdfe log_any_air_total RD_Estimate post1 above dist1 c.post1#c.dist1 c.above#c.dist1 c.post1#c.above#c.dist1 cutoff if abs(dist1) < 11.3, a(time) cl(city_id)
estadd scalar EN = e(N_full)
estadd scalar band = 11.3
eststo D
esttab A B C D using "$out_files/TableC11a.tex", tex keep(RD_Estimate) transform(@/1.21 1/1.21, pattern(0 0 0 1)) replace b(a2) se(a2) label noconstant nolines nogaps compress fragment nonumbers mlabels(none) coeflabels(RD_Estimate "\# Monitors") stats(EN, labels("Observations")) starlevels(* 0.10 ** 0.05 *** 0.01)


use "$data_files/city_enf.dta", clear

gen log_any_air_rest = log(any_air_rest+1)

label variable post1 "Post" 
label variable number "\# Mon"
label variable number_iv "Min \# Mon"

gen RD_Estimate = c.post1#c.number

reghdfe log_any_air_rest RD_Estimate c.post1#c.area c.post1#c.pop, a(city_id year#quarter pred tem_meand age_year incentive2#time) cluster(city_id)
estadd scalar EN = e(N_full)
eststo A
ivreghdfe log_any_air_rest c.post1#c.area c.post1#c.pop (RD_Estimate=c.post1#c.number_iv), a(city_id year#quarter pred tem_meand age_year incentive2#time) cluster(city_id)
estadd scalar EN = e(N_full)
eststo B

use "$data_files/city_enf_rd.dta", clear

gen log_any_air_rest = log(any_air_rest+1)

gen dist1 = area - 20 if cutoff == 1
replace dist1 = area - 50 if cutoff == 2

gen bench = log_any_air_rest if year < 2012
bys city_id cutoff: egen mean_bench = mean(bench)

gen above = dist1 > 0
gen RD_Estimate = c.post1#c.above

rdrobust log_any_air_rest dist1 if year>=2015, fuzzy(number) p(1) h(11.3) covs(cutoff mean_bench year quarter) kernel(uni) vce(cluster city_id)
estadd scalar EN = e(N_h_l) + e(N_h_r)
estadd scalar band = e(h_l)
eststo C
reghdfe log_any_air_rest RD_Estimate post1 above dist1 c.post1#c.dist1 c.above#c.dist1 c.post1#c.above#c.dist1 cutoff if abs(dist1) < 11.3, a(time) cl(city_id)
estadd scalar EN = e(N_full)
estadd scalar band = 11.3
eststo D
esttab A B C D using "$out_files/TableC11b.tex", tex keep(RD_Estimate) transform(@/1.21 1/1.21, pattern(0 0 0 1)) replace b(a2) se(a2) label noconstant nolines nogaps compress fragment nonumbers mlabels(none) coeflabels(RD_Estimate "\# Monitors") stats(EN, labels("Observations")) starlevels(* 0.10 ** 0.05 *** 0.01)


**==============================================================================
* Table C12
* kernel and covs
use "$data_files/city_pm_rd.dta", clear

gen dist1 = area - 20 if cutoff == 1
replace dist1 = area - 50 if cutoff == 2

gen bench = pm25 if year < 2012
bys city_id: egen mean_bench = mean(bench)

eststo clear
rdrobust pm25 dist1 if year>=2015, fuzzy(number) p(1) h(11.3) covs(cutoff mean_bench year month) kernel(uni) vce(cluster city_id)
estadd scalar EN = e(N_h_l) + e(N_h_r)
estadd scalar band = e(h_l)
eststo A
rdrobust pm25 dist1 if year>=2015, fuzzy(number) p(1) covs(cutoff mean_bench year month) kernel(tri) vce(cluster city_id)
estadd scalar EN = e(N_h_l) + e(N_h_r)
estadd scalar band = e(h_l)
eststo B
rdrobust pm25 dist1 if year>=2015, fuzzy(number) p(1) covs(cutoff mean_bench year month) kernel(epa) vce(cluster city_id)
estadd scalar EN = e(N_h_l) + e(N_h_r)
estadd scalar band = e(h_l)
eststo C
rdrobust pm25 dist1 if year>=2015, fuzzy(number) p(1) covs() kernel(uni) vce(cluster city_id)
estadd scalar EN = e(N_h_l) + e(N_h_r)
estadd scalar band = e(h_l)
eststo D
esttab A B C D using "$out_files/TableC12a1.tex", tex keep(RD_Estimate) replace b(a2) se(a2) label noconstant nolines nogaps compress fragment nonumbers mlabels(none) coeflabels(RD_Estimate "\# Monitors") stats(EN band, labels("Observations" "Bandwidth")) starlevels(* 0.10 ** 0.05 *** 0.01)

eststo clear
rdrobust number dist1 if year>=2015, p(1) h(11.3) covs(cutoff) kernel(uni) vce(cluster city_id)
eststo A
rdrobust number dist1 if year>=2015, p(1) h(12.3) covs(cutoff) kernel(tri) vce(cluster city_id)
eststo B
rdrobust number dist1 if year>=2015, p(1) h(12.5) covs(cutoff) kernel(epa) vce(cluster city_id)
eststo C
rdrobust number dist1 if year>=2015, p(1) h(13.8) covs() kernel(uni) vce(cluster city_id)
eststo D
esttab A B C D using "$out_files/TableC12a2.tex", tex replace b(a2) se(a2) label noconstant nolines nogaps compress fragment nonumbers noobs mlabels(none) keep(RD_Estimate) coeflabels(RD_Estimate "First stage") starlevels(* 0.10 ** 0.05 *** 0.01)

use "$data_files/city_enf_rd.dta", clear

gen dist1 = area - 20 if cutoff == 1
replace dist1 = area - 50 if cutoff == 2

gen dist2 = pop - 25 if cutoff == 1
replace dist2 = pop - 50 if cutoff == 2

gen bench = log_any_air if year < 2012
bys city_id: egen mean_bench = mean(bench)

gen above = dist1 > 0
gen RD_Estimate = c.post1#c.above

eststo clear
rdrobust log_any_air dist1 if year>=2015, fuzzy(number) p(1) h(11.3) covs(cutoff mean_bench year quarter) kernel(uni) vce(cluster city_id)
estadd scalar EN = e(N_h_l) + e(N_h_r)
estadd scalar band = e(h_l)
eststo A
rdrobust log_any_air dist1 if year>=2015, fuzzy(number) p(1) covs(cutoff mean_bench year quarter) kernel(tri) vce(cluster city_id)
estadd scalar EN = e(N_h_l) + e(N_h_r)
estadd scalar band = e(h_l)
eststo B
rdrobust log_any_air dist1 if year>=2015, fuzzy(number) p(1) covs(cutoff mean_bench year quarter) kernel(epa) vce(cluster city_id)
estadd scalar EN = e(N_h_l) + e(N_h_r)
estadd scalar band = e(h_l)
eststo C
rdrobust log_any_air dist1 if year>=2015, fuzzy(number) p(1) covs() kernel(uni) vce(cluster city_id)
estadd scalar EN = e(N_h_l) + e(N_h_r)
estadd scalar band = e(h_l)
eststo D
esttab A B C D using "$out_files/TableC12b1.tex", tex keep(RD_Estimate) replace b(a2) se(a2) label noconstant nolines nogaps compress fragment nonumbers mlabels(none) coeflabels(RD_Estimate "\# Monitors") stats(EN band, labels("Observations" "Bandwidth")) starlevels(* 0.10 ** 0.05 *** 0.01)

eststo clear
rdrobust number dist1 if year>=2015, p(1) h(11.3) covs(cutoff) kernel(uni) vce(cluster city_id)
eststo A
estadd local kern = "Uniform"
estadd local cov = "Yes"
rdrobust number dist1 if year>=2015, p(1) h(13.1) covs(cutoff) kernel(tri) vce(cluster city_id)
eststo B
estadd local kern = "Epanechnikov"
estadd local cov = "Yes"
rdrobust number dist1 if year>=2015, p(1) h(12.5) covs(cutoff) kernel(epa) vce(cluster city_id)
eststo C
estadd local kern = "Triangle"
estadd local cov = "Yes"
rdrobust number dist1 if year>=2015, p(1) h(11.4) covs() kernel(uni) vce(cluster city_id)
eststo D
estadd local kern = "Uniform"
estadd local cov = "No"
esttab A B C D using "$out_files/TableC12b2.tex", tex replace b(a2) se(a2) label noconstant nolines nogaps compress fragment nonumbers noobs mlabels(none) keep(RD_Estimate) coeflabels(RD_Estimate "First stage") stats(kern cov, labels("Kernel" "Covariates")) starlevels(* 0.10 ** 0.05 *** 0.01)


**==============================================================================
* Table C13
* Cutoff 1
use "$data_files/city_pm.dta", clear

gen dist1 = area - 20

gen bench = pm25 if year < 2012
bys city_id: egen mean_bench = mean(bench)

gen above = dist1 > 0
gen RD_Estimate = c.post1#c.above

eststo clear
rdrobust pm25 dist1 if year>=2015, fuzzy(number) p(1) h(11.3) covs(mean_bench year quarter) kernel(uni) vce(cluster city_id)
estadd scalar EN = e(N_h_l) + e(N_h_r)
estadd scalar band = e(h_l)
eststo A
reghdfe pm25 RD_Estimate post1 above dist1 c.post1#c.dist1 c.above#c.dist1 c.post#c.above#c.dist1 if abs(dist1) < 11.3, a(year#month) cl(city_id)
estadd scalar EN = e(N_full)
estadd scalar band = 11.3
eststo B

use "$data_files/city_enf.dta", clear

gen dist1 = area - 20

gen bench = log_any_air if year < 2012
bys city_id: egen mean_bench = mean(bench)

gen above = dist1 > 0
gen RD_Estimate = c.post1#c.above

rdrobust log_any_air dist1 if year>=2015, fuzzy(number) p(1) h(11.3) covs(mean_bench year quarter) kernel(uni) vce(cluster city_id)
estadd scalar EN = e(N_h_l) + e(N_h_r)
estadd scalar band = e(h_l)
eststo C
reghdfe log_any_air RD_Estimate post1 above dist1 c.post1#c.dist1 c.above#c.dist1 c.post1#c.above#c.dist1 if abs(dist1) < 11.3, a(time) cl(city_id)
estadd scalar EN = e(N_full)
estadd scalar band = 11.3
eststo D
esttab A B C D using "$out_files/TableC13a1.tex", tex keep(RD_Estimate) transform(@/0.79 1/0.79, pattern(0 1 0 1)) replace b(a2) se(a2) label noconstant nolines nogaps compress fragment nonumbers mlabels(none) coeflabels(RD_Estimate "\# Monitors") stats(EN band, labels("Observations" "Bandwidth")) starlevels(* 0.10 ** 0.05 *** 0.01)

eststo clear
rdrobust number dist1 if year>=2015, p(1) h(11.3) kernel(uni) vce(cluster city_id)
eststo A
rdrobust number dist1 if year>=2015, p(1) h(11.3) kernel(uni) vce(cluster city_id)
eststo B
rdrobust number dist1 if year>=2015, p(1) h(11.3) kernel(uni) vce(cluster city_id)
eststo C
rdrobust number dist1 if year>=2015, p(1) h(11.3) covs() kernel(uni) vce(cluster city_id)
eststo D
esttab A B C D using "$out_files/TableC13a2.tex", tex replace b(a2) se(a2) label noconstant nolines nogaps compress fragment nonumbers noobs mlabels(none) keep(RD_Estimate) coeflabels(RD_Estimate "First stage") starlevels(* 0.10 ** 0.05 *** 0.01)

* Cutoff 2
use "$data_files/city_pm.dta", clear

gen dist1 = area - 50

gen bench = pm25 if year < 2012
bys city_id: egen mean_bench = mean(bench)

gen above = dist1 > 0
gen RD_Estimate = c.post1#c.above

eststo clear
rdrobust pm25 dist1 if year>=2015, fuzzy(number) p(1) h(11.3) covs(mean_bench year month) kernel(uni) vce(cluster city_id)
estadd scalar EN = e(N_h_l) + e(N_h_r)
estadd scalar band = e(h_l)
eststo A
reghdfe pm25 RD_Estimate post1 above dist1 c.post1#c.dist1 c.above#c.dist1 c.post#c.above#c.dist1 if abs(dist1) < 11.3, a(time) cl(city_id)
estadd scalar EN = e(N_full)
estadd scalar band = 11.3
eststo B

use "$data_files/city_enf.dta", clear

gen dist1 = area - 50

gen bench = log_any_air if year < 2012
bys city_id: egen mean_bench = mean(bench)

gen above = dist1 > 0
gen RD_Estimate = c.post1#c.above

rdrobust log_any_air dist1 if year>=2015, fuzzy(number) p(1) h(11.3) covs(mean_bench year quarter) kernel(uni) vce(cluster city_id)
estadd scalar EN = e(N_h_l) + e(N_h_r)
estadd scalar band = e(h_l)
eststo C
reghdfe log_any_air RD_Estimate post1 above dist1 c.post1#c.dist1 c.above#c.dist1 c.post1#c.above#c.dist1 if abs(dist1) < 11.3, a(time) cl(city_id)
estadd scalar EN = e(N_full)
estadd scalar band = 11.3
eststo D
esttab A B C D using "$out_files/TableC13b1.tex", tex keep(RD_Estimate) transform(@/1.76 1/1.76, pattern(0 1 0 1)) replace b(a2) se(a2) label noconstant nolines nogaps compress fragment nonumbers mlabels(none) coeflabels(RD_Estimate "\# Monitors") stats(EN band, labels("Observations" "Bandwidth")) starlevels(* 0.10 ** 0.05 *** 0.01)

eststo clear
rdrobust number dist1 if year>=2015, p(1) h(11.3) kernel(uni) vce(cluster city_id)
eststo A
estadd local kern = "Uniform"
estadd scalar band = 11.3
rdrobust number dist1 if year>=2015, p(1) h(11.3) kernel(uni) vce(cluster city_id)
eststo B
estadd local kern = "Uniform"
estadd scalar band = 11.3
rdrobust number dist1 if year>=2015, p(1) h(11.3) kernel(uni) vce(cluster city_id)
eststo C
estadd local kern = "Uniform"
estadd scalar band = 11.3
rdrobust number dist1 if year>=2015, p(1) h(11.3) covs() kernel(uni) vce(cluster city_id)
eststo D
estadd local kern = "Uniform"
estadd local band = 11.3
esttab A B C D using "$out_files/TableC13b2.tex", tex replace b(a2) se(a2) label noconstant nolines nogaps compress fragment nonumbers noobs mlabels(none) keep(RD_Estimate) coeflabels(RD_Estimate "First stage") stats(kern band, labels("Kernel" "Bandwidth")) starlevels(* 0.10 ** 0.05 *** 0.01)


**==============================================================================
* Table C14
* Spillover in aod
use "$data_files/city_pm_rd.dta", clear

rename pm pm_monitor
drop if pm_monitor == .
drop if pm_direct == .
drop if pm_indirect == .

gen dist1 = area - 20 if cutoff == 1
replace dist1 = area - 50 if cutoff == 2

gen bench_monitor = pm_monitor if year < 2012
bys city_id cutoff: egen mean_bench_monitor = mean(bench_monitor)

gen RD_Estimate = .
gen above = dist1 > 0

replace RD_Estimate = c.post1#c.number
eststo clear
reghdfe pm_monitor RD_Estimate c.post1#c.area c.post1#c.pop if cutoff == 1, a(city_id year#month pred tem_meand age_year incentive2#time) cluster(city_id)
eststo A
summ pm_monitor
estadd scalar ysumm = r(mean)
estadd scalar EN = e(N_full)
ivreghdfe pm_monitor c.post1#c.area c.post1#c.pop (RD_Estimate=c.post1#c.number_iv) if cutoff == 1, a(city_id year#month pred tem_meand age_year incentive2#time) cluster(city_id)
eststo B
summ pm_monitor
estadd scalar ysumm = r(mean)
estadd scalar EN = e(N_full)
rdrobust pm_monitor dist1 if year>=2015, fuzzy(number) p(1) h(11.3) covs(cutoff mean_bench_monitor year month) kernel(uni) vce(cluster city_id)
estadd scalar EN = e(N_h_l) + e(N_h_r)
summ pm_monitor if abs(dist1)<11.3
estadd scalar ysumm = r(mean)
eststo C
replace RD_Estimate = c.post1#c.above
reghdfe pm_monitor RD_Estimate post1 above dist1 c.post1#c.dist1 c.above#c.dist1 c.post#c.above#c.dist1 cutoff if abs(dist1) < 11.3, a(time) cl(city_id)
estadd scalar EN = e(N)
summ pm_monitor if abs(dist1)<11.3
estadd scalar ysumm = r(mean)
eststo D
esttab A B C D using "$out_files/TableC14a.tex", keep(RD_Estimate) transform(@/1.21 1/1.21, pattern(0 0 0 1)) replace b(a2) se(a2) label noconstant nolines nogaps compress fragment nonumbers mlabels(none) coeflabels(RD_Estimate "\# Monitors") stats(EN ysumm, labels("Observations" "Mean Outcome")) starlevels(* 0.10 ** 0.05 *** 0.01) tex

use "$data_files/city_pm_rd.dta", clear

rename pm pm_monitor
drop if pm_monitor == .
drop if pm_direct == .
drop if pm_indirect == .

gen dist1 = area - 20 if cutoff == 1
replace dist1 = area - 50 if cutoff == 2

gen bench_dir = pm_direct if year < 2012
bys city_id cutoff: egen mean_bench_dir = mean(bench_dir)

gen bench_in = pm_indirect if year < 2012
bys city_id cutoff: egen mean_bench_in = mean(bench_in)

gen RD_Estimate = .
gen above = dist1 > 0

replace RD_Estimate = c.post1#c.number
eststo clear
reghdfe pm_direct RD_Estimate c.post1#c.area c.post1#c.pop if cutoff == 1, a(city_id year#month pred tem_meand age_year incentive2#time) cluster(city_id)
eststo A
summ pm_direct
estadd scalar ysumm = r(mean)
estadd scalar EN = e(N_full)
ivreghdfe pm_direct c.post1#c.area c.post1#c.pop (RD_Estimate=c.post1#c.number_iv) if cutoff == 1, a(city_id year#month pred tem_meand age_year incentive2#time) cluster(city_id)
eststo B
summ pm_direct
estadd scalar ysumm = r(mean)
estadd scalar EN = e(N_full)
rdrobust pm_direct dist1 if year>=2015, fuzzy(number) p(1) h(11.3) covs(cutoff mean_bench_dir year month) kernel(uni) vce(cluster city_id)
estadd scalar EN = e(N_h_l) + e(N_h_r)
summ pm_direct if abs(dist1) < 11.3
estadd scalar ysumm = r(mean)
eststo C
replace RD_Estimate = c.post1#c.above
reghdfe pm_direct RD_Estimate post1 above dist1 c.post1#c.dist1 c.above#c.dist1 c.post#c.above#c.dist1 cutoff if abs(dist1) < 11.3, a(time) cl(city_id)
estadd scalar EN = e(N)
summ pm_direct if abs(dist1) < 11.3
estadd scalar ysumm = r(mean)
eststo D
esttab A B C D using "$out_files/TableC14b.tex", keep(RD_Estimate) transform(@/1.21 1/1.21, pattern(0 0 0 1)) replace b(a2) se(a2) label noconstant nolines nogaps compress fragment nonumbers mlabels(none) coeflabels(RD_Estimate "\# Monitors") stats(EN ysumm, labels("Observations" "Mean Outcome")) starlevels(* 0.10 ** 0.05 *** 0.01) tex

replace RD_Estimate = c.post1#c.number
eststo clear
reghdfe pm_indirect RD_Estimate c.post1#c.area c.post1#c.pop if cutoff == 1, a(city_id year#month pred tem_meand age_year incentive2#time) cluster(city_id)
eststo A
summ pm_indirect
estadd scalar ysumm = r(mean)
estadd scalar EN = e(N_full)
ivreghdfe pm_indirect c.post1#c.area c.post1#c.pop pre tem_mean (RD_Estimate=c.post1#c.number_iv) if cutoff == 1, a(city_id year#month pred tem_meand age_year incentive2#time) cluster(city_id)
eststo B
summ pm_indirect
estadd scalar ysumm = r(mean)
estadd scalar EN = e(N_full)
rdrobust pm_indirect dist1 if year>=2015, fuzzy(number) p(1) h(11.3) covs(cutoff mean_bench_in year month) kernel(uni) vce(cluster city_id)
estadd scalar EN = e(N_h_l) + e(N_h_r)
summ pm_indirect if abs(dist1) < 11.3
estadd scalar ysumm = r(mean)
eststo C
replace RD_Estimate = c.post1#c.above
reghdfe pm_indirect RD_Estimate post1 above dist1 c.post1#c.dist1 c.above#c.dist1 c.post#c.above#c.dist1 cutoff if abs(dist1) < 11.3, a(time) cl(city_id)
summ pm_indirect if abs(dist1) < 11.3
estadd scalar ysumm = r(mean)
estadd scalar EN = e(N)
eststo D
esttab A B C D using "$out_files/TableC14c.tex", keep(RD_Estimate) transform(@/1.21 1/1.21, pattern(0 0 0 1)) replace b(a2) se(a2) label noconstant nolines nogaps compress fragment nonumbers mlabels(none) coeflabels(RD_Estimate "\# Monitors") stats(EN ysumm, labels("Observations" "Mean Outcome")) starlevels(* 0.10 ** 0.05 *** 0.01) tex

* Spillover in enf
use "$data_files/city_enf.dta", clear

label variable post1 "Post"
label variable number "\# Mon"
label variable number_iv "Min \# Mon"

gen RD_Estimate = c.post1#c.number

eststo clear
reghdfe log_any_air_10 RD_Estimate c.post1#c.area c.post1#c.pop, a(city_id year#quarter pred tem_meand age_year incentive2#time) cluster(city_id)
summ log_any_air_10
estadd scalar ysumm = r(mean)
estadd scalar EN = e(N_full)
eststo A
ivreghdfe log_any_air_10 c.post1#c.area c.post1#c.pop (RD_Estimate=c.post1#c.number_iv), a(city_id year#quarter pred tem_meand age_year incentive2#time) cluster(city_id)
summ log_any_air_10
estadd scalar ysumm = r(mean)
estadd scalar EN = e(N_full)
eststo B

use "$data_files/city_enf_rd.dta", clear

gen dist1 = area - 20 if cutoff == 1
replace dist1 = area - 50 if cutoff == 2

gen bench_10 = log_any_air_10 if year < 2012
bys city_id cutoff: egen mean_bench_10 = mean(bench_10)

gen above = dist1 > 0
gen RD_Estimate = c.post1#c.above

rdrobust log_any_air_10 dist1 if year>=2015, fuzzy(number) p(1) h(11.3) covs(cutoff mean_bench_10 year quarter) kernel(uni) vce(cluster city_id)
summ log_any_air_10 if abs(dist1)<11.3
estadd scalar ysumm = r(mean)
estadd scalar EN = e(N_h_l) + e(N_h_r)
estadd scalar band = e(h_l)
eststo C
reghdfe log_any_air_10 RD_Estimate post1 above dist1 c.post1#c.dist1 c.above#c.dist1 c.post1#c.above#c.dist1 cutoff if abs(dist1) < 11.3, a(time) cl(city_id)
summ log_any_air_10 if abs(dist1)<11.3
estadd scalar ysumm = r(mean)
estadd scalar EN = e(N)
estadd scalar band = 11.3
eststo D
esttab A B C D using "$out_files/TableC14d.tex", keep(RD_Estimate) transform(@/1.21 1/1.21, pattern(0 0 0 1)) replace b(a2) se(a2) label noconstant nolines nogaps compress fragment nonumbers mlabels(none) coeflabels(RD_Estimate "\# Monitors") stats(EN ysumm, labels("Observations" "Mean Outcome")) starlevels(* 0.10 ** 0.05 *** 0.01) tex


use "$data_files/city_enf.dta", clear

label variable post1 "Post"
label variable number "\# Mon"
label variable number_iv "Min \# Mon"

gen RD_Estimate = c.post1#c.number

eststo clear
reghdfe log_any_air_20 RD_Estimate c.post1#c.area c.post1#c.pop, a(city_id year#quarter pred tem_meand age_year incentive2#time) cluster(city_id)
summ log_any_air_20
estadd scalar ysumm = r(mean)
estadd scalar EN = e(N_full)
eststo A
ivreghdfe log_any_air_20 c.post1#c.area c.post1#c.pop (RD_Estimate=c.post1#c.number_iv), a(city_id year#quarter pred tem_meand age_year incentive2#time) cluster(city_id)
summ log_any_air_20
estadd scalar ysumm = r(mean)
estadd scalar EN = e(N_full)
eststo B

use "$data_files/city_enf_rd.dta", clear

gen dist1 = area - 20 if cutoff == 1
replace dist1 = area - 50 if cutoff == 2

gen bench_20 = log_any_air_20 if year < 2012
bys city_id cutoff: egen mean_bench_20 = mean(bench_20)

gen above = dist1 > 0
gen RD_Estimate = c.post1#c.above

rdrobust log_any_air_20 dist1 if year>=2015, fuzzy(number) p(1) h(11.3) covs(cutoff mean_bench_20 year quarter) kernel(uni) vce(cluster city_id)
summ log_any_air_20 if abs(dist1)<11.3
estadd scalar ysumm = r(mean)
estadd scalar EN = e(N_h_l) + e(N_h_r)
estadd scalar band = e(h_l)
eststo C
reghdfe log_any_air_20 RD_Estimate post1 above dist1 c.post1#c.dist1 c.above#c.dist1 c.post1#c.above#c.dist1 cutoff if abs(dist1) < 11.3, a(time) cl(city_id)
summ log_any_air_20 if abs(dist1)<11.3
estadd scalar ysumm = r(mean)
estadd scalar EN = e(N)
estadd scalar band = 11.3
eststo D
esttab A B C D using "$out_files/TableC14e.tex", keep(RD_Estimate) transform(@/1.21 1/1.21, pattern(0 0 0 1)) replace b(a2) se(a2) label noconstant nolines nogaps compress fragment nonumbers mlabels(none) coeflabels(RD_Estimate "\# Monitors") stats(EN ysumm, labels("Observations" "Mean Outcome")) starlevels(* 0.10 ** 0.05 *** 0.01) tex

use "$data_files/city_enf.dta", clear

label variable post1 "Post"
label variable number "\# Mon"
label variable number_iv "Min \# Mon"

gen RD_Estimate = c.post1#c.number

eststo clear
reghdfe log_any_air_50 RD_Estimate c.post1#c.area c.post1#c.pop, a(city_id pred tem_meand age_year incentive2#time) cluster(city_id)
summ log_any_air_50
estadd scalar ysumm = r(mean)
estadd scalar EN = e(N_full)
eststo A
ivreghdfe log_any_air_50 c.post1#c.area c.post1#c.pop (RD_Estimate=c.post1#c.number_iv), a(city_id pred tem_meand age_year incentive2#time) cluster(city_id)
summ log_any_air_50
estadd scalar ysumm = r(mean)
estadd scalar EN = e(N_full)
eststo B

use "$data_files/city_enf_rd.dta", clear

gen dist1 = area - 20 if cutoff == 1
replace dist1 = area - 50 if cutoff == 2

gen bench_50 = log_any_air_50 if year < 2012
bys city_id cutoff: egen mean_bench_50 = mean(bench_50)

gen above = dist1 > 0
gen RD_Estimate = c.post1#c.above

rdrobust log_any_air_50 dist1 if year>=2015, fuzzy(number) p(1) h(11.3) covs(cutoff mean_bench_50 year quarter) kernel(uni) vce(cluster city_id)
summ log_any_air_50 if abs(dist1)<11.3
estadd scalar ysumm = r(mean)
estadd scalar EN = e(N_h_l) + e(N_h_r)
estadd local kern = "Uniform"
estadd scalar band = 11.3
eststo C
reghdfe log_any_air_50 RD_Estimate post1 above dist1 c.post1#c.dist1 c.above#c.dist1 c.post1#c.above#c.dist1 cutoff if abs(dist1) < 11.3, a(time) cl(city_id)
summ log_any_air_50 if abs(dist1)<11.3
estadd scalar ysumm = r(mean)
estadd scalar EN = e(N)
estadd local kern = "Uniform"
estadd scalar band = 11.3
eststo D
esttab A B C D using "$out_files/TableC14f.tex", keep(RD_Estimate) transform(@/1.21 1/1.21, pattern(0 0 0 1)) replace b(a2) se(a2) label noconstant nolines nogaps compress fragment nonumbers mlabels(none) coeflabels(RD_Estimate "\# Monitors") stats(EN ysumm kern band, labels("Observations" "Mean Outcome" "Kernel" "Bandwidth")) starlevels(* 0.10 ** 0.05 *** 0.01) tex


**==============================================================================
* Table C15
* Promotion
use "$data_files/city_pm.dta", clear

label variable post1 "Post" 
label variable number "\# Mon"
label variable number_iv "Min \# Mon"

gen above57 = age<=57
gen RD_Estimate = c.post1#c.number
label variable above57 "Below 58"

eststo clear
reghdfe pm25 RD_Estimate c.post1#c.area c.post1#c.pop c.RD_Estimate#c.above57, a(city_id year#month pred tem_meand age_year incentive2#time) cluster(city_id)
eststo A
estadd ysumm, mean
estadd scalar EN = e(N_full)
reghdfe pm25 RD_Estimate c.post1#c.area c.post1#c.pop c.RD_Estimate#c.above57 if age >= 51 & age <= 62, a(city_id year#month pred tem_meand age_year incentive2#time) cluster(city_id)
eststo B
estadd ysumm, mean
estadd scalar EN = e(N_full)
reghdfe pm25 RD_Estimate c.post1#c.area c.post1#c.pop c.RD_Estimate#c.above57 if age >= 53 & age <= 62, a(city_id year#month pred tem_meand age_year incentive2#time) cluster(city_id)
eststo C
estadd ysumm, mean
estadd scalar EN = e(N_full)
reghdfe pm25 RD_Estimate c.post1#c.area c.post1#c.pop c.RD_Estimate#c.above57 if age >= 55 & age <= 60, a(city_id year#month pred tem_meand age_year incentive2#time) cluster(city_id)
eststo D
estadd ysumm, mean
estadd scalar EN = e(N_full)
esttab A B C D  using "$out_files/TableC15a.tex", replace b(a2) noconstant se(a2) nolines nogaps compress fragment nonumbers label mlabels(none) collabels() keep(RD_Estimate c.RD_Estimate#c.above57) coeflabels(RD_Estimate "\# Monitors" c.RD_Estimate#c.above57 "\# Monitors $\times$ Below 58") stats(ymean EN, labels("Mean Outcome" "Observations")) starlevels(* 0.10 ** 0.05 *** 0.01) substitute(\_ _) tex

use "$data_files/city_enf.dta", clear

label variable post1 "Post" 
label variable number "\# Mon"
label variable number_iv "Min \# Mon"

gen above57 = age <= 57
gen RD_Estimate = c.post1#c.number
label variable above57 "Below 58"

eststo clear
reghdfe log_any_air RD_Estimate c.post1#c.area c.post1#c.pop c.RD_Estimate#c.above57, a(city_id year#quarter pred tem_meand age_year incentive2#time) cluster(city_id)
eststo A
estadd ysumm, mean
estadd scalar EN = e(N_full)
reghdfe log_any_air RD_Estimate c.post1#c.area c.post1#c.pop c.RD_Estimate#c.above57 if age >= 51 & age <= 62, a(city_id year#quarter pred tem_meand age_year incentive2#time) cluster(city_id)
eststo B
estadd ysumm, mean
estadd scalar EN = e(N_full)
reghdfe log_any_air RD_Estimate c.post1#c.area c.post1#c.pop c.RD_Estimate#c.above57 if age >= 53 & age <= 62, a(city_id year#quarter pred tem_meand age_year incentive2#time) cluster(city_id)
eststo C
estadd ysumm, mean
estadd scalar EN = e(N_full)
reghdfe log_any_air RD_Estimate c.post1#c.area c.post1#c.pop c.RD_Estimate#c.above57 if age >= 55 & age <= 60, a(city_id year#quarter pred tem_meand age_year incentive2#time) cluster(city_id)
eststo D
estadd ysumm, mean
estadd scalar EN = e(N_full)
esttab A B C D using "$out_files/TableC15b.tex", replace b(a2) noconstant se(a2) nolines nogaps compress fragment nonumbers label mlabels(none) collabels() keep(RD_Estimate c.RD_Estimate#c.above57) coeflabels(RD_Estimate "\# Monitors" c.RD_Estimate#c.above57 "\# Monitors $\times$ Below 58") stats(ymean EN, labels("Mean Outcome" "Observations")) starlevels(* 0.10 ** 0.05 *** 0.01) substitute(\_ _) tex


**==============================================================================
* Table C16
* Balance
use "$data_files/city_pm.dta", clear
keep if year < 2015

replace light = log(light)
gen log_any_air = log(any_air+1)

collapse (mean) pm25 light log_any_air number area pop age city_id, by(city_cn)
gen above57 = age > 57

label variable number "\# Monitors"
label variable area "Size of buildup area"
label variable pop "Urban population"
label variable pm25 "AOD before 2015"
label variable light "Night light before 2015"
label variable log_any_air "log(\# Firms) before 2015"

regress above57 number area pop pm25 light log_any_air
test number area pop pm25 light log_any_air
regress above57 number area pop pm25 light log_any_air if age >= 51 & age <= 62
test number area pop pm25 light log_any_air
regress above57 number area pop pm25 light log_any_air if age >= 53 & age <= 62
test number area pop pm25 light log_any_air
regress above57 number area pop pm25 light log_any_air if age >= 55 & age <= 60
test number area pop pm25 light log_any_air

eststo clear
eststo tot: estpost summarize number area pop pm25 light log_any_air
eststo treat1: estpost summarize number area pop pm25 light log_any_air if above57==1
eststo control1: estpost summarize number area pop pm25 light log_any_air if above57==0
eststo diff1: estpost ttest number area pop pm25 light log_any_air, by(above57)
eststo diff1: estadd scalar pvalue = 0.19
eststo diff2: estpost ttest number area pop pm25 light log_any_air if age >= 51 & age <= 62, by(above57)
eststo diff2: estadd scalar pvalue = 0.15
eststo diff3: estpost ttest number area pop pm25 light log_any_air if age >= 53 & age <= 62, by(above57)
eststo diff3: estadd scalar pvalue = 0.29
eststo diff4: estpost ttest number area pop pm25 light log_any_air if age >= 55 & age <= 60, by(above57)
eststo diff4: estadd scalar pvalue = 0.37
esttab tot treat1 control1 diff1 diff2 diff3 diff4 using "$out_files/TableC16.tex", tex label noconstant nolines nogaps compress fragment nonumbers mlabels(,none) collabels(,none) cells(mean(pattern(1 1 1 0 0 0 0) fmt(a2)) & b(star pattern(0 0 0 1 1 1 1) fmt(a2)) sd(pattern(1 1 1 0 0 0 0) fmt(a2) par) & se(pattern(0 0 0 1 1 1 1) fmt(a2) par)) stats(N pvalue, labels("Observations" "Joint Test (p-value)")) starlevels(* 0.10 ** 0.05 *** 0.01) replace


**==============================================================================
* Table C17

use "$data_files/city_pm.dta", clear
label variable post1 "Post" 
label variable number "\# Mon"
label variable number_iv "Min \# Mon"

merge 1:1 city_cn year month using "$data_files/Raw/baidu.dta" 
keep if _merge == 3
drop _merge

replace sear_freq_w1 = sear_freq_w1/pop
replace sear_freq_w2 = sear_freq_w2/pop
replace sear_freq_w3 = sear_freq_w3/pop
replace sear_freq_w4 = sear_freq_w4/pop
replace sear_freq_w5 = sear_freq_w5/pop

foreach x of varlist sear_freq_w* {
	egen m_`x' = mean(`x')
	egen sd_`x' = sd(`x')
	gen std_`x' = (`x'- m_`x')/sd_`x'
}

forvalues i=1/5 {
replace sear_freq_w`i'=0 if sear_freq_w`i'==.
gen log_w`i'=log(sear_freq_w`i'+1)
gen any_w`i'=0
replace any_w`i'=1 if sear_freq_w`i'>0 & sear_freq_w`i'!=.
}

eststo clear 
ivreghdfe log_w1 i.time#c.area i.time#c.pop (c.post1#c.number=c.post1#c.number_iv), a(city_id year#month pred tem_meand age_year incentive2#time) cluster(city_id)
eststo A
summ log_w1
estadd scalar ymean = r(mean)
ivreghdfe log_w2 i.time#c.area i.time#c.pop (c.post1#c.number=c.post1#c.number_iv), a(city_id year#month pred tem_meand age_year incentive2#time) cluster(city_id)
eststo B
summ log_w2
estadd scalar ymean = r(mean)
ivreghdfe log_w3 i.time#c.area i.time#c.pop (c.post1#c.number=c.post1#c.number_iv), a(city_id year#month pred tem_meand age_year incentive2#time) cluster(city_id)
eststo C
summ log_w3
estadd scalar ymean = r(mean)
ivreghdfe log_w4 i.time#c.area i.time#c.pop (c.post1#c.number=c.post1#c.number_iv), a(city_id year#month pred tem_meand age_year incentive2#time) cluster(city_id)
eststo D
summ log_w4
estadd scalar ymean = r(mean)
ivreghdfe log_w5 i.time#c.area i.time#c.pop (c.post1#c.number=c.post1#c.number_iv), a(city_id year#month pred tem_meand age_year incentive2#time) cluster(city_id)
eststo E
summ log_w5
estadd scalar ymean = r(mean)
estfe A B C D E, labels(city_id "City FE" time "Time FE")
return list
esttab A B C D E using "$out_files/TableC17.tex", replace b(a2) se(a2) keep(c.post1#c.number) coeflabels(c.post1#c.number "\# Monitors") label noconstant nolines nogaps compress fragment nonumbers mlabels(none) collabels() stats(ymean N, labels( "Mean Outcome" "Observations")) starlevels(* 0.10 ** 0.05 *** 0.01)


**==============================================================================
** Figures

**==============================================================================
* Figure D3
use "$data_files/firm_enf.dta", clear

fvset base 4 min_d_d4

reghdfe any_air i.post##i.min_d_d4 if min_dist<50 & starty<=2010, absorb(id time industry#time prov_id#time) cluster(city_id) poolsize(1) compact
coefplot, baselevels omitted vert yline(0, lc(cranberry)) keep(1.post1#*) coeflabels(1.post1#0.min_d_d4 = "0-5km" 1.post1#1.min_d_d4 = "5-10km" 1.post1#2.min_d_d4 = "10-15km" 1.post1#3.min_d_d4 = "15-20km" 1.post1#4.min_d_d4 = "20-50km") drop() graphregion(color(white) fcolor(white)) plotregion(color(white)) ytitle(Parameter Estimate) xtitle() le(95)
graph export "$out_files/any_air_gradient_50_ci.pdf", replace


**==============================================================================
* Figure D5
use "$data_files/firm_enf.dta", clear

merge m:1 city_id using "$data_files/Raw/city_info.dta", keepusing(env_lat env_lon centroid_lat centroid_lon)
keep if _merge == 3
drop _merge

geodist env_lat env_lon lat lon, gen(env_dist)
gen min_env_d4 = int(env_dist/5)
replace min_env_d4 = 4 if min_env_d4 > 4

* set base level
fvset base 20 time
fvset base 4 min_env_d4

geodist centroid_lat centroid_lon lat lon, gen(cen_dist)
gen min_cen_d4 = int(cen_dist/5)
replace min_cen_d4 = 4 if min_cen_d4 > 4

* set base level
fvset base 20 time
fvset base 4 min_cen_d4

reghdfe any_air i.time##i.min_env_d4 i.post##i.min_d_d4 i.post##i.min_cen_d4 if env_dist<50 & starty<=2010, absorb(time id industry#time prov_id#time) cluster(city_id) poolsize(1) compact

qui coefplot, baselevels omitted vert yline(0, lc(black)) xline(20.5, lc(cranberry) lp(dash)) keep(*.time#0.min_env_d4) drop() graphregion(color(white) fcolor(white)) plotregion(color(white)) ytitle(Parameter Estimate) xtitle(Year) le(95) mc(black) ciopts(recast(rcap) lwidth(0.3) lpattern(dash)) gen(enf_5_) replace

twoway (rarea enf_5_ul1 enf_5_ll1 enf_5_at, color(gs6%20)) (scatter enf_5_b enf_5_at, msymbol(p) mc(black%60)) (line enf_5_b enf_5_at, lp(dash) lc(blackblack%60)), yline(0, lc(black)) xline(20.5, lp(dash) lc(cranberry)) graphregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white) ilpattern(blank)) plotregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white)) legend(off) ytitle("") xtitle("") xtick(1(1)32) xlabel(1 "2010" 5 "2011" 9 "2012" 13 "2013" 17 "2014" 21 "2015" 25 "2016" 29 "2017") ysc(r(-0.01 0.01)) ylab(-0.01(0.005)0.01)
graph export "$out_files/any_air_env_event_5.pdf", replace

qui coefplot, baselevels omitted vert yline(0, lc(black)) xline(20.5, lc(cranberry) lp(dash)) keep(*.time#1.min_env_d4) drop() graphregion(color(white) fcolor(white)) plotregion(color(white)) ytitle(Parameter Estimate) xtitle(Year) le(95) mc(black) ciopts(recast(rcap) lwidth(0.3) lpattern(dash)) gen(enf_10_) replace

twoway (rarea enf_10_ul1 enf_10_ll1 enf_10_at, color(gs6%20)) (scatter enf_10_b enf_10_at, msymbol(p) mc(black%60)) (line enf_10_b enf_10_at, lp(dash) lc(blackblack%60)), yline(0, lc(black)) xline(20.5, lp(dash) lc(cranberry)) graphregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white) ilpattern(blank)) plotregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white)) legend(off) ytitle("") xtitle("") xtick(1(1)32) xlabel(1 "2010" 5 "2011" 9 "2012" 13 "2013" 17 "2014" 21 "2015" 25 "2016" 29 "2017") ysc(r(-0.01 0.01)) ylab(-0.01(0.005)0.01)
graph export "$out_files/any_air_env_event_10.pdf", replace

qui coefplot, baselevels omitted vert yline(0, lc(black)) xline(20.5, lc(cranberry) lp(dash)) keep(*.time#2.min_env_d4) drop() graphregion(color(white) fcolor(white)) plotregion(color(white)) ytitle(Parameter Estimate) xtitle(Year) le(95) mc(black) ciopts(recast(rcap) lwidth(0.3) lpattern(dash)) gen(enf_15_) replace

twoway (rarea enf_15_ul1 enf_15_ll1 enf_15_at, color(gs6%20)) (scatter enf_15_b enf_10_at, msymbol(p) mc(black%60)) (line enf_15_b enf_15_at, lp(dash) lc(blackblack%60)), yline(0, lc(black)) xline(20.5, lp(dash) lc(cranberry)) graphregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white) ilpattern(blank)) plotregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white)) legend(off) ytitle("") xtitle("") xtick(1(1)32) xlabel(1 "2010" 5 "2011" 9 "2012" 13 "2013" 17 "2014" 21 "2015" 25 "2016" 29 "2017") ysc(r(-0.01 0.01)) ylab(-0.01(0.005)0.01)
graph export "$out_files/any_air_env_event_15.pdf", replace

qui coefplot, baselevels omitted vert yline(0, lc(black)) xline(20.5, lc(cranberry) lp(dash)) keep(*.time#3.min_env_d4) drop() graphregion(color(white) fcolor(white)) plotregion(color(white)) ytitle(Parameter Estimate) xtitle(Year) le(95) mc(black) ciopts(recast(rcap) lwidth(0.3) lpattern(dash)) gen(enf_20_) replace

twoway (rarea enf_20_ul1 enf_20_ll1 enf_20_at, color(gs6%20)) (scatter enf_20_b enf_20_at, msymbol(p) mc(black%60)) (line enf_20_b enf_20_at, lp(dash) lc(blackblack%60)), yline(0, lc(black)) xline(20.5, lp(dash) lc(cranberry)) graphregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white) ilpattern(blank)) plotregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white)) legend(off) ytitle("") xtitle("") xtick(1(1)32) xlabel(1 "2010" 5 "2011" 9 "2012" 13 "2013" 17 "2014" 21 "2015" 25 "2016" 29 "2017") ysc(r(-0.01 0.01)) ylab(-0.01(0.005)0.01)
graph export "$out_files/any_air_env_event_20.pdf", replace



reghdfe any_air i.time##i.min_cen_d4 i.post##i.min_d_d4 i.post##i.min_env_d4 if cen_dist<50 & starty<=2010, absorb(time id industry#time prov_id#time) cluster(city_id) poolsize(1) compact

qui coefplot, baselevels omitted vert yline(0, lc(black)) xline(20.5, lc(cranberry) lp(dash)) keep(*.time#0.min_cen_d4) drop() graphregion(color(white) fcolor(white)) plotregion(color(white)) ytitle(Parameter Estimate) xtitle(Year) le(95) mc(black) ciopts(recast(rcap) lwidth(0.3) lpattern(dash)) gen(enf_5_) replace

twoway (rarea enf_5_ul1 enf_5_ll1 enf_5_at, color(gs6%20)) (scatter enf_5_b enf_5_at, msymbol(p) mc(black%60)) (line enf_5_b enf_5_at, lp(dash) lc(blackblack%60)), yline(0, lc(black)) xline(20.5, lp(dash) lc(cranberry)) graphregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white) ilpattern(blank)) plotregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white)) legend(off) ytitle("") xtitle("") xtick(1(1)32) xlabel(1 "2010" 5 "2011" 9 "2012" 13 "2013" 17 "2014" 21 "2015" 25 "2016" 29 "2017") ysc(r(-0.01 0.01)) ylab(-0.01(0.005)0.01)
graph export "$out_files/any_air_cen_event_5.pdf", replace

qui coefplot, baselevels omitted vert yline(0, lc(black)) xline(20.5, lc(cranberry) lp(dash)) keep(*.time#1.min_cen_d4) drop() graphregion(color(white) fcolor(white)) plotregion(color(white)) ytitle(Parameter Estimate) xtitle(Year) le(95) mc(black) ciopts(recast(rcap) lwidth(0.3) lpattern(dash)) gen(enf_10_) replace

twoway (rarea enf_10_ul1 enf_10_ll1 enf_10_at, color(gs6%20)) (scatter enf_10_b enf_10_at, msymbol(p) mc(black%60)) (line enf_10_b enf_10_at, lp(dash) lc(blackblack%60)), yline(0, lc(black)) xline(20.5, lp(dash) lc(cranberry)) graphregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white) ilpattern(blank)) plotregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white)) legend(off) ytitle("") xtitle("") xtick(1(1)32) xlabel(1 "2010" 5 "2011" 9 "2012" 13 "2013" 17 "2014" 21 "2015" 25 "2016" 29 "2017") ysc(r(-0.01 0.01)) ylab(-0.01(0.005)0.01)
graph export "$out_files/any_air_cen_event_10.pdf", replace

qui coefplot, baselevels omitted vert yline(0, lc(black)) xline(20.5, lc(cranberry) lp(dash)) keep(*.time#2.min_cen_d4) drop() graphregion(color(white) fcolor(white)) plotregion(color(white)) ytitle(Parameter Estimate) xtitle(Year) le(95) mc(black) ciopts(recast(rcap) lwidth(0.3) lpattern(dash)) gen(enf_15_) replace

twoway (rarea enf_15_ul1 enf_15_ll1 enf_15_at, color(gs6%20)) (scatter enf_15_b enf_10_at, msymbol(p) mc(black%60)) (line enf_15_b enf_15_at, lp(dash) lc(blackblack%60)), yline(0, lc(black)) xline(20.5, lp(dash) lc(cranberry)) graphregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white) ilpattern(blank)) plotregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white)) legend(off) ytitle("") xtitle("") xtick(1(1)32) xlabel(1 "2010" 5 "2011" 9 "2012" 13 "2013" 17 "2014" 21 "2015" 25 "2016" 29 "2017") ysc(r(-0.01 0.01)) ylab(-0.01(0.005)0.01)
graph export "$out_files/any_air_cen_event_15.pdf", replace

qui coefplot, baselevels omitted vert yline(0, lc(black)) xline(20.5, lc(cranberry) lp(dash)) keep(*.time#3.min_cen_d4) drop() graphregion(color(white) fcolor(white)) plotregion(color(white)) ytitle(Parameter Estimate) xtitle(Year) le(95) mc(black) ciopts(recast(rcap) lwidth(0.3) lpattern(dash)) gen(enf_20_) replace

twoway (rarea enf_20_ul1 enf_20_ll1 enf_20_at, color(gs6%20)) (scatter enf_20_b enf_20_at, msymbol(p) mc(black%60)) (line enf_20_b enf_20_at, lp(dash) lc(blackblack%60)), yline(0, lc(black)) xline(20.5, lp(dash) lc(cranberry)) graphregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white) ilpattern(blank)) plotregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white)) legend(off) ytitle("") xtitle("") xtick(1(1)32) xlabel(1 "2010" 5 "2011" 9 "2012" 13 "2013" 17 "2014" 21 "2015" 25 "2016" 29 "2017") ysc(r(-0.01 0.01)) ylab(-0.01(0.005)0.01)
graph export "$out_files/any_air_cen_event_20.pdf", replace


**==============================================================================
* Figure D5
use "$data_files/city_enf.dta", clear
set scheme s1mono

fvset base 2014 year
fvset base 20 time

reghdfe log_any_air i.time##c.number i.post1##c.area i.post1##c.pop, a(city_id year#quarter pred tem_meand age_year incentive2#time) cluster(city_id) poolsize(1) compact
coefplot, baselevels omitted vert yline(-0, lc(black)) xline(20.5, lp(dash) lc(cranberry)) keep(*me#c.number) coeflabels() drop() graphregion(color(white) fcolor(white)) plotregion(color(white)) ytitle(Parameter Estimate) le(95) mc(black) gen(pm1_) replace

regress number number_iv
predict num_hat

reghdfe log_any_air i.time##c.num_hat i.post1##c.area i.post1##c.pop, a(city_id year#quarter pred tem_meand age_year incentive2#time) cluster(city_id) poolsize(1) compact
coefplot, baselevels omitted vert yline(-0, lc(black)) xline(20.5, lp(dash) lc(cranberry)) keep(*me#c.num_hat) coeflabels() drop() graphregion(color(white) fcolor(white)) plotregion(color(white)) ytitle(Parameter Estimate) le(95) mc(black) gen(pm2_) replace

twoway (rarea pm1_ul1 pm1_ll1 pm1_at, color(gs6%20)) (line pm1_b pm1_at, lwidth(medthick) lp(dash) lc(blackblack%70)) (rarea pm2_ul1 pm2_ll1 pm2_at, color(gs6%20)) (line pm2_b pm2_at, lp(dash) lc(blackblack%40)), yline(-0, lc(black)) xline(20.5, lp(dash) lc(cranberry))  graphregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white) ilpattern(blank)) plotregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white)) ytitle("") xtitle("") xtick(1(1)32) xlabel(1 "2010" 5 "2011" 9 "2012" 13 "2013" 17 "2014" 21 "2015" 25 "2016" 29 "2017") ysc(r(-0.2 0.6)) ylabel(-0.2(0.2)0.6)  legend(order(2 "DiD" 4 "DiD+IV") pos(2) ring(0) rows(2))

graph export "$out_files/eventenf.pdf", replace


**==============================================================================
* Figure D11
* balance
use "$data_files/city_pm.dta", clear
keep if year < 2015

replace light = log(light)
gen log_any_air = log(any_air+1)

collapse (mean) pm25 light log_any_air number area pop age city_id GDP, by(city_cn)
gen above57 = age > 57

label variable number "\# Monitors"
label variable area "Size of buildup area"
label variable pop "Urban population"
label variable pm25 "AOD before 2015"
label variable light "Night light before 2015"
label variable log_any_air "log(\# Firms) before 2015"

fvset base 58 age
regress number i.age if age>=50 & age<=60
coefplot, baselevels omitted vert drop(_cons) keep(*.age) yline(0, lc(cranberry)) graphregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white) ilpattern(blank)) plotregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white)) legend(off) ytitle("") xtitle("Age of Mayor")coeflabels(50.age = "50" 51.age = "51" 52.age = "52" 53.age = "53" 54.age = "54" 55.age = "55" 56.age = "56" 57.age = "57" 58.age = "58" 59.age = "59" 60.age = "60") le(95)
graph export "$out_files/number_age.pdf", replace

regress area i.age if age>=50 & age<=60
coefplot, baselevels omitted vert drop(_cons) keep(*.age) yline(0, lc(cranberry)) graphregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white) ilpattern(blank)) plotregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white)) legend(off) ytitle("") xtitle("Age of Mayor")coeflabels(50.age = "50" 51.age = "51" 52.age = "52" 53.age = "53" 54.age = "54" 55.age = "55" 56.age = "56" 57.age = "57" 58.age = "58" 59.age = "59" 60.age = "60") le(95)
graph export "$out_files/area_age.pdf", replace

regress pop i.age if age>=50 & age<=60
coefplot, baselevels omitted vert drop(_cons) keep(*.age) yline(0, lc(cranberry)) graphregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white) ilpattern(blank)) plotregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white)) legend(off) ytitle("") xtitle("Age of Mayor")coeflabels(50.age = "50" 51.age = "51" 52.age = "52" 53.age = "53" 54.age = "54" 55.age = "55" 56.age = "56" 57.age = "57" 58.age = "58" 59.age = "59" 60.age = "60") le(95)
graph export "$out_files/pop_age.pdf", replace

regress pm25 i.age if age>=50 & age<=60
coefplot, baselevels omitted vert drop(_cons) keep(*.age) yline(0, lc(cranberry)) graphregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white) ilpattern(blank)) plotregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white)) legend(off) ytitle("") xtitle("Age of Mayor")coeflabels(50.age = "50" 51.age = "51" 52.age = "52" 53.age = "53" 54.age = "54" 55.age = "55" 56.age = "56" 57.age = "57" 58.age = "58" 59.age = "59" 60.age = "60") le(95)
graph export "$out_files/pm_age.pdf", replace

regress light i.age if age>=50 & age<=60
coefplot, baselevels omitted vert drop(_cons) keep(*.age) yline(0, lc(cranberry)) graphregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white) ilpattern(blank)) plotregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white)) legend(off) ytitle("") xtitle("Age of Mayor")coeflabels(50.age = "50" 51.age = "51" 52.age = "52" 53.age = "53" 54.age = "54" 55.age = "55" 56.age = "56" 57.age = "57" 58.age = "58" 59.age = "59" 60.age = "60") le(95)
graph export "$out_files/light_age.pdf", replace

regress log_any_air i.age if age>=50 & age<=60
coefplot, baselevels omitted vert drop(_cons) keep(*.age) yline(0, lc(cranberry)) graphregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white) ilpattern(blank)) plotregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white)) legend(off) ytitle("") xtitle("Age of Mayor")coeflabels(50.age = "50" 51.age = "51" 52.age = "52" 53.age = "53" 54.age = "54" 55.age = "55" 56.age = "56" 57.age = "57" 58.age = "58" 59.age = "59" 60.age = "60") le(95)
graph export "$out_files/enf_age.pdf", replace


**==============================================================================
* Figure D7
* Bandwidths
use "$data_files/city_pm_rd.dta", clear

gen dist1 = area - 20 if cutoff == 1
replace dist1 = area - 50 if cutoff == 2

frame create fs fs_b fs_var
quietly{
	forvalues x = 4(2)20 {
		qui rdrobust number dist1, p(1) h(`x') kernel(uni) covs(cutoff) vce(cluster city_id)
		frame post fs (e(tau_cl)) (e(se_tau_cl))
	}
}

frame fs: gen fs_ul = fs_b + 1.96*fs_var
frame fs: gen fs_ll = fs_b - 1.96*fs_var
frame fs: gen fs_at = 2 + 2*_n

frame fs: twoway (connected fs_b fs_at, sort msymbol(S) color(black)) (line fs_ul fs_at, sort lpattern(dash) lcolor(gs9)) /*
*/ (line fs_ll fs_at, sort lpattern(dash) lcolor(gs9)), ytitle(Number of monitors) yline(0, lc(cranberry)) /*
*/ xtitle(Bandwidth) xline(11.3, lcolor(blue) lpattern(dash) lwidth(thin)) /*
*/ graphregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white) ilpattern(blank)) plotregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white)) legend(off) ysc(r(0 2)) ylabel(0(0.5)2) xlabel(4(2)20) 
graph export "$out_files/band_fs.pdf", replace

gen bench = pm25 if year < 2012
bys city_id cutoff: egen mean_bench = mean(bench)

frame create rd rd_b rd_var
quietly{
	forvalues x = 4(2)20 {
		qui rdrobust pm25 dist1 if year >= 2015, fuzzy(number) covs(cutoff mean_bench year) p(1) h(`x') vce(cluster city_id) kernel(uni)
		frame post rd (e(tau_cl)) (e(se_tau_cl))
	}
}

frame rd: gen rd_ul = rd_b + 1.96*rd_var
frame rd: gen rd_ll = rd_b - 1.96*rd_var
frame rd: gen rd_at = 2 + 2*_n

frame rd: twoway (connected rd_b rd_at, sort msymbol(S) color(black)) (line rd_ul rd_at, sort lpattern(dash) lcolor(gs9)) /*
*/ (line rd_ll rd_at, sort lpattern(dash) lcolor(gs9)), ytitle(Number of monitors) yline(0, lc(cranberry)) /*
*/ xtitle(Bandwidth) xline(11.3, lcolor(blue) lpattern(dash) lwidth(thin)) /*
*/ graphregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white) ilpattern(blank)) plotregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white)) legend(off) ysc(r(-0.075 0.05)) ylabel(-0.075(0.025)0.05) xlabel(4(2)20) 
graph export "$out_files/band_rd.pdf", replace


use "$data_files/city_enf_rd.dta", clear

gen dist1 = area - 20 if cutoff == 1
replace dist1 = area - 50 if cutoff == 2

gen bench = log_any_air if year < 2012
bys city_id cutoff: egen mean_bench = mean(bench)

frame drop rd
frame create rd rd_b rd_var
quietly{
	forvalues x = 4(2)20 {
		qui rdrobust log_any_air dist1 if year >= 2015, fuzzy(number) covs(cutoff mean_bench year) p(1) h(`x') vce(cluster city_id) kernel(uni)
		frame post rd (e(tau_cl)) (e(se_tau_cl))
	}
}

frame rd: gen rd_ul = rd_b + 1.96*rd_var
frame rd: gen rd_ll = rd_b - 1.96*rd_var
frame rd: gen rd_at = 2 + 2*_n

frame rd: twoway (connected rd_b rd_at, sort msymbol(S) color(black)) (line rd_ul rd_at, sort lpattern(dash) lcolor(gs9)) /*
*/ (line rd_ll rd_at, sort lpattern(dash) lcolor(gs9)), ytitle(Number of monitors) yline(0, lc(cranberry)) /*
*/ xtitle(Bandwidth) xline(11.3, lcolor(blue) lpattern(dash) lwidth(thin)) /*
*/ graphregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white) ilpattern(blank)) plotregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white)) legend(off) ysc(r(-0.2 0.6)) ylabel(-0.2(0.2)0.6) xlabel(4(2)20) 
graph export "$out_files/band_rd_enf.pdf", replace


**==============================================================================
* Figure D7
use "$data_files/city_pm_rd.dta", clear

gen dist1 = area - 20 if cutoff == 1
replace dist1 = area - 50 if cutoff == 2

hist dist1 if cutoff == 1 & year == 2015 & month == 1, /*
*/ start(-24) width(12) xline(0, lc(cranberry)) ysc(r(0 0.025)) /*
*/ ylabel(0(0.005)0.025) xtitle("Size of the Build-up Area") /*
*/ graphregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white) ilpattern(blank)) /*
*/ plotregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white)) /*
*/ legend(nobox region(fcolor(white) margin(zero) lcolor(white)))
graph export "$out_files/Cutoff1Score1.pdf", replace

hist dist1 if cutoff == 2 & year == 2015 & month == 1, /*
*/ start(-60) width(12) xline(0, lc(cranberry)) ysc(r(0 0.025)) /*
*/ ylabel(0(0.005)0.025) xtitle("Size of the Build-up Area") /*
*/ graphregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white) ilpattern(blank)) /*
*/ plotregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white)) /*
*/ legend(nobox region(fcolor(white) margin(zero) lcolor(white)))
graph export "$out_files/Cutoff2Score1.pdf", replace

rddensity dist1 if year==2015 & month==1 & dist1<40 & dist1>-40, all plot plot_range(-20 20) nohist graph_opt(legend(off) xtitle("Size of the Buildup Area") ytitle("Density") graphregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white) ilpattern(blank)) plotregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white)))
graph export "$out_files/DensityTest1.pdf", as(pdf) replace


**==============================================================================
* Figure D9
* hist
use "$data_files/Raw/firm_info.dta", clear

hist min_dist if min_dist < 50, xtitle("Distance to the closest monitor (km)") /* 
*/ graphregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white) ilpattern(blank)) /*
*/ plotregion(fcolor(white) lcolor(none) ifcolor(white) ilcolor(white)) /*
*/ legend(nobox region(fcolor(white) margin(zero) lcolor(white)))
graph export "$out_files/hist_min_dist.pdf", as(pdf) replace