File size: 2,233 Bytes
4328c38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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


**********************************************************************
*** FIGURE A4
*** Distribution of the Difference-in-Differences Effects
**********************************************************************

use "Data\county_day_data.dta", clear

keep if year==2015 | year==2016 | year==2017

rename TRUMP_POST_1_30  TRUMP_POST30
rename TRUMP_PRE_M30 TRUMP_PREM30
rename TRUMP_POST_M30 TRUMP_POSTM30

***number of counties 1,478
qui: {
forval ii = 1/1478 {
	su n_stops if county_id==`ii' & TRUMP_POST30==1
	if r(N) != 0 {
		total n_stops if county_id==`ii' & TRUMP_POST30==1
		global stops`ii' = _b[n_stops]
		g TREATED_COUNTY_`ii' = (county_id==`ii')
	}
}
}
**I drop the first for collinearity
drop TREATED_COUNTY_9

reghdfe black_ps  1.TRUMP_POST30 1.TRUMP_POST30#1.TREATED_COUNTY_* [w=n_stops], a(county_id  day_id  i.county_id#c.day_id TRUMP_PREM30 TRUMP_0 TRUMP_POSTM30) cluster(county_id day_id)

mat treat = 999* J(1478,2,1)

local numerator = 0
local denominator = 0
forval ii = 1/1478 {
qui: su n_stops if county_id==`ii' & TRUMP_POST30==1
	if r(N) != 0 {
		if `ii' == 9{
			mat treat[`ii',1] = (_b[1.TRUMP_POST30]) 
			mat treat[`ii',2] = (${stops`ii'})
			local numerator = `numerator' +  ((_b[1.TRUMP_POST30]) * ${stops`ii'})
			local denominator = `denominator' + ${stops`ii'}
		}
		else {
			mat treat[`ii',1] = (_b[1.TRUMP_POST30] + _b[1.TRUMP_POST30#1.TREATED_COUNTY_`ii']) 
			mat treat[`ii',2] = (${stops`ii'})
			local numerator = `numerator' +  ((_b[1.TRUMP_POST30] + _b[1.TRUMP_POST30#1.TREATED_COUNTY_`ii']) * ${stops`ii'})
			local denominator = `denominator' + ${stops`ii'}
		}
	}
}

local effect =  `numerator' / `denominator'

di `effect'

g yy = treat[_n,1] in 1/1478
g ww = treat[_n,2] in 1/1478
replace yy = . if yy==999
replace ww = . if ww==999

graph twoway (hist yy [fweight=ww] if yy>-10 & yy<10, frac xtitle("Treatment Effects")) (scatteri 0 1.053357 0.2 1.053357, recast(line) lw(0.5)), legend(label(1 "Distribution Effects") label(2 "Average Effect")) graphregion(color(white)) scheme(s1mono)
graph export "Results\figureA4.pdf", as(pdf) name("Graph") replace

keep yy ww
drop if yy==.
save "Results\SA.dta", replace