Dear all,
I am trying to fully understand the STATA do-file shared by Jorda (and pasted below) on panel local projections. My questions are mainly two:
Best,
Lars
______________________Jorda STATA code_______________________________________
clear
cap drop _all
cap graph drop _all
/********************* READ IN THE DATA ***********************/
use http://data.macrohistory.net/JST/JSTdatasetR5.dta
sort ifs year /* ifs indicates the country */
xtset ifs year, yearly
/******************** Some Data transformations ***************/
gen lgdpr = 100*ln(rgdppc*pop) /* convert to RGDP and take log */
gen lcpi = 100*ln(cpi)
* My notes: CPI in the dataset is an index and dlcpi below is thus the percentage inflation rate,
*dlgdpr is the real growth rate
* stir is the short term interest rate and dstir is thus the pp change in the short term interest rate
gen dlcpi = d.lcpi /* first-diff*/
gen dlgdpr = d.lgdpr
gen dstir = d.stir
gen lstir = l.stir /* first lag */
/* Generate LHS variables for the LPs */
foreach x in lgdpr lcpi stir {
forv h = 0/4 {
*gen `x'`h' = f`h'.`x' - l.`x' // Use for cumulative IRF
gen `x'`h' = f`h'.`x' - l.f`h'.`x' // Use for usual IRF
}
}
********************************************
* Set Sample if only interested in post-WW2
********************************************
*keep if year>=1950
************************************************** ************
* Compute LPs. Note: a loop is more elegant but tricky to code
* because I am using Cholesky identification and controls vary
* by regression
************************************************** ************
** Real GDP to STIR
eststo clear
cap drop b u d Years Zero
gen Years = _n-1 if _n<=6
gen Zero = 0 if _n<=6
gen b=0
gen u=0
gen d=0
qui forv h = 0/4 {
xtreg lgdpr`h' l(1/3).dlgdpr l(1/3).dlcpi l(1/3).dstir, fe cluster(iso)
replace b = _b[l.dstir] if _n == `h'+2
replace u = _b[l.dstir] + 1.645* _se[l.dstir] if _n == `h'+2
replace d = _b[l.dstir] - 1.645* _se[l.dstir] if _n == `h'+2
eststo
}
nois esttab , se nocons keep(L.dstir)
twoway ///
(rarea u d Years, ///
fcolor(gs13) lcolor(gs13) lw(none) lpattern(solid)) ///
(line b Years, lcolor(blue) ///
lpattern(solid) lwidth(thick)) ///
(line Zero Years, lcolor(black)), legend(off) ///
title("Response of GDPR to 1pp shock to STIR (Cholesky)", color(black) size(medsmall)) ///
ytitle("Percent", size(medsmall)) xtitle("Year", size(medsmall)) ///
graphregion(color(white)) plotregion(color(white))
gr rename g_gdpr , replace
** Real CPI to STIR (Note: l(0/3).dlgdpr in xtreg)
eststo clear
cap drop b u d Years Zero
gen Years = _n-1 if _n<=6
gen Zero = 0 if _n<=6
gen b=0
gen u=0
gen d=0
qui forv h = 0/4 {
xtreg lcpi`h' l(0/3).dlgdpr l(1/3).dlcpi l(1/3).dstir, fe cluster(iso)
replace b = _b[l.dstir] if _n == `h'+2
replace u = _b[l.dstir] + 1.645* _se[l.dstir] if _n == `h'+2
replace d = _b[l.dstir] - 1.645* _se[l.dstir] if _n == `h'+2
eststo
}
nois esttab , se nocons keep(L.dstir)
twoway ///
(rarea u d Years, ///
fcolor(gs13) lcolor(gs13) lw(none) lpattern(solid)) ///
(line b Years, lcolor(blue) ///
lpattern(solid) lwidth(thick)) ///
(line Zero Years, lcolor(black)), legend(off) ///
title("Response of CPI to 1pp shock to STIR (Cholesky)", color(black) size(medsmall)) ///
ytitle("Percent", size(medsmall)) xtitle("Year", size(medsmall)) ///
graphregion(color(white)) plotregion(color(white))
gr rename g_cpi , replace
** Real STIR to STIR (Note: l(0/3).dlgdpr and l(0/3).dlcpi in xtreg)
** Also note _n == `h'+1 and _b[dstir]
eststo clear
cap drop b u d Years Zero
gen Years = _n-1 if _n<=6
gen Zero = 0 if _n<=6
gen b=0
gen u=0
gen d=0
qui forv h = 0/4 {
xtreg stir`h' l(0/3).dlgdpr l(0/3).dlcpi l(0/3).dstir, fe cluster(iso)
replace b = _b[dstir] if _n == `h'+1
replace u = _b[dstir] + 1.645* _se[dstir] if _n == `h'+1
replace d = _b[dstir] - 1.645* _se[dstir] if _n == `h'+1
eststo
}
nois esttab , se nocons keep(dstir)
twoway ///
(rarea u d Years, ///
fcolor(gs13) lcolor(gs13) lw(none) lpattern(solid)) ///
(line b Years, lcolor(blue) ///
lpattern(solid) lwidth(thick)) ///
(line Zero Years, lcolor(black)), legend(off) ///
title("Response of STIR to 1pp shock to STIR (Cholesky)", color(black) size(medsmall)) ///
ytitle("Percent", size(medsmall)) xtitle("Year", size(medsmall)) ///
graphregion(color(white)) plotregion(color(white))
gr rename g_stir , replace
gr combine g_gdpr g_cpi g_stir
gr rename g_all1, replace
I am trying to fully understand the STATA do-file shared by Jorda (and pasted below) on panel local projections. My questions are mainly two:
- Jorda says he is using Cholesky identification, but im unsure how that is reflected in the code. For instance, his first regression of lgdpr (real GDP) on dstir (change in short term interest rate) and dlcpi (inflation rate) looks like this: xtreg lgdpr`h' l(1/3).dlgdpr l(1/3).dlcpi l(1/3).dstir, fe cluster(iso). By Cholesky identification, is Jorda simply referring to the fact that he is using only lagged values of dstir and dlcpi? So, not estimating the contemporaneous impacts? And by that logic not using Cholesky identification would just be entering variables as l(0/3).x instead of l(1/3).x?
- In his code he uses the term 'if _n == `h'+2' in the first two IRFs but in the third and final one (where variables are entered using 'l(0/3)') it is changed to 'if _n == `h'+1'. Im pretty sure it has something to do with allowing for contemporaneous impacts on the short term interest rate (dstir) but not sure how it is related exactly?
Best,
Lars
______________________Jorda STATA code_______________________________________
clear
cap drop _all
cap graph drop _all
/********************* READ IN THE DATA ***********************/
use http://data.macrohistory.net/JST/JSTdatasetR5.dta
sort ifs year /* ifs indicates the country */
xtset ifs year, yearly
/******************** Some Data transformations ***************/
gen lgdpr = 100*ln(rgdppc*pop) /* convert to RGDP and take log */
gen lcpi = 100*ln(cpi)
* My notes: CPI in the dataset is an index and dlcpi below is thus the percentage inflation rate,
*dlgdpr is the real growth rate
* stir is the short term interest rate and dstir is thus the pp change in the short term interest rate
gen dlcpi = d.lcpi /* first-diff*/
gen dlgdpr = d.lgdpr
gen dstir = d.stir
gen lstir = l.stir /* first lag */
/* Generate LHS variables for the LPs */
foreach x in lgdpr lcpi stir {
forv h = 0/4 {
*gen `x'`h' = f`h'.`x' - l.`x' // Use for cumulative IRF
gen `x'`h' = f`h'.`x' - l.f`h'.`x' // Use for usual IRF
}
}
********************************************
* Set Sample if only interested in post-WW2
********************************************
*keep if year>=1950
************************************************** ************
* Compute LPs. Note: a loop is more elegant but tricky to code
* because I am using Cholesky identification and controls vary
* by regression
************************************************** ************
** Real GDP to STIR
eststo clear
cap drop b u d Years Zero
gen Years = _n-1 if _n<=6
gen Zero = 0 if _n<=6
gen b=0
gen u=0
gen d=0
qui forv h = 0/4 {
xtreg lgdpr`h' l(1/3).dlgdpr l(1/3).dlcpi l(1/3).dstir, fe cluster(iso)
replace b = _b[l.dstir] if _n == `h'+2
replace u = _b[l.dstir] + 1.645* _se[l.dstir] if _n == `h'+2
replace d = _b[l.dstir] - 1.645* _se[l.dstir] if _n == `h'+2
eststo
}
nois esttab , se nocons keep(L.dstir)
twoway ///
(rarea u d Years, ///
fcolor(gs13) lcolor(gs13) lw(none) lpattern(solid)) ///
(line b Years, lcolor(blue) ///
lpattern(solid) lwidth(thick)) ///
(line Zero Years, lcolor(black)), legend(off) ///
title("Response of GDPR to 1pp shock to STIR (Cholesky)", color(black) size(medsmall)) ///
ytitle("Percent", size(medsmall)) xtitle("Year", size(medsmall)) ///
graphregion(color(white)) plotregion(color(white))
gr rename g_gdpr , replace
** Real CPI to STIR (Note: l(0/3).dlgdpr in xtreg)
eststo clear
cap drop b u d Years Zero
gen Years = _n-1 if _n<=6
gen Zero = 0 if _n<=6
gen b=0
gen u=0
gen d=0
qui forv h = 0/4 {
xtreg lcpi`h' l(0/3).dlgdpr l(1/3).dlcpi l(1/3).dstir, fe cluster(iso)
replace b = _b[l.dstir] if _n == `h'+2
replace u = _b[l.dstir] + 1.645* _se[l.dstir] if _n == `h'+2
replace d = _b[l.dstir] - 1.645* _se[l.dstir] if _n == `h'+2
eststo
}
nois esttab , se nocons keep(L.dstir)
twoway ///
(rarea u d Years, ///
fcolor(gs13) lcolor(gs13) lw(none) lpattern(solid)) ///
(line b Years, lcolor(blue) ///
lpattern(solid) lwidth(thick)) ///
(line Zero Years, lcolor(black)), legend(off) ///
title("Response of CPI to 1pp shock to STIR (Cholesky)", color(black) size(medsmall)) ///
ytitle("Percent", size(medsmall)) xtitle("Year", size(medsmall)) ///
graphregion(color(white)) plotregion(color(white))
gr rename g_cpi , replace
** Real STIR to STIR (Note: l(0/3).dlgdpr and l(0/3).dlcpi in xtreg)
** Also note _n == `h'+1 and _b[dstir]
eststo clear
cap drop b u d Years Zero
gen Years = _n-1 if _n<=6
gen Zero = 0 if _n<=6
gen b=0
gen u=0
gen d=0
qui forv h = 0/4 {
xtreg stir`h' l(0/3).dlgdpr l(0/3).dlcpi l(0/3).dstir, fe cluster(iso)
replace b = _b[dstir] if _n == `h'+1
replace u = _b[dstir] + 1.645* _se[dstir] if _n == `h'+1
replace d = _b[dstir] - 1.645* _se[dstir] if _n == `h'+1
eststo
}
nois esttab , se nocons keep(dstir)
twoway ///
(rarea u d Years, ///
fcolor(gs13) lcolor(gs13) lw(none) lpattern(solid)) ///
(line b Years, lcolor(blue) ///
lpattern(solid) lwidth(thick)) ///
(line Zero Years, lcolor(black)), legend(off) ///
title("Response of STIR to 1pp shock to STIR (Cholesky)", color(black) size(medsmall)) ///
ytitle("Percent", size(medsmall)) xtitle("Year", size(medsmall)) ///
graphregion(color(white)) plotregion(color(white))
gr rename g_stir , replace
gr combine g_gdpr g_cpi g_stir
gr rename g_all1, replace