-
Notifications
You must be signed in to change notification settings - Fork 3
/
preparefactors.do
executable file
·58 lines (40 loc) · 1.14 KB
/
preparefactors.do
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
use "data/derived/shares.dta", clear
do "set_globals.do"
* calc global factor
* though we put it in ind factors and not use it separately
egen glbf = mean(shock), by(year)
* calculate the sectoral means as fixed effect estimates of the industry factors
egen indf = mean(shock), by(sector year)
* calculate country means, this has measurement error!
egen cntf = mean(shock-indf), by(country year)
* calculate even more residuals
gen epsilon = shock - indf - cntf
tempfile factors indfactors
save `factors', replace
* save country correspondence
collapse (count) epsilon, by(cnum country)
drop epsilon
sort cnum
save "data/derived/countries.dta", replace
use `factors', clear
collapse (mean) indf, by(sector year)
ren indf Fs
reshape wide Fs, i(year) j(sector)
sort year
save `indfactors', replace
* do the same for cnt factors
use `factors'
collapse (mean) cntf, by(country year)
ren cntf Fc
reshape wide Fc, i(year) j(country)
sort year
merge year using `indfactors'
tab _
drop _
* how many countries in a year?
egen Jt = robs(Fc*)
sort year
save "data/derived/allfactors.dta", replace
keep year Jt
sort year
save "data/derived/Jt.dta", replace