-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathstacked.do
More file actions
106 lines (75 loc) · 2.86 KB
/
stacked.do
File metadata and controls
106 lines (75 loc) · 2.86 KB
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
/*
Purpose: Estimate stacked income decile regression (generate sters)
*/
****** Set Model Specification Locals ******************************************
local model = "$model"
********************************************************************************
*Step 1: Load Data
********************************************************************************
use "$root/data/GMFD_`model'_regsort.dta", `clear'
********************************************************************************
* Step 2: Prepare Regressors and Run Regression
********************************************************************************
* set fixed effect
* set time
sort region_i year
xtset region_i year
* income decile dummies
forval pg=1/2 {
forval lg=1/10 {
qui gen DumIncG`lg'F1P`pg' = (ind`lg'- L1.ind`lg') * indf1 * indp`pg'
}
}
** Ashwin: the epic plot version
forval pg=1/2 {
forval lg=1/3 {
qui gen DumIncGepic`lg'F1P`pg' = (indepic`lg'- L1.indepic`lg') * indf1 * indp`pg'
}
}
* income decile x temp
local income_decile_temp_r = ""
forval pg = 1/2 {
forval lg = 1/10 {
forval k = 1/2 {
local income_decile_temp_r = "`income_decile_temp_r' c.indp`pg'#c.indf1#c.FD_I`lg'temp`k'_GMFD"
}
}
}
** Ashwin: the epic plot version
local income_decile_epic_temp_r = ""
forval pg = 1/2 {
forval lg = 1/3 {
forval k = 1/2 {
local income_decile_epic_temp_r = "`income_decile_epic_temp_r' c.indp`pg'#c.indf1#c.FD_Iepic`lg'temp`k'_GMFD"
}
}
}
* precip
local precip_r = ""
forval pg=1/2 {
forval k = 1/2 {
local precip_r = "`precip_r' c.indp`pg'#c.indf1#c.FD_precip`k'_GMFD"
}
}
* run first stage regression
reghdfe FD_load_pc `income_decile_temp_r' `precip_r' DumInc*, absorb(i.flow_i#i.product_i#i.year#i.subregionid) cluster(region_i) residuals(resid)
estimates save "$root/sters/FD_income_decile_`model'", replace
* calculating weigts for FGLS
drop if resid==.
bysort region_i: egen omega = var(resid)
qui gen weight = 1/omega
* run second stage FGLS regression
reghdfe FD_load_pc `income_decile_temp_r' `precip_r' DumInc* [pw=weight], absorb(i.flow_i#i.product_i#i.year#i.subregionid) cluster(region_i)
estimates save "$root/sters/FD_FGLS_income_decile_`model'", replace
drop resid weight omega
** Ashwin: epic plot version
* run first stage regression
reghdfe FD_load_pc `income_decile_epic_temp_r' `precip_r' DumIncGepic*, absorb(i.flow_i#i.product_i#i.year#i.subregionid) cluster(region_i) residuals(resid)
estimates save "$root/sters/FD_income_decile_epic_`model'", replace
* calculating weigts for FGLS
drop if resid==.
bysort region_i: egen omega = var(resid)
qui gen weight = 1/omega
* run second stage FGLS regression
reghdfe FD_load_pc `income_decile_epic_temp_r' `precip_r' DumIncGepic* [pw=weight], absorb(i.flow_i#i.product_i#i.year#i.subregionid) cluster(region_i)
estimates save "$root/sters/FD_FGLS_income_decile_epic_`model'", replace