Graphing impulse responses w/ error bands to selected shocks

Questions and discussions on Vector Autoregressions

Graphing impulse responses w/ error bands to selected shocks

Postby res84529 » Tue Aug 30, 2011 2:00 am

Hello,

I want to graph the impulse response functions to selected shocks. But I find even the revised procedure @mcgraphirf doesn't offer such choice unless I choose "byshock" in the page option and stack the several columns of produced graphs in the word file, which seems awkward. Can you give me some advice to revise the @mcgraphirf procedure or other solutions so that I can graph the irfs with error bands to only selected shocks?

code file is attached
Attachments
unitshock_diffscale.txt
(4.97 KiB) Downloaded 77 times
res84529
 
Posts: 11
Joined: Sat Aug 27, 2011 1:56 am

Re: Graphing impulse responses w/ error bands to selected sh

Postby TomDoan » Wed Aug 31, 2011 4:00 pm

The number of shocks you save in %%RESPONSES doesn't have to match with the number of variables. The following, for instance, will save only the first two---it uses %xsubmat to take the first two columns out of the step j matrix of impulse responses.

Code: Select all
   dim %%responses(draw)(nvar*2,nstep)
   compute weights(draw)=weight
   ewise %%responses(draw)(i,j)=ix=%vec(%xsubmat(%xt(impulses,j),1,nvar,1,2)),ix(i)
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

To several shocks which are not consecutive in order

Postby res84529 » Sat Sep 03, 2011 7:47 pm

Hi, Tom!

Thank you very much for your quick reply! I really appreciate that!

The solution works if I want to graph the two columns which are consecutive in the order. But what is needed is to stack the responses to the 3rd, 6th, and 7th shocks only in one graph without adding responses to other shocks. Could you still give me some suggestions on how to do this?

Thank you!
res84529
 
Posts: 11
Joined: Sat Aug 27, 2011 1:56 am

Re: Graphing impulse responses w/ error bands to selected sh

Postby TomDoan » Wed Sep 07, 2011 11:00 am

That would be done with

Code: Select all
   dim %%responses(draw)(nvar*3,nstep)
   compute weights(draw)=weight
   ewise %%responses(draw)(i,j)=xt=%xt(impulses,j),ix=%vec(%xcol(xt,3)~%xcol(xt,6)~%xcol(xt,7)),ix(i)
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Some remaining questions

Postby res84529 » Sun Sep 25, 2011 5:31 am

Hi Tom,

Thank you so much for your help!

I also tried horizontal concatenation with the following code before I looked at your answer:
ewise %%responses(draw)(i,j)=ix=%vec(%xsubmat(%xt(acumirf,j),1,nvar,3,3)~%xsubmat(%xt(acumirf,j),1,nvar,6,7)),ix(i)

It works. In addition, I'm confused about the meaning of the part of the code which is originally from UG p. 498:
impulses((i-1)/nvar+1,%clock(i,nvar))(j)

Could you please explain to me what's the meaning of "(i-1)/nvar+1,%clock(i,nvar)"? what's the use of it?
In addition, why should we repeat with another ix(i) after already defining it in the ewise instruction above since there's no such requirement in the standard ewise instruction setup?

Best Regards
res84529
 
Posts: 11
Joined: Sat Aug 27, 2011 1:56 am

Re: Some remaining questions

Postby TomDoan » Mon Sep 26, 2011 1:35 pm

res84529 wrote:Hi Tom,

Thank you so much for your help!

I also tried horizontal concatenation with the following code before I looked at your answer:
ewise %%responses(draw)(i,j)=ix=%vec(%xsubmat(%xt(acumirf,j),1,nvar,3,3)~%xsubmat(%xt(acumirf,j),1,nvar,6,7)),ix(i)

It works. In addition, I'm confused about the meaning of the part of the code which is originally from UG p. 498:
impulses((i-1)/nvar+1,%clock(i,nvar))(j)

Could you please explain to me what's the meaning of "(i-1)/nvar+1,%clock(i,nvar)"? what's the use of it?


The set of impulse responses would best be represented as a three dimensional array (step, shock, target variable) and we need one matrix like that per draw, so you really would want a four dimensional array. Lacking that, you need to map everything down to fewer dimensions. In this case, it's a VECTOR (over the draws) of RECT, which is a two-dimensional array with steps in the columns and shocks x target variables in the rows. With the combined subscripts blocked by shocks, the (i-1)/nvar+1 maps the combined subscripts to the target variable and %clock(i,nvar) to the shock. The coding for this in the RATS v8 UG is the simpler:

ewise %%responses(draw)(i,j)=ix=%vec(%xt(impulses,j)),ix(i)

which does exactly the same thing.

res84529 wrote:In addition, why should we repeat with another ix(i) after already defining it in the ewise instruction above since there's no such requirement in the standard ewise instruction setup?

Best Regards


EWISE has an internal loop over i and j and needs to have an expression which evaluates to a single number. The IX calculation creates a VECTOR based upon desired value of the J subscript (which is the step); IX(I) then takes the Ith element out of that to make %%responses(draw)(i,j)
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm


Return to VARs (Vector Autoregression Models)

Who is online

Users browsing this forum: No registered users and 1 guest

cron