Page 1 of 1

MCVARDoDraws - Procedure for drawing IRF's by Monte Carlo

PostPosted: Fri Jul 17, 2009 3:07 pm
by TomDoan
The attached is a procedure which was largely taken out of the MonteVar procedure. This does the draws only, leaving the graphing and other analysis to other procedures (particularly MCGraphIRF).

MCVARDoDraws does a Choleski factorization, though it can easily be adapted to other situations. Its options are:

MODEL=model to analyze [required, should already be estimated]
STEPS=number of response steps[48]
DRAWS=number of Monte Carlo draws[1000]
ACCUMULATE=list of variables (by position) to accumulate [none]

The ACCUMULATE option allows you to estimate the VAR in differences, then convert the impulse responses to the responses of the levels. For instance, ACCUMULATE=||1|| will "undifference" the 1st variable.

MCVARDoDraws defines the global %%responses in the format used by MCGraphIRF and some other procedures. It does not directly produce any output.

Minor revision 8 April 2011

mcvardodraws.src
Minor revision 8 April 2011
(3.72 KiB) Downloaded 184 times


If you want to replace the Choleski factorization with some other one, that is done at the following location in the procedure. We would recommend that you first make a renamed copy of the procedure file before editing:

Code: Select all
   *
   * The next line is where a particular factorization of sigmad is
   * input into the calculation. This does the Choleski factorization in
   * standard order, which is what is used above in drawing the
   * coefficients.
   *
   compute factor=fsigmad


Instead of factor=fsigmad, you want factor = whatever your factor matrix is. An example is the following, which uses a factorization with short and long-run restrictions:

Code: Select all
compute phiinv=inv(%modellagsums(model))
@ShortAndLong(lr=lr,sr=sr,masum=phiinv) sigmad factor


The LR and SR matrices need to be passed into the procedure in some way; adding them as options to your new procedure is probably the best way to handle that. So you would include the following among the options:

Code: Select all
option rect LR
option rect SR

Re: MCVARDoDraws - Procedure for drawing IRF's by Monte Carlo

PostPosted: Sun Sep 20, 2009 3:39 am
by MC128
Hi Tom,

Do you know how to modify the MCVARDoDraws to factorization other than the choleski?? Should I include the A and B matrix (i.e. A and B matrix from SVAR) into the procedure?

And would the mean impulse response be the same as the point estimate from the OLS?

Thanks!

MC

Re: MCVARDoDraws - Procedure for drawing IRF's by Monte Carlo

PostPosted: Mon Sep 21, 2009 10:16 am
by TomDoan
MC128 wrote:Hi Tom,

Do you know how to modify the MCVARDoDraws to factorization other than the choleski?? Should I include the A and B matrix (i.e. A and B matrix from SVAR) into the procedure?


Code: Select all
      compute sigmad  =%ranwisharti(fwish,wishdof)
      compute fsigmad =%decomp(sigmad)


The first of these draws a sigma matrix from the unconditional distribution. The second creates a factor of that. It's that second instruction that need to be replaced to create a different factor. That could be with a CVMODEL instruction, which would include the FACTOR=FSIGMAD option.

MC128 wrote:And would the mean impulse response be the same as the point estimate from the OLS?


Other than for the first step, no. Once you've done MC integration, the mean or median of the drawn responses is a better estimate than the point estimate from OLS.

Re: MCVARDoDraws - Procedure for drawing IRF's by Monte Carlo

PostPosted: Mon Sep 21, 2009 8:12 pm
by MC128
Hi Tom,

Thanks for your reply. I have tried your suggestion...but the programme crashes.....Is the following command correctly writen?

May I also ask whether the Rats could draw bootstrapped confidence interval?

Many thanks.

MC

Code: Select all
source ABDraws.src
source MCGraphIRF.src
*
compute nstep=25
compute nshocks=3
dec vect[strings] cl(nshocks)
compute cl=||"GDP","Expenditure","Revenue"||
*
dec vect[strings] vl(3)
compute vl=||"GDP","Expenditure","Revenue"||
*
dec frml[rect] afrml bfrml
nonlin aey ary aye ayr bre ber
*
*assume structural revenue shock have no impact on structural spending shock - ber = 0
*if assume structural spending shock have no impact on structural revenue shock - bre = 0
*
*
frml afrml = ||1.0,-aye,-ayr|$
               -aey,1.0,0.0|$
               -ary,0.0,1.0||

frml bfrml = ||1.0,0.0,0.0|$
               0.0,1.0,ber|$
               0.0,bre,1.0||
*
system(model=varmodel)
variables gdp govspendb revenue
lags 1 to 4
det constant
end(system)
estimate(noprint)
*
compute aye=ayr=bre=0
nonlin aey=0.0 ary=0.25 aye ayr bre ber=0.0

cvmodel(a=afrml,b=bfrml,method=bfgs,pmethod=genetic,piters=20,factor=swish) %sigma
@varirf(model=varmodel,step=nstep,vlabels=vl,byshocks,factor=swish)


@ABDraws(model=varmodel,step=nstep)
@MCGraphIRF(model=varmodel,varlabels=vl,shocklabels=cl,$
  page=byshock,stddev=1.0,columns=1,include=||1,2,3||)

Re: MCVARDoDraws - Procedure for drawing IRF's by Monte Carlo

PostPosted: Mon Sep 21, 2009 9:25 pm
by TomDoan
Redo the

Code: Select all
estimate(noprint)


right before doing the @abdraws call. The procedure is expecting that the last estimation is estimation of the VAR.

There's an example of bootstrapping for a VAR in the Sims and Zha replications.

Re: MCVARDoDraws - Procedure for drawing IRF's by Monte Carlo

PostPosted: Mon Sep 21, 2009 9:56 pm
by MC128
Hi Tom,

For unknow reason, the Rats programme crash again.....I have attached the programme for your reference....many thanks.

MC

Re: MCVARDoDraws - Procedure for drawing IRF's by Monte Carlo

PostPosted: Tue Sep 22, 2009 10:31 am
by TomDoan
Aren't you getting a message that AFRML isn't defined? You're trying to source the abdraws procedure before AFRML and BFRML (which are referenced in it) have been defined. If you get rid of those two early source instructions (which you don't need anyway), it should work.