Manual confidence intervals for impulse response functions

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

heer0
Posts: 22
Joined: Sat May 04, 2019 11:23 am

Manual confidence intervals for impulse response functions

Postby heer0 » Sat Jul 06, 2019 12:38 pm

Hi guys,

I am using EViews 10 (Univ. ed.) and I programmed an algorithm to construct impulse response functions from a factor-augmented vector autoregression in keeping with Bernanke et al. (2005).

I would now like to construct bootstrapped confidence intervals for my impulse response graphs. My current code is this:

Code: Select all

'Make a group of all 148 informational time series, ordering slow-moving variables first group xt [...] 'Convert group "xt" into a matrix object matrix data = @convert(xt) 'Now extract the first three pc from the entire dataset- The "cor" option implies that the data need not be standardized before pc estimation xt.pcomp (cor, eigval=v1, eigvec=m1) pc1 pc2 pc3 'Now make a group out of the 99 slow-moving variables group xt_slow [...] 'Now extract the first three prinicpal components from the slow-moving variables xt_slow.pcomp (cor, eigval=v1s, eigvec=m1s) pc1s pc2s pc3s 'Factor rotation. OLSE of pc# on pc1s, pc2s, pc3s and policy variables equation eq1.ls pc1 c pc1s pc2s pc3s iec shadow imp equation eq2.ls pc2 c pc1s pc2s pc3s iec shadow imp equation eq3.ls pc3 c pc1s pc2s pc3s iec shadow imp 'Now remove the impact of ffr from pc1, pc2 and pc3 series pc1n = pc1 - (eq1.@coefs(5)*iec) - (eq1.@coefs(6)*shadow) - (eq1.@coefs(7)*imp) series pc2n = pc2 - (eq2.@coefs(5)*iec) - (eq2.@coefs(6)*shadow) - (eq2.@coefs(7)*imp) series pc3n = pc3 - (eq3.@coefs(5)*iec) - (eq3.@coefs(6)*shadow) - (eq3.@coefs(7)*imp) 'The next step estimates a VAR with 2 lags using the rotated factors pc1n, pc2n and pc3n as well as iec, shadow, imp var favar.ls 1 2 pc1n pc2n pc3n iec shadow imp favar.impulse(60, m, matbys = irf) pc1n pc2n pc3n iec shadow imp @ iec shadow imp 'irf is 60*36, where the first 18 columns contain the impulse responses to shocks in pc1n, pc2n, and pc3n 'estimate the coefficients relating the data and pc1n, pc2n, pc3n, iec, shadow, and imp via OLS matrix(148,6) weights 'creates a matrix that will hold the proper weights group pcn pc1n pc2n pc3n matrix xx=@convert(pcn) 'new matrix containing the three factors scalar j for j=1 to 99 'loop over the 99 slow-moving variables 'Left-hand side of the regression (number of columns equal number of principal components in var) matrix yy=@subextract(data,1,j,@rows(data),j) 'this sets up the jth column of data for estimation matrix btemp=@inverse(@transpose(xx)*xx)*(@transpose(xx)*yy) weights(j,1)=btemp(1,1) weights(j,2)=btemp(2,1) weights(j,3)=btemp(3,1) 'the previous three lines save the weights next group pcn1 pc1n pc2n pc3n iec shadow imp matrix xx1=@convert(pcn1) 'matrix with three factors and iec shadow imp for j=100 to 148 'loop over the 49 fast-moving variables 'Left-hand side of the regression yy=@subextract(data,1,j,@rows(data),j) 'jth column of data matrix (number of rows equals number of unobservable and observable factors in var) btemp=@inverse(@transpose(xx1)*xx1)*(@transpose(xx1)*yy) weights(j,1)=btemp(1,1) weights(j,2)=btemp(2,1) weights(j,3)=btemp(3,1) weights(j,4)=btemp(4,1) 'note coefficients relating to iec and data weights(j,5)=btemp(5,1) 'note coeffeicients relating to shadow and data weights(j,6)=btemp(6,1) 'note coefficients relating to imp and data next 'Construct the impulse responses of all the underlying variables to a shock in iec matrix irf1=@subextract(irf, 1, 19, 60, 24) 'irf of pc1n, pc2n and pc3n iec shadow imp to iec matrix irfmat1=irf1*@transpose(weights) irfmat1.write(t=xls) irfmat1.xls 'weights is 146*6, @transpose weights is 6*146 'Construct the impulse responses of all the underlying variables to a shock in shadow matrix irf2=@subextract(irf, 1, 25, 60, 30) 'irf of pc1n, pc2n and pc3n iec shadow imp to shadow matrix irfmat2=irf2*@transpose(weights) irfmat2.write(t=xls) irfmat2.xls 'Construct the impulse responses of all the underlying variables to a shock in imp matrix irf3=@subextract(irf, 1, 31, 60, 36) 'irf of pc1n, pc2n and pc3n iec shadow imp to imp matrix irfmat3=irf3*@transpose(weights) irfmat3.write(t=xls) irfmat3.xls
Any help on how to construct confidence intervals in this case will be highly appreciated!

Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests