MCGRAPHIRF (revised)

Use this forum to post complete RATS "procedures". Please be sure to include instructions on using the procedure and detailed references where applicable.

MCGRAPHIRF (revised)

Postby TomDoan » Wed Mar 23, 2011 5:29 pm

This is a revised version of the MCGRAPHIRF procedure. MCGRAPHIRF organizes graphs for the output from various procedures which draw impulse response functions. Among the version 8 examples which use this are:

  1. BOOTVAR.RPF (boot strapping a VAR)
  2. MONTESUR.RPF (Gibbs sampling for a near-VAR)
  3. MONTESVAR.RPF (Gibbs sampling for an overidentified SVAR)
  4. MONTEVAR.RPF (standard Monte Carlo integration for an OLS VAR)

By separating the tasks of generating the impulse responses (done by a variety of methods) and organizing the graphs (done by MCGRAPHIRF), we can provide greater flexibility in the graphics. The newest option is

[COMMONSCALE]/NOCOMMONSCALE

which allows you (with NOCOMMONSCALE) to override the standard behavior of making all responses of a particular variable graphed using the same scale.

mcgraphirf.src
Procedure file
(11.98 KiB) Downloaded 160 times


If you want the calculations of the confidence bands without the graphs, use MCPROCESSIRF

http://www.estima.com/forum/viewtopic.php?f=7&t=996
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: MCGRAPHIRF (revised)

Postby TWG » Wed May 04, 2011 9:01 am

Tom, I have one question, how can I get a table with the values of
the graph of the irf using mcgraphirf, with upper, lower and the center values.

Best regards


W
TWG
 
Posts: 12
Joined: Tue Jun 29, 2010 1:19 pm

Re: MCGRAPHIRF (revised)

Postby TomDoan » Wed May 04, 2011 10:24 am

You would use MCPROCESSIRF. I edited the original message to include a link to it.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: MCGRAPHIRF (revised)

Postby WALLE » Wed Aug 17, 2011 2:31 am

Hi,

I'm running a 6 variable VAR as in below and I'm trying to compute the confidence intervals for Impulse responses. I looked up at the User guide and read up about the Monte Carlo procedure. I carried out the procedure using the following code and I obtained the graphs. However, the graphs are too many; 36 on a page resulting in the output being very tiny to read. And I really would like to have just the response of all variables to one shock per page instead of the present 6X6 format. How do I go about this?

Here is my code:


Code: Select all
***************************************************************
*SET UP/ESTIMATE VAR SYSTEM
***************************************************************
compute neqn = 6
compute nlags = 2
compute nsteps = 12
compute ndraws = 10000

system(model=canvar)
variables OILP CAN_CPI_INF CAN_GDEF_INF CAN_WAG_INF CAN_OUTPUT CAN_UR
lags 1 to nlags
det constant
end(system)

estimate(noprint,resids=varresidscan)

******************************************************************
*GENERATE IRF AND CONFIDENCE INTERVAL USING MONTE CARLO
******************************************************************
compute nvar   =%nvar
compute fxx    =%decomp(%xx)
compute fwish  =%decomp(inv(%nobs*%sigma))
compute wishdof=%nobs-%nreg
compute betaols=%modelgetcoeffs(canvar)

declare vect[rect] %%responses(ndraws)
declare rect[series] impulses(nvar,nvar)

infobox(action=define,progress,lower=1,upper=ndraws) "Monte Carlo Integration"
do draw=1,ndraws

   if %clock(draw,2)==1 {
      compute sigmad  =%ranwisharti(fwish,wishdof)
      compute fsigma  =%decomp(sigmad)
      compute betau   =%ranmvkron(fsigma,fxx)
      compute betadraw=betaols+betau
   }
   else
      compute betadraw=betaols-betau
   *
   * Push the draw for the coefficient back into the model.
   *
   compute %modelsetcoeffs(canvar,betadraw)
     results=impulses,steps=nsteps)
   *
   * Save the impulse responses
   *
   dim %%responses(draw)(nvar*nvar,nsteps)
   ewise %%responses(draw)(i,j)=ix=%vec(%xt(impulses,j)),ix(i)
   infobox(current=draw)
end do draw
infobox(action=remove)

@MCGRAPHIRF(MODEL=CANVAR)
WALLE
 
Posts: 14
Joined: Thu Jul 21, 2011 12:24 pm

Re: MCGRAPHIRF (revised)

Postby TomDoan » Wed Aug 17, 2011 7:43 am

WALLE wrote:Hi,

I'm running a 6 variable VAR as in below and I'm trying to compute the confidence intervals for Impulse responses. I looked up at the User guide and read up about the Monte Carlo procedure. I carried out the procedure using the following code and I obtained the graphs. However, the graphs are too many; 36 on a page resulting in the output being very tiny to read. And I really would like to have just the response of all variables to one shock per page instead of the present 6X6 format. How do I go about this?

Here is my code:


Code: Select all
***************************************************************
*SET UP/ESTIMATE VAR SYSTEM
***************************************************************
compute neqn = 6
compute nlags = 2
compute nsteps = 12
compute ndraws = 10000

system(model=canvar)
variables OILP CAN_CPI_INF CAN_GDEF_INF CAN_WAG_INF CAN_OUTPUT CAN_UR
lags 1 to nlags
det constant
end(system)

estimate(noprint,resids=varresidscan)

******************************************************************
*GENERATE IRF AND CONFIDENCE INTERVAL USING MONTE CARLO
******************************************************************
compute nvar   =%nvar
compute fxx    =%decomp(%xx)
compute fwish  =%decomp(inv(%nobs*%sigma))
compute wishdof=%nobs-%nreg
compute betaols=%modelgetcoeffs(canvar)

declare vect[rect] %%responses(ndraws)
declare rect[series] impulses(nvar,nvar)

infobox(action=define,progress,lower=1,upper=ndraws) "Monte Carlo Integration"
do draw=1,ndraws

   if %clock(draw,2)==1 {
      compute sigmad  =%ranwisharti(fwish,wishdof)
      compute fsigma  =%decomp(sigmad)
      compute betau   =%ranmvkron(fsigma,fxx)
      compute betadraw=betaols+betau
   }
   else
      compute betadraw=betaols-betau
   *
   * Push the draw for the coefficient back into the model.
   *
   compute %modelsetcoeffs(canvar,betadraw)
     results=impulses,steps=nsteps)
   *
   * Save the impulse responses
   *
   dim %%responses(draw)(nvar*nvar,nsteps)
   ewise %%responses(draw)(i,j)=ix=%vec(%xt(impulses,j)),ix(i)
   infobox(current=draw)
end do draw
infobox(action=remove)

@MCGRAPHIRF(MODEL=CANVAR)


@MCGRAPHIRF has quite a few options for formatting graphs. You might want to read the comments at the top of the MCGRAPHIRF.SRC file. What you're looking for is the option PAGE=BYSHOCK.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: MCGRAPHIRF (revised)

Postby WALLE » Wed Aug 17, 2011 11:54 am

Thanks Tom. Worked like magic :D
WALLE
 
Posts: 14
Joined: Thu Jul 21, 2011 12:24 pm


Return to RATS Procedures

Who is online

Users browsing this forum: No registered users and 1 guest