I am trying to bootstrap the impulse response function that I obtain from a local projection. The tricky bit is that the object I want to bootstrap is a vector. This is the code that I have so far:
Code:
clear set obs 200 set seed 12 gen xx=runiform() gen e=rnormal(0,1) gen lindpro=0.5*x+e g time =_n tsset time local nlags 3 local irflag = 36 capture program drop lpirf program lpirf, eclass args xx lindpro nlags irflag * compute IRFs local irflagp1 = `irflag'+1 mat bbb = J(`irflagp1',1,0) forvalues h = 0/`irflag' { local hp1 = `h'+1 qui reg F`h'.xx L(0/`nlags').xx L(1/`nlags').lindpro, r mat bbb[`hp1',1] = _b[xx] } tempname bb matrix `bb'=bbb' ereturn clear ereturn post `bb' ereturn local cmd="bootstrap" end lpirf xx lindpro `nlags' `irflag' matrix list e(b) bootstrap _b, reps(100) nowarn nodrop: lpirf xx lindpro `nlags' `irflag'
Now, I could easily compute the standard errors of the impulse responses in a different way, however, ultimately I want to bootstrap the historical decomposition, which is yet again a function of the impulse responses and the data:
Code:
cap drop hdlindpro gen hdlindpro = 0 forvalues h = 1/`irflag' { qui replace hdlindpro = hdlindpro + bbb[`h',1]*L`h'.xx } mkmat hdlindpro if hdlindpro!= . , matrix(histdec)
Many thanks in advance and all the best,
Diego
0 Response to Bootstrap local projections impulse responses/historical decompositions
Post a Comment