-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathultrapollution_complete.R
1194 lines (893 loc) · 82.9 KB
/
ultrapollution_complete.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
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
# This script performs the econometric analyses for the ultrapollution project
# Loading libraries
library(stargazer)
library(sandwich)
library(ggplot2)
library(jtools)
library(dplyr)
library(kableExtra)
library(modelsummary)
library(maps)
library(sf)
library(tmap)
library(socviz)
library(lmtest)
library(car)
library(corrplot)
# Specifying directories for data + results
direc <- paste('C:/Users/', username, '/Documents/Data/ultrapollution/ultra_data/', sep = '')
direc2 <- paste('C:/Users/', username, '/Documents/Data/ultrapollution/results/', sep = '')
# Reading in the data set
data <- read.csv(paste(direc, 'ultradata.csv', sep = ''))
# See which event types have at least 100 observations
event_types <- c()
for (d in unique(data$RACE_Distance)) {if (dim(data[which(data$RACE_Distance == d),])[1]>100) {event_types <- c(event_types,d)}}
# Remove ambiguous event types and sub-ultras from list
event_types <- event_types[! event_types %in% c('Variable Hours', 'Unknown Miles', '25 KM', '20 Miles', '40 KM')]
# Remove event types with fewer than 5 unique events and 20 total times events were held and at least 500 observations
drop_types <- c()
for (d in event_types) {
tmp <- data[which(data$RACE_Distance == d),]
v1 <- length(unique(tmp$RACE_Name))
v2 <- length(unique(tmp$RACE_ID))
v3 <- dim(tmp)[1]
if (v1 < 5 || v2 < 20 || v3 < 500) {
drop_types <- c(drop_types,d)
}
}
event_types <- event_types[! event_types %in% drop_types]
# Split event_types into distance based and time based events lists
event_types_db <- event_types[c(1,4,6,11,12,13,15,16,17,18,19,20,21,22,23,25,26,27,28)]
event_types_tb <- event_types[c(2,3,5,7,8,9,10,14,24)]
# Making sure that no negative pollution values exist
data$PM2.5 <- ifelse(data$PM2.5 < 0, 0, data$PM2.5)
data$PM10 <- ifelse(data$PM10 < 0, 0, data$PM10)
data$CO <- ifelse(data$CO < 0, 0, data$CO)
data$NO2 <- ifelse(data$NO2 < 0, 0, data$NO2)
data$O3 <- ifelse(data$O3 < 0, 0, data$O3)
# Making sure that no negative pollution values exist for home counties
data$PM2.5_Home <- ifelse(data$PM2.5_Home < 0, 0, data$PM2.5_Home)
data$PM10_Home <- ifelse(data$PM10_Home < 0, 0, data$PM10_Home)
data$CO_Home <- ifelse(data$CO_Home < 0, 0, data$CO_Home)
data$NO2_Home <- ifelse(data$NO2_Home < 0, 0, data$NO2_Home)
data$O3_Home <- ifelse(data$O3_Home < 0, 0, data$O3_Home)
# Run the main models
modpmd <- lm(log(Seconds+.001) ~ PM2.5 + factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + PM2.5_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
modpmdx <- coeftest(modpmd, vcov = vcovCL, cluster = ~RACE_Distance)
modpmt <- lm(log(Distance+.001) ~ PM2.5 + factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + PM2.5_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
modpmtx <- coeftest(modpmt, vcov = vcovCL, cluster = ~RACE_Distance)
modpm10d <- lm(log(Seconds+.001) ~ PM10 + factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + PM10_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
modpm10dx <- coeftest(modpm10d, vcov = vcovCL, cluster = ~RACE_Distance)
modpm10t <- lm(log(Distance+.001) ~ PM10 + factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + PM10_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
modpm10tx <- coeftest(modpm10t, vcov = vcovCL, cluster = ~RACE_Distance)
modcod <- lm(log(Seconds+.001) ~ CO + factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + CO_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
modcodx <- coeftest(modcod, vcov = vcovCL, cluster = ~RACE_Distance)
modcot <- lm(log(Distance+.001) ~ CO + factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + CO_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
modcotx <- coeftest(modcot, vcov = vcovCL, cluster = ~RACE_Distance)
modno2d <- lm(log(Seconds+.001) ~ NO2 + factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + NO2_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
modno2dx <- coeftest(modno2d, vcov = vcovCL, cluster = ~RACE_Distance)
modno2t <- lm(log(Distance+.001) ~ NO2 + factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + NO2_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
modno2tx <- coeftest(modno2t, vcov = vcovCL, cluster = ~RACE_Distance)
modo3d <- lm(log(Seconds+.001) ~ O3 + factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + O3_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
modo3dx <- coeftest(modo3d, vcov = vcovCL, cluster = ~RACE_Distance)
modo3t <- lm(log(Distance+.001) ~ O3 + factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + O3_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
modo3tx <- coeftest(modo3t, vcov = vcovCL, cluster = ~RACE_Distance)
modalld <- lm(log(Seconds+.001) ~ PM2.5 + factor(Gender) + PM10 + factor(Gender) + CO + factor(Gender) + NO2 + factor(Gender) + O3 + factor(Gender)
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM2.5_Home + PM10_Home + O3_Home + CO_Home + NO2_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
modalldx <- coeftest(modalld, vcov = vcovCL, cluster = ~RACE_Distance)
modallt <- lm(log(Distance+.001) ~ PM2.5 + factor(Gender) + PM10 + factor(Gender) + CO + factor(Gender) + NO2 + factor(Gender) + O3 + factor(Gender)
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM2.5_Home + PM10_Home + O3_Home + CO_Home + NO2_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
modalltx <- coeftest(modallt, vcov = vcovCL, cluster = ~RACE_Distance)
mod41d <- lm(log(Seconds+.001) ~ PM2.5 + factor(Gender) + CO + factor(Gender) + NO2 + factor(Gender) + O3 + factor(Gender)
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM2.5_Home + O3_Home + CO_Home + NO2_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
mod41dx <- coeftest(mod41d, vcov = vcovCL, cluster = ~RACE_Distance)
mod41t <- lm(log(Distance+.001) ~ PM2.5 + factor(Gender) + CO + factor(Gender) + NO2 + factor(Gender) + O3 + factor(Gender)
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM2.5_Home + O3_Home + CO_Home + NO2_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
mod41tx <- coeftest(mod41t, vcov = vcovCL, cluster = ~RACE_Distance)
mod42d <- lm(log(Seconds+.001) ~ PM10 + factor(Gender) + CO + factor(Gender) + NO2 + factor(Gender) + O3 + factor(Gender)
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM10_Home + O3_Home + CO_Home + NO2_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
mod42dx <- coeftest(mod42d, vcov = vcovCL, cluster = ~RACE_Distance)
mod42t <- lm(log(Distance+.001) ~ PM10 + factor(Gender) + CO + factor(Gender) + NO2 + factor(Gender) + O3 + factor(Gender)
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM10_Home + O3_Home + CO_Home + NO2_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
mod42tx <- coeftest(mod42t, vcov = vcovCL, cluster = ~RACE_Distance)
# Results
write.csv(stargazer(modpmdx, modpm10dx, modcodx, modno2dx, modo3dx, modalldx, mod41dx, mod42dx,
omit = c('FIPS_Race', 'RACE_Month', 'RACE_Year', 'RACE_Distance'), omit.stat = c('f', 'ser')),
paste(direc2, 'results_db.txt', sep = ''))
write.csv(stargazer(modpmtx, modpm10tx, modcotx, modno2tx, modo3tx, modalltx, mod41tx, mod42tx,
omit = c('FIPS_Race', 'RACE_Month', 'RACE_Year', 'RACE_Distance'), omit.stat = c('f', 'ser')),
paste(direc2, 'results_tb.txt', sep = ''))
stargazer(modpmdx, modpm10dx, modcodx, modno2dx, modo3dx, modalldx, mod41dx, mod42dx,
omit = c('FIPS_Race', 'RACE_Month', 'RACE_Year', 'RACE_Distance'), omit.stat = c('f', 'ser'), type = 'text')
stargazer(modpmtx, modpm10tx, modcotx, modno2tx, modo3tx, modalltx, mod41tx, mod42tx,
omit = c('FIPS_Race', 'RACE_Month', 'RACE_Year', 'RACE_Distance'), omit.stat = c('f', 'ser'), type = 'text')
# Run the elasticity models
modpmd2 <- lm(log(Seconds+.001) ~ log(PM2.5+.001) + factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + PM2.5_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
modpmdxx <- coeftest(modpmd2, vcov = vcovCL, cluster = ~RACE_Distance)
modpmt2 <- lm(log(Distance+.001) ~ log(PM2.5+.001) + factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + PM2.5_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
modpmtxx <- coeftest(modpmt2, vcov = vcovCL, cluster = ~RACE_Distance)
modpm10d2 <- lm(log(Seconds+.001) ~ log(PM10+.001) + factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + PM10_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
modpm10dxx <- coeftest(modpm10d2, vcov = vcovCL, cluster = ~RACE_Distance)
modpm10t2 <- lm(log(Distance+.001) ~ log(PM10+.001) + factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + PM10_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
modpm10txx <- coeftest(modpm10t2, vcov = vcovCL, cluster = ~RACE_Distance)
modcod2 <- lm(log(Seconds+.001) ~ log(CO+.001) + factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + CO_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
modcodxx <- coeftest(modcod2, vcov = vcovCL, cluster = ~RACE_Distance)
modcot2 <- lm(log(Distance+.001) ~ log(CO+.001) + factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + CO_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
modcotxx <- coeftest(modcot2, vcov = vcovCL, cluster = ~RACE_Distance)
modno2d2 <- lm(log(Seconds+.001) ~ log(NO2+.001) + factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + NO2_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
modno2dxx <- coeftest(modno2d2, vcov = vcovCL, cluster = ~RACE_Distance)
modno2t2 <- lm(log(Distance+.001) ~ log(NO2+.001) + factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + NO2_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
modno2txx <- coeftest(modno2t2, vcov = vcovCL, cluster = ~RACE_Distance)
modo3d2 <- lm(log(Seconds+.001) ~ log(O3+.001) + factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + O3_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
modo3dxx <- coeftest(modo3d2, vcov = vcovCL, cluster = ~RACE_Distance)
modo3t2 <- lm(log(Distance+.001) ~ log(O3+.001) + factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + O3_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
modo3txx <- coeftest(modo3t2, vcov = vcovCL, cluster = ~RACE_Distance)
modalld2 <- lm(log(Seconds+.001) ~ log(PM2.5+.001) + log(PM10+.001) + log(CO+.001) + log(NO2+.001) + log(O3+.001) + factor(Gender)
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM2.5_Home + PM10_Home + CO_Home + NO2_Home + O3_Home,
data = data[which(data$RACE_Distance %in% event_types_db),])
modalldxx <- coeftest(modalld2, vcov = vcovCL, cluster = ~RACE_Distance)
modallt2 <- lm(log(Distance+.001) ~ log(PM2.5+.001) + log(PM10+.001) + log(CO+.001) + log(NO2+.001) + log(O3+.001) + factor(Gender)
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM2.5_Home + PM10_Home + CO_Home + NO2_Home + O3_Home,
data = data[which(data$RACE_Distance %in% event_types_tb),])
modalltxx <- coeftest(modallt2, vcov = vcovCL, cluster = ~RACE_Distance)
mod41d2 <- lm(log(Seconds+.001) ~ log(PM2.5+.001) + log(CO+.001) + log(NO2+.001) + log(O3+.001) + factor(Gender)
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM2.5_Home +CO_Home + NO2_Home + O3_Home,
data = data[which(data$RACE_Distance %in% event_types_db),])
mod41dxx <- coeftest(mod41d2, vcov = vcovCL, cluster = ~RACE_Distance)
mod41t2 <- lm(log(Distance+.001) ~ log(PM2.5+.001) + log(CO+.001) + log(NO2+.001) + log(O3+.001) + factor(Gender)
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM2.5_Home + CO_Home + NO2_Home + O3_Home,
data = data[which(data$RACE_Distance %in% event_types_tb),])
mod41txx <- coeftest(mod41t2, vcov = vcovCL, cluster = ~RACE_Distance)
mod42d2 <- lm(log(Seconds+.001) ~ log(PM10+.001) + log(CO+.001) + log(NO2+.001) + log(O3+.001) + factor(Gender)
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM10_Home + CO_Home + NO2_Home + O3_Home,
data = data[which(data$RACE_Distance %in% event_types_db),])
mod42dxx <- coeftest(mod42d2, vcov = vcovCL, cluster = ~RACE_Distance)
mod42t2 <- lm(log(Distance+.001) ~ log(PM10+.001) + log(CO+.001) + log(NO2+.001) + log(O3+.001) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM10_Home + CO_Home + NO2_Home + O3_Home,
data = data[which(data$RACE_Distance %in% event_types_tb),])
mod42txx <- coeftest(mod42t2, vcov = vcovCL, cluster = ~RACE_Distance)
# Results
write.csv(stargazer(modpmdxx, modpm10dxx, modcodxx, modno2dxx, modo3dxx, modalldxx, mod41dxx, mod42dxx,
omit = c('FIPS_Race', 'RACE_Month', 'RACE_Year', 'RACE_Distance'), omit.stat = c('f', 'ser')),
paste(direc2, 'results_db_2.txt', sep = ''))
write.csv(stargazer(modpmtxx, modpm10txx, modcotxx, modno2txx, modo3txx, modalltxx, mod41txx, mod42txx,
omit = c('FIPS_Race', 'RACE_Month', 'RACE_Year', 'RACE_Distance'), omit.stat = c('f', 'ser')),
paste(direc2, 'results_tb_2.txt', sep = ''))
stargazer(modpmdxx, modpm10dxx, modcodxx, modno2dxx, modo3dxx, modalldxx, mod41dxx, mod42dxx,
omit = c('FIPS_Race', 'RACE_Month', 'RACE_Year', 'RACE_Distance'), omit.stat = c('f', 'ser'), type = 'text')
stargazer(modpmtxx, modpm10txx, modcotxx, modno2txx, modo3txx, modalltxx, mod41txx, mod42txx,
omit = c('FIPS_Race', 'RACE_Month', 'RACE_Year', 'RACE_Distance'), omit.stat = c('f', 'ser'), type = 'text')
# Repeating with an interaction between pollution and gender
# Log-level models
xmodpmd <- lm(log(Seconds+.001) ~ PM2.5*factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + PM2.5_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
xmodpmdx <- coeftest(xmodpmd, vcov = vcovCL, cluster = ~RACE_Distance)
xmodpmt <- lm(log(Distance+.001) ~ PM2.5*factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + PM2.5_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
xmodpmtx <- coeftest(xmodpmt, vcov = vcovCL, cluster = ~RACE_Distance)
xmodpm10d <- lm(log(Seconds+.001) ~ PM10*factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + PM10_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
xmodpm10dx <- coeftest(xmodpm10d, vcov = vcovCL, cluster = ~RACE_Distance)
xmodpm10t <- lm(log(Distance+.001) ~ PM10*factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + PM10_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
xmodpm10tx <- coeftest(xmodpm10t, vcov = vcovCL, cluster = ~RACE_Distance)
xmodcod <- lm(log(Seconds+.001) ~ CO*factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + CO_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
xmodcodx <- coeftest(xmodcod, vcov = vcovCL, cluster = ~RACE_Distance)
xmodcot <- lm(log(Distance+.001) ~ CO*factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + CO_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
xmodcotx <- coeftest(xmodcot, vcov = vcovCL, cluster = ~RACE_Distance)
xmodno2d <- lm(log(Seconds+.001) ~ NO2*factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + NO2_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
xmodno2dx <- coeftest(xmodno2d, vcov = vcovCL, cluster = ~RACE_Distance)
xmodno2t <- lm(log(Distance+.001) ~ NO2*factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + NO2_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
xmodno2tx <- coeftest(xmodno2t, vcov = vcovCL, cluster = ~RACE_Distance)
xmodo3d <- lm(log(Seconds+.001) ~ O3*factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + O3_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
xmodo3dx <- coeftest(xmodo3d, vcov = vcovCL, cluster = ~RACE_Distance)
xmodo3t <- lm(log(Distance+.001) ~ O3*factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + O3_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
xmodo3tx <- coeftest(xmodo3t, vcov = vcovCL, cluster = ~RACE_Distance)
xmodalld <- lm(log(Seconds+.001) ~ PM2.5*factor(Gender) + PM10*factor(Gender) + CO*factor(Gender) + NO2*factor(Gender) + O3*factor(Gender)
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM2.5_Home + PM10_Home + O3_Home + CO_Home + NO2_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
xmodalldx <- coeftest(xmodalld, vcov = vcovCL, cluster = ~RACE_Distance)
xmodallt <- lm(log(Distance+.001) ~ PM2.5*factor(Gender) + PM10*factor(Gender) + CO*factor(Gender) + NO2*factor(Gender) + O3*factor(Gender)
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM2.5_Home + PM10_Home + O3_Home + CO_Home + NO2_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
xmodalltx <- coeftest(xmodallt, vcov = vcovCL, cluster = ~RACE_Distance)
xmod41d <- lm(log(Seconds+.001) ~ PM2.5*factor(Gender) + CO*factor(Gender) + NO2*factor(Gender) + O3*factor(Gender)
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM2.5_Home + O3_Home + CO_Home + NO2_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
xmod41dx <- coeftest(xmod41d, vcov = vcovCL, cluster = ~RACE_Distance)
xmod41t <- lm(log(Distance+.001) ~ PM2.5*factor(Gender) + CO*factor(Gender) + NO2*factor(Gender) + O3*factor(Gender)
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM2.5_Home + O3_Home + CO_Home + NO2_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
xmod41tx <- coeftest(xmod41t, vcov = vcovCL, cluster = ~RACE_Distance)
xmod42d <- lm(log(Seconds+.001) ~ PM10*factor(Gender) + CO*factor(Gender) + NO2*factor(Gender) + O3*factor(Gender)
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM10_Home + O3_Home + CO_Home + NO2_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
xmod42dx <- coeftest(xmod42d, vcov = vcovCL, cluster = ~RACE_Distance)
xmod42t <- lm(log(Distance+.001) ~ PM10*factor(Gender) + CO*factor(Gender) + NO2*factor(Gender) + O3*factor(Gender)
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM10_Home + O3_Home + CO_Home + NO2_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
xmod42tx <- coeftest(xmod42t, vcov = vcovCL, cluster = ~RACE_Distance)
# Results
write.csv(stargazer(xmodpmdx, xmodpm10dx, xmodcodx, xmodno2dx, xmodo3dx, xmodalldx, xmod41dx, xmod42dx,
omit = c('FIPS_Race', 'RACE_Month', 'RACE_Year', 'RACE_Distance'), omit.stat = c('f', 'ser')),
paste(direc2, 'results_db_X.txt', sep = ''))
write.csv(stargazer(xmodpmtx, xmodpm10tx, xmodcotx, xmodno2tx, xmodo3tx, xmodalltx, xmod41tx, xmod42tx,
omit = c('FIPS_Race', 'RACE_Month', 'RACE_Year', 'RACE_Distance'), omit.stat = c('f', 'ser')),
paste(direc2, 'results_tb_X.txt', sep = ''))
stargazer(xmodpmdx, xmodpm10dx, xmodcodx, xmodno2dx, xmodo3dx, xmodalldx, xmod41dx, xmod42dx,
omit = c('FIPS_Race', 'RACE_Month', 'RACE_Year', 'RACE_Distance'), omit.stat = c('f', 'ser'), type = 'text')
stargazer(xmodpmtx, xmodpm10tx, xmodcotx, xmodno2tx, xmodo3tx, xmodalltx, xmod41tx, xmod42tx,
omit = c('FIPS_Race', 'RACE_Month', 'RACE_Year', 'RACE_Distance'), omit.stat = c('f', 'ser'), type = 'text')
# Log-log models
xmodpmd2 <- lm(log(Seconds+.001) ~ log(PM2.5+.001)*factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + PM2.5_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
xmodpmdxx <- coeftest(xmodpmd2, vcov = vcovCL, cluster = ~RACE_Distance)
xmodpmt2 <- lm(log(Distance+.001) ~ log(PM2.5+.001)*factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + PM2.5_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
xmodpmtxx <- coeftest(xmodpmt2, vcov = vcovCL, cluster = ~RACE_Distance)
xmodpm10d2 <- lm(log(Seconds+.001) ~ log(PM10+.001)*factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + PM10_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
xmodpm10dxx <- coeftest(xmodpm10d2, vcov = vcovCL, cluster = ~RACE_Distance)
xmodpm10t2 <- lm(log(Distance+.001) ~ log(PM10+.001)*factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + PM10_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
xmodpm10txx <- coeftest(xmodpm10t2, vcov = vcovCL, cluster = ~RACE_Distance)
xmodcod2 <- lm(log(Seconds+.001) ~ log(CO+.001)*factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + CO_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
xmodcodxx <- coeftest(xmodcod2, vcov = vcovCL, cluster = ~RACE_Distance)
xmodcot2 <- lm(log(Distance+.001) ~ log(CO+.001)*factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + CO_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
xmodcotxx <- coeftest(xmodcot2, vcov = vcovCL, cluster = ~RACE_Distance)
xmodno2d2 <- lm(log(Seconds+.001) ~ log(NO2+.001)*factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + NO2_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
xmodno2dxx <- coeftest(xmodno2d2, vcov = vcovCL, cluster = ~RACE_Distance)
xmodno2t2 <- lm(log(Distance+.001) ~ log(NO2+.001)*factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + NO2_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
xmodno2txx <- coeftest(xmodno2t2, vcov = vcovCL, cluster = ~RACE_Distance)
xmodo3d2 <- lm(log(Seconds+.001) ~ log(O3+.001)*factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + O3_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
xmodo3dxx <- coeftest(xmodo3d2, vcov = vcovCL, cluster = ~RACE_Distance)
xmodo3t2 <- lm(log(Distance+.001) ~ log(O3+.001)*factor(Gender) + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + O3_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
xmodo3txx <- coeftest(xmodo3t2, vcov = vcovCL, cluster = ~RACE_Distance)
xmodalld2 <- lm(log(Seconds+.001) ~ log(PM2.5+.001)*factor(Gender) + log(PM10+.001)*factor(Gender)
+ log(CO+.001)*factor(Gender) + log(NO2+.001)*factor(Gender) + log(O3+.001)*factor(Gender)
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM2.5_Home + PM10_Home + CO_Home + NO2_Home + O3_Home,
data = data[which(data$RACE_Distance %in% event_types_db),])
xmodalldxx <- coeftest(xmodalld2, vcov = vcovCL, cluster = ~RACE_Distance)
xmodallt2 <- lm(log(Distance+.001) ~ log(PM2.5+.001)*factor(Gender) + log(PM10+.001)*factor(Gender)
+ log(CO+.001)*factor(Gender) + log(NO2+.001)*factor(Gender) + log(O3+.001)*factor(Gender)
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM2.5_Home + PM10_Home + CO_Home + NO2_Home + O3_Home,
data = data[which(data$RACE_Distance %in% event_types_tb),])
xmodalltxx <- coeftest(xmodallt2, vcov = vcovCL, cluster = ~RACE_Distance)
xmod41d2 <- lm(log(Seconds+.001) ~ log(PM2.5+.001)*factor(Gender) + log(CO+.001)*factor(Gender)
+ log(NO2+.001)*factor(Gender) + log(O3+.001)*factor(Gender)
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM2.5_Home +CO_Home + NO2_Home + O3_Home,
data = data[which(data$RACE_Distance %in% event_types_db),])
xmod41dxx <- coeftest(xmod41d2, vcov = vcovCL, cluster = ~RACE_Distance)
xmod41t2 <- lm(log(Distance+.001) ~ log(PM2.5+.001)*factor(Gender) + log(CO+.001)*factor(Gender)
+ log(NO2+.001)*factor(Gender) + log(O3+.001)*factor(Gender)
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM2.5_Home + CO_Home + NO2_Home + O3_Home,
data = data[which(data$RACE_Distance %in% event_types_tb),])
xmod41txx <- coeftest(xmod41t2, vcov = vcovCL, cluster = ~RACE_Distance)
xmod42d2 <- lm(log(Seconds+.001) ~ log(PM10+.001)*factor(Gender) + log(CO+.001)*factor(Gender)
+ log(NO2+.001)*factor(Gender) + log(O3+.001)*factor(Gender)
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM10_Home + CO_Home + NO2_Home + O3_Home,
data = data[which(data$RACE_Distance %in% event_types_db),])
xmod42dxx <- coeftest(xmod42d2, vcov = vcovCL, cluster = ~RACE_Distance)
xmod42t2 <- lm(log(Distance+.001) ~ log(PM10+.001)*factor(Gender) + log(CO+.001)*factor(Gender)
+ log(NO2+.001)*factor(Gender) + log(O3+.001)*factor(Gender)
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Ability + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM10_Home + CO_Home + NO2_Home + O3_Home,
data = data[which(data$RACE_Distance %in% event_types_tb),])
xmod42txx <- coeftest(xmod42t2, vcov = vcovCL, cluster = ~RACE_Distance)
# Results
write.csv(stargazer(xmodpmdxx, xmodpm10dxx, xmodcodxx, xmodno2dxx, xmodo3dxx, xmodalldxx, xmod41dxx, xmod42dxx,
omit = c('FIPS_Race', 'RACE_Month', 'RACE_Year', 'RACE_Distance'), omit.stat = c('f', 'ser')),
paste(direc2, 'results_db_2_X.txt', sep = ''))
write.csv(stargazer(xmodpmtxx, xmodpm10txx, xmodcotxx, xmodno2txx, xmodo3txx, xmodalltxx, xmod41txx, xmod42txx,
omit = c('FIPS_Race', 'RACE_Month', 'RACE_Year', 'RACE_Distance'), omit.stat = c('f', 'ser')),
paste(direc2, 'results_tb_2_X.txt', sep = ''))
stargazer(xmodpmdxx, xmodpm10dxx, xmodcodxx, xmodno2dxx, xmodo3dxx, xmodalldxx, xmod41dxx, xmod42dxx,
omit = c('FIPS_Race', 'RACE_Month', 'RACE_Year', 'RACE_Distance'), omit.stat = c('f', 'ser'), type = 'text')
stargazer(xmodpmtxx, xmodpm10txx, xmodcotxx, xmodno2txx, xmodo3txx, xmodalltxx, xmod41txx, xmod42txx,
omit = c('FIPS_Race', 'RACE_Month', 'RACE_Year', 'RACE_Distance'), omit.stat = c('f', 'ser'), type = 'text')
# Repeating with a triple interaction between pollution and gender and ability
# Log-level models
xxxmodpmd <- lm(log(Seconds+.001) ~ PM2.5*factor(Gender)*Ability + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + PM2.5_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
xxxmodpmdx <- coeftest(xxxmodpmd, vcov = vcovCL, cluster = ~RACE_Distance)
xxxmodpmt <- lm(log(Distance+.001) ~ PM2.5*factor(Gender)*Ability + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + PM2.5_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
xxxmodpmtx <- coeftest(xxxmodpmt, vcov = vcovCL, cluster = ~RACE_Distance)
xxxmodpm10d <- lm(log(Seconds+.001) ~ PM10*factor(Gender)*Ability + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + PM10_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
xxxmodpm10dx <- coeftest(xxxmodpm10d, vcov = vcovCL, cluster = ~RACE_Distance)
xxxmodpm10t <- lm(log(Distance+.001) ~ PM10*factor(Gender)*Ability + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + PM10_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
xxxmodpm10tx <- coeftest(xxxmodpm10t, vcov = vcovCL, cluster = ~RACE_Distance)
xxxmodcod <- lm(log(Seconds+.001) ~ CO*factor(Gender)*Ability + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + CO_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
xxxmodcodx <- coeftest(xxxmodcod, vcov = vcovCL, cluster = ~RACE_Distance)
xxxmodcot <- lm(log(Distance+.001) ~ CO*factor(Gender)*Ability + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + CO_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
xxxmodcotx <- coeftest(xxxmodcot, vcov = vcovCL, cluster = ~RACE_Distance)
xxxmodno2d <- lm(log(Seconds+.001) ~ NO2*factor(Gender)*Ability + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + NO2_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
xxxmodno2dx <- coeftest(xxxmodno2d, vcov = vcovCL, cluster = ~RACE_Distance)
xxxmodno2t <- lm(log(Distance+.001) ~ NO2*factor(Gender)*Ability + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + NO2_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
xxxmodno2tx <- coeftest(xxxmodno2t, vcov = vcovCL, cluster = ~RACE_Distance)
xxxmodo3d <- lm(log(Seconds+.001) ~ O3*factor(Gender)*Ability + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + O3_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
xxxmodo3dx <- coeftest(xxxmodo3d, vcov = vcovCL, cluster = ~RACE_Distance)
xxxmodo3t <- lm(log(Distance+.001) ~ O3*factor(Gender)*Ability + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + O3_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
xxxmodo3tx <- coeftest(xxxmodo3t, vcov = vcovCL, cluster = ~RACE_Distance)
xxxmodalld <- lm(log(Seconds+.001) ~ PM2.5*factor(Gender)*Ability + PM10*factor(Gender)*Ability + CO*factor(Gender)*Ability + NO2*factor(Gender)*Ability + O3*factor(Gender)*Ability
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM2.5_Home + PM10_Home + O3_Home + CO_Home + NO2_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
xxxmodalldx <- coeftest(xxxmodalld, vcov = vcovCL, cluster = ~RACE_Distance)
xxxmodallt <- lm(log(Distance+.001) ~ PM2.5*factor(Gender)*Ability + PM10*factor(Gender)*Ability + CO*factor(Gender)*Ability + NO2*factor(Gender)*Ability + O3*factor(Gender)*Ability
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM2.5_Home + PM10_Home + O3_Home + CO_Home + NO2_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
xxxmodalltx <- coeftest(xxxmodallt, vcov = vcovCL, cluster = ~RACE_Distance)
xxxmod41d <- lm(log(Seconds+.001) ~ PM2.5*factor(Gender)*Ability + CO*factor(Gender)*Ability + NO2*factor(Gender)*Ability + O3*factor(Gender)*Ability
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM2.5_Home + O3_Home + CO_Home + NO2_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
xxxmod41dx <- coeftest(xxxmod41d, vcov = vcovCL, cluster = ~RACE_Distance)
xxxmod41t <- lm(log(Distance+.001) ~ PM2.5*factor(Gender)*Ability + CO*factor(Gender)*Ability + NO2*factor(Gender)*Ability + O3*factor(Gender)*Ability
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM2.5_Home + O3_Home + CO_Home + NO2_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
xxxmod41tx <- coeftest(xxxmod41t, vcov = vcovCL, cluster = ~RACE_Distance)
xxxmod42d <- lm(log(Seconds+.001) ~ PM10*factor(Gender)*Ability + CO*factor(Gender)*Ability + NO2*factor(Gender)*Ability + O3*factor(Gender)*Ability
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM10_Home + O3_Home + CO_Home + NO2_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
xxxmod42dx <- coeftest(xxxmod42d, vcov = vcovCL, cluster = ~RACE_Distance)
xxxmod42t <- lm(log(Distance+.001) ~ PM10*factor(Gender)*Ability + CO*factor(Gender)*Ability + NO2*factor(Gender)*Ability + O3*factor(Gender)*Ability
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM10_Home + O3_Home + CO_Home + NO2_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
xxxmod42tx <- coeftest(xxxmod42t, vcov = vcovCL, cluster = ~RACE_Distance)
# Results
write.csv(stargazer(xxxmodpmdx, xxxmodpm10dx, xxxmodcodx, xxxmodno2dx, xxxmodo3dx, xxxmodalldx, xxxmod41dx, xxxmod42dx,
omit = c('FIPS_Race', 'RACE_Month', 'RACE_Year', 'RACE_Distance'), omit.stat = c('f', 'ser')),
paste(direc2, 'results_db_XX.txt', sep = ''))
write.csv(stargazer(xxxmodpmtx, xxxmodpm10tx, xxxmodcotx, xxxmodno2tx, xxxmodo3tx, xxxmodalltx, xxxmod41tx, xxxmod42tx,
omit = c('FIPS_Race', 'RACE_Month', 'RACE_Year', 'RACE_Distance'), omit.stat = c('f', 'ser')),
paste(direc2, 'results_tb_XX.txt', sep = ''))
stargazer(xxxmodpmdx, xxxmodpm10dx, xxxmodcodx, xxxmodno2dx, xxxmodo3dx, xxxmodalldx, xxxmod41dx, xxxmod42dx,
omit = c('FIPS_Race', 'RACE_Month', 'RACE_Year', 'RACE_Distance'), omit.stat = c('f', 'ser'), type = 'text')
stargazer(xxxmodpmtx, xxxmodpm10tx, xxxmodcotx, xxxmodno2tx, xxxmodo3tx, xxxmodalltx, xxxmod41tx, xxxmod42tx,
omit = c('FIPS_Race', 'RACE_Month', 'RACE_Year', 'RACE_Distance'), omit.stat = c('f', 'ser'), type = 'text')
# Log-log models
xxxmodpmd2 <- lm(log(Seconds+.001) ~ log(PM2.5+.001)*factor(Gender)*Ability + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + PM2.5_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
xxxmodpmdxx <- coeftest(xxxmodpmd2, vcov = vcovCL, cluster = ~RACE_Distance)
xxxmodpmt2 <- lm(log(Distance+.001) ~ log(PM2.5+.001)*factor(Gender)*Ability + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + PM2.5_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
xxxmodpmtxx <- coeftest(xxxmodpmt2, vcov = vcovCL, cluster = ~RACE_Distance)
xxxmodpm10d2 <- lm(log(Seconds+.001) ~ log(PM10+.001)*factor(Gender)*Ability + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + PM10_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
xxxmodpm10dxx <- coeftest(xxxmodpm10d2, vcov = vcovCL, cluster = ~RACE_Distance)
xxxmodpm10t2 <- lm(log(Distance+.001) ~ log(PM10+.001)*factor(Gender)*Ability + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + PM10_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
xxxmodpm10txx <- coeftest(xxxmodpm10t2, vcov = vcovCL, cluster = ~RACE_Distance)
xxxmodcod2 <- lm(log(Seconds+.001) ~ log(CO+.001)*factor(Gender)*Ability + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + CO_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
xxxmodcodxx <- coeftest(xxxmodcod2, vcov = vcovCL, cluster = ~RACE_Distance)
xxxmodcot2 <- lm(log(Distance+.001) ~ log(CO+.001)*factor(Gender)*Ability + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + CO_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
xxxmodcotxx <- coeftest(xxxmodcot2, vcov = vcovCL, cluster = ~RACE_Distance)
xxxmodno2d2 <- lm(log(Seconds+.001) ~ log(NO2+.001)*factor(Gender)*Ability + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + NO2_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
xxxmodno2dxx <- coeftest(xxxmodno2d2, vcov = vcovCL, cluster = ~RACE_Distance)
xxxmodno2t2 <- lm(log(Distance+.001) ~ log(NO2+.001)*factor(Gender)*Ability + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + NO2_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
xxxmodno2txx <- coeftest(xxxmodno2t2, vcov = vcovCL, cluster = ~RACE_Distance)
xxxmodo3d2 <- lm(log(Seconds+.001) ~ log(O3+.001)*factor(Gender)*Ability + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + O3_Home, data = data[which(data$RACE_Distance %in% event_types_db),])
xxxmodo3dxx <- coeftest(xxxmodo3d2, vcov = vcovCL, cluster = ~RACE_Distance)
xxxmodo3t2 <- lm(log(Distance+.001) ~ log(O3+.001)*factor(Gender)*Ability + Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home + O3_Home, data = data[which(data$RACE_Distance %in% event_types_tb),])
xxxmodo3txx <- coeftest(xxxmodo3t2, vcov = vcovCL, cluster = ~RACE_Distance)
xxxmodalld2 <- lm(log(Seconds+.001) ~ log(PM2.5+.001)*factor(Gender)*Ability + log(PM10+.001)*factor(Gender)*Ability
+ log(CO+.001)*factor(Gender)*Ability + log(NO2+.001)*factor(Gender)*Ability + log(O3+.001)*factor(Gender)*Ability
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM2.5_Home + PM10_Home + CO_Home + NO2_Home + O3_Home,
data = data[which(data$RACE_Distance %in% event_types_db),])
xxxmodalldxx <- coeftest(xxxmodalld2, vcov = vcovCL, cluster = ~RACE_Distance)
xxxmodallt2 <- lm(log(Distance+.001) ~ log(PM2.5+.001)*factor(Gender)*Ability + log(PM10+.001)*factor(Gender)*Ability
+ log(CO+.001)*factor(Gender)*Ability + log(NO2+.001)*factor(Gender)*Ability + log(O3+.001)*factor(Gender)*Ability
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State
+ Travel_Distance + Population + Poverty_Rate + Unemployment_Rate + Income
+ Education_High_School + Education_Some_College + Education_Associates
+ Education_Bachelors + Education_Graduate + Altitude_Home
+ PM2.5_Home + PM10_Home + CO_Home + NO2_Home + O3_Home,
data = data[which(data$RACE_Distance %in% event_types_tb),])
xxxmodalltxx <- coeftest(xxxmodallt2, vcov = vcovCL, cluster = ~RACE_Distance)
xxxmod41d2 <- lm(log(Seconds+.001) ~ log(PM2.5+.001)*factor(Gender)*Ability + log(CO+.001)*factor(Gender)*Ability
+ log(NO2+.001)*factor(Gender)*Ability + log(O3+.001)*factor(Gender)*Ability
+ Temperature*Humidity + Precipitation + WindSpeed + factor(FIPS_Race) + factor(RACE_Month)*factor(RACE_Year)
+ factor(RACE_Distance) + Total_Races + RACE_Finisher_Count + In_State