RATS 10.1
RATS 10.1

Before using @MCGraphIRF, @MCProcessIRF or @MCFEVDTable, you have to fill in the global array %%responses which has the following structure:

It is a VECT[RECT] with the dimension of the VECT being NDRAWS. Each element of the VECT gives the entire generated response for one draw.

For each draw, the response is put into a RECT with NVAR*NSHOCKS rows and NSTEPS columns. NVAR is the number of endogenous variables in the model, NSTEPS is the number of steps of responses. NSHOCKS is the number of shocks, which is usually the same as NVAR, but doesn’t have to be.

The rows in the RECT for saving the draw are blocked by shocks, so the first set of NVAR elements in a column are the responses to the first shock, the second set are the responses to the second shock. If you %VEC a set of impulse responses produced by IMPULSE, that's how they will be blocked.

 

The following shows a typical way that this can be created:

 

Outside the draw loop (ndraws is the number of draws being made):

 

declare vect[rect] %%responses

dim %%responses(ndraws)

 

Inside of it (draw is the current draw number), use either the FLATTEN option on IMPULSE:

 

impulse(noprint,model=model,factor=fsigmad,flatten=%%responses(draw),steps=steps)

 

or use the following to pack the information from the RESULTS option in the proper form:

 

impulse(noprint,model=model,factor=fsigmad,results=impulses,steps=steps)

dim %%responses(draw)(nvar*nvar,steps)

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

If you need to save a different "shape" of response (different number of shocks than targets), make sure you dimension the elements properly. For instance, the following "interleaves" two full sets of impulse responses, so there are twice as many shocks as targets.

 

dim %%responses(draw)(%rows(impulses1)*%cols(impulses1)*2,steps)

ewise %%responses(draw)(i,j)=ix=%vec(%xt(impulses1,j)~~%xt(impulses2,j)),ix(i)


In the EWISE instruction, the %XT(IMPULSES,J) extracts the NVAR \(\times\) NSHOCKS matrix of responses at step J, the %VEC then “flattens” that into a VECTOR with the proper organization. The elements of that VECTOR are then copied into the proper slots in the %%RESPONSES(DRAW) matrix.

 


Copyright © 2025 Thomas A. Doan