-
Notifications
You must be signed in to change notification settings - Fork 0
/
manufacturing_linear_analysis_log.log
183 lines (155 loc) · 9.36 KB
/
manufacturing_linear_analysis_log.log
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
-----------------------------------------------------------------------------------------------------------------------------------------
name: main
log: E:\Research Projects\Worker Accidents and Pollution\Regression Models\manufacturing_linear_analysis_log.log
log type: text
opened on: 3 Mar 2021, 20:48:15
.
. * Import the clean data file, produced using R. I'm using Stata for the analysis.
. * because Stata works with panel data a little easier.
. import delimited "../Data/Data for Regression Models/`industry'_accidents_2003_to_2015.csv", varnames(1) numericcols(3/25)
(20 vars, 15,288,560 obs)
.
. * Take a smaller sample for local code testing
. keep if strpos(date, "2005")
(14,113,260 observations deleted)
.
. ********* End of section to change when switching between local and ACCRE ******
.
. ********* Basic fixes to data file, applicable to every regression *************
.
. * Replace the string date variable with one readable by Stata.
. gen temporary_date = date(date, "YMD")
. drop date
. rename temporary_date date
. format date %td
.
. * Create a month variable so I can absorb month-of-year fixed effects
. gen month = month(date)
.
. // * Create weekday dummy variables, since ivreg2 can't handle factor variables
. // tabulate weekday, generate(weekday_dummy_)
. // drop weekday_dummy_1
.
. * Drop any observations from Alaska, Hawaii, or Puerto Rico.
. drop if floor(fips / 1000) == 2 | floor(fips / 1000) == 15 | floor(fips / 1000) == 72
(40,880 observations deleted)
.
. * Declare the data as panel data.
. xtset fips date
panel variable: fips (strongly balanced)
time variable: date, 01jan2005 to 31dec2005
delta: 1 day
.
. * Make a binary for an accident occurring.
. gen accident_occurred = 1 if num_accidents > 0
(1,133,421 missing values generated)
. replace accident_occurred = 0 if accident_occurred == .
(1,133,421 real changes made)
.
. * Generate heating- and cooling-degree-day measurements to capture the fact that
. * temperature changes could plausibly have very different effects depending
. * on the base temperature; but first, transform from kelvin to celsius
. replace mean_temperature = mean_temperature - 273.15
(1,134,420 real changes made)
. gen heat_degree_days = mean_temperature - 18 if mean_temperature > 18
(684,760 missing values generated)
. replace heat_degree_days = 0 if heat_degree_days == .
(684,760 real changes made)
. gen cool_degree_days = 18 - mean_temperature if mean_temperature < 18
(449,660 missing values generated)
. replace cool_degree_days = 0 if cool_degree_days == .
(449,660 real changes made)
.
. ********* End basic fixes to data file, applicable to every regression *********
.
. * Test out ivprobit. See https://www.statalist.org/forums/forum/general-stata-discussion/general/1305265-instrumental-variable-probit-u
> sing-panel-data
. * for Jeff Wooldridge saying that clustering on the panel identifier allows for
. * valid inference with panel data using ivprobit. It is a correlated random
. * effects approach rather than fixed effects, because unconditional fixed
. * effects estimates are biased.
. eststo: ivprobit accident_occurred heat_degree_days cool_degree_days mean_precipitation employment i.weekday (mean_pm25 = meanlayer* pb
> l_height), vce(cluster fips) first
Fitting exogenous probit model
Iteration 0: log likelihood = -8007.575
Iteration 1: log likelihood = -6772.2754
Iteration 2: log likelihood = -6549.2947
Iteration 3: log likelihood = -6546.4962
Iteration 4: log likelihood = -6546.4794
Iteration 5: log likelihood = -6546.4794
Fitting full model
Iteration 0: log pseudolikelihood = -3605260.9
Iteration 1: log pseudolikelihood = -3605260.9
Probit model with endogenous regressors Number of obs = 1,113,250
Wald chi2(11) = 511.70
Log pseudolikelihood = -3605260.9 Prob > chi2 = 0.0000
(Std. Err. adjusted for 3,050 clusters in fips)
-------------------------------------------------------------------------------------------------------
| Robust
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
--------------------------------------+----------------------------------------------------------------
accident_occurred |
mean_pm25 | .0112152 .0074571 1.50 0.133 -.0034003 .0258308
heat_degree_days | -.0198619 .0073655 -2.70 0.007 -.0342979 -.0054258
cool_degree_days | -.0061114 .0022265 -2.74 0.006 -.0104753 -.0017476
mean_precipitation | -.0015187 .0028966 -0.52 0.600 -.0071959 .0041585
employment | 6.89e-06 6.21e-07 11.09 0.000 5.67e-06 8.11e-06
|
weekday |
2 | .5290104 .0760885 6.95 0.000 .3798796 .6781412
3 | .5430884 .0783642 6.93 0.000 .3894973 .6966795
4 | .5016558 .0757408 6.62 0.000 .3532066 .650105
5 | .5744414 .0763077 7.53 0.000 .424881 .7240018
6 | .527456 .0742128 7.11 0.000 .3820016 .6729104
7 | .2411984 .0767301 3.14 0.002 .0908101 .3915868
|
_cons | -3.723034 .0948973 -39.23 0.000 -3.909029 -3.537039
--------------------------------------+----------------------------------------------------------------
mean_pm25 |
heat_degree_days | .7652498 .0085064 89.96 0.000 .7485777 .781922
cool_degree_days | -.0355966 .0045375 -7.85 0.000 -.0444899 -.0267034
mean_precipitation | -.1125086 .0016344 -68.84 0.000 -.115712 -.1093052
employment | .0000176 7.77e-06 2.26 0.024 2.36e-06 .0000328
|
weekday |
2 | -.2392408 .0087604 -27.31 0.000 -.2564109 -.2220707
3 | -.2168994 .0097188 -22.32 0.000 -.2359479 -.1978509
4 | -.0330339 .0136145 -2.43 0.015 -.0597177 -.00635
5 | -.2317289 .0169175 -13.70 0.000 -.2648867 -.1985712
6 | -.2501595 .0189468 -13.20 0.000 -.2872945 -.2130244
7 | .1034542 .013494 7.67 0.000 .0770064 .1299019
|
meanlayer1 | -75.65052 4.364848 -17.33 0.000 -84.20547 -67.09558
meanlayer2 | -.0179899 12.03289 -0.00 0.999 -23.60201 23.56603
meanlayer3 | 4.491231 13.37485 0.34 0.737 -21.72298 30.70545
meanlayer4 | -15.01321 9.096147 -1.65 0.099 -32.84133 2.814913
pbl_height | -.0054954 .0000719 -76.48 0.000 -.0056363 -.0053546
_cons | 14.45929 .1000834 144.47 0.000 14.26313 14.65545
--------------------------------------+----------------------------------------------------------------
/athrho2_1 | -.1262694 .0404519 -3.12 0.002 -.2055537 -.0469851
/lnsigma2 | 1.813682 .0037362 485.44 0.000 1.806359 1.821004
--------------------------------------+----------------------------------------------------------------
corr(e.mean_pm25,e.accident_occurred)| -.1256026 .0398137 -.2027067 -.0469506
sd(e.mean_pm25)| 6.132986 .022914 6.088239 6.178061
-------------------------------------------------------------------------------------------------------
Instrumented: mean_pm25
Instruments: heat_degree_days cool_degree_days mean_precipitation employment 2.weekday 3.weekday
4.weekday 5.weekday 6.weekday 7.weekday meanlayer1 meanlayer2 meanlayer3 meanlayer4
pbl_height
-------------------------------------------------------------------------------------------------------
Wald test of exogeneity (corr = 0): chi2(1) = 9.74 Prob > chi2 = 0.0018
(est1 stored)
. version 14.0: eststo: margins, dydx(_all) predict(pr)
--Break--
r(1);
end of do-file
--Break--
r(1);
. do "E:\Research Projects\Worker Accidents and Pollution\Regression Models\chapter_3_iv_probit.do"
. * Start with a clean slate.
. log close _all
name: main
log: E:\Research Projects\Worker Accidents and Pollution\Regression Models\manufacturing_linear_analysis_log.log
log type: text
closed on: 3 Mar 2021, 21:41:50
-----------------------------------------------------------------------------------------------------------------------------------------