MCVARDoDraws - Procedure for drawing IRF's by Monte Carlo

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

MCVARDoDraws - Procedure for drawing IRF's by Monte Carlo

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

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 LRoption rect SR`
TomDoan

Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

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

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
MC128

Posts: 36
Joined: Tue Jun 16, 2009 5:55 am

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

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.
TomDoan

Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

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

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.srcsource MCGraphIRF.src*compute nstep=25compute nshocks=3dec vect[strings] cl(nshocks)compute cl=||"GDP","Expenditure","Revenue"||*dec vect[strings] vl(3)compute vl=||"GDP","Expenditure","Revenue"||*dec frml[rect] afrml bfrmlnonlin 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 revenuelags 1 to 4det constantend(system)estimate(noprint)*compute aye=ayr=bre=0nonlin aey=0.0 ary=0.25 aye ayr bre ber=0.0cvmodel(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||)`
Attachments
ABDraws.src
changing the MCVARDoDraws.src to alternative factorization
MC128

Posts: 36
Joined: Tue Jun 16, 2009 5:55 am

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

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.
TomDoan

Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

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

Hi Tom,

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

MC
Attachments
fiscalshocks(bp).PRG
MC128

Posts: 36
Joined: Tue Jun 16, 2009 5:55 am

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

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.
TomDoan

Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm