Near-VAR with sign restrictions

Questions and discussions on Vector Autoregressions
Yashodha
Posts: 35
Joined: Wed May 04, 2016 12:30 am

Near-VAR with sign restrictions

Unread post by Yashodha »

Hi,
I am trying to do a near-VAR with sign restrictions. I am fairly new to RATS as well as to sign restrictions.

So to get a basic understanding of how to do the coding, I modified the 'mujasetup' file in the RATS Mountford Uhlig JAE 2009 paper replication example (modified file is named as 'setup' and is attached). In the modified file, the rgdp, rbpexp and rbprev variables are foreign variables while the ffrt, ares, ppic, gdpdef, rcon, rnresinv, and wage are domestic variables. The domestic variables cannot affect the foreign variables.

I used this setup file to run the mu2009x1 file (attached as SIGN_NEARVAR) and I got the following error message.
"## MAT2. Matrices with Dimensions 21 x 10 and 168 x 10 Involved in + Operation
The Error Occurred At Location 90, Line 8 of loop/block"

This is probably because I didn't modify the mu2009x1 file to fit for a near-VAR but I have no idea how to do it. I would highly appreciate if you could let me know whether I have done any error in my setup file and how to modify the mu2009x1 file.

Best regards,
Last edited by Yashodha on Fri Jul 26, 2019 1:39 am, edited 1 time in total.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Near-VAR with sign restrictions

Unread post by TomDoan »

You can't use the same method for drawing coefficients for a near VAR vs a full VAR. That's discussed in the User's Guide. See the MONTESUR.RPF example.
Yashodha
Posts: 35
Joined: Wed May 04, 2016 12:30 am

Re: Near-VAR with sign restrictions

Unread post by Yashodha »

Hi,

Thank you very much for your reply. I did a near-VAR model with sign restrictions (with four orthogonal shocks). There are three foreign variables and five domestic variables. I have incorporated the 'Gibbs sampling' technique as you suggested, but I am getting the following error message.
"The Error Occurred At Location 68, Line 7 of loop/block
## MAT14. Non-invertible Matrix. Using Generalized Inverse for SYMMETRIC.
The Error Occurred At Location 195, Line 13 of loop/block
## MAT14. Non-invertible Matrix. Using Generalized Inverse for SYMMETRIC."

When I run the model with a full-VAR, the model works. I can't figure-out what is the mistake I have made. I have attached the sign-restriction model file, setup file and the data file. Really appreciate if you could help me to correct my code.

Thank you.
Last edited by Yashodha on Fri Jul 26, 2019 1:39 am, edited 1 time in total.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Near-VAR with sign restrictions

Unread post by TomDoan »

You left these is your setup file, but they're specifically for an OLS VAR. They need to be deleted (or at least commented out).

*
* This is the standard setup for MC integration of an OLS VAR
*
compute sigmad =%sigma
compute sxx =%decomp(%xx)
compute svt =%decomp(inv(%nobs*%sigma))
compute betaols=%modelgetcoeffs(varmodel)
compute ncoef =%rows(sxx)
compute wishdof=%nobs-ncoef
Yashodha
Posts: 35
Joined: Wed May 04, 2016 12:30 am

Re: Near-VAR with sign restrictions

Unread post by Yashodha »

Dear Tom,

Thank you very much for your reply. I revised the codes as per your suggestion and it works. I also added codes to get historical decomposition graphs and FEVD tables. However, I seems to be having some problems with the output.
(a) If I run the model twice, I don't get the same results. Visually, the IRF graphs and HD graphs remains more or less the same. But if I compare the numbers in FEVD tables, they are somewhat different each time I run the model. What could be the reason?
(b) In the HD graphs, why the error bands become wider towards the latter part of the time period considered, particularly in domestic variables? Also, could you explain a little bit on how I should be interpreting the HD graphs.

Once again, I thank you immensely for the support you have given me so far.
Last edited by Yashodha on Fri Jul 26, 2019 1:40 am, edited 1 time in total.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Near-VAR with sign restrictions

Unread post by TomDoan »

Error bands on historical decompositions are typically pretty wide even when a shock is constructed from a specific model, and even more when they're being generated by simulations. However, the big problem that you have is that your INT variable has rather bizarre behavior which can't easily be explained by the model. As a result, the dynamic forecasts of it end up being all over the place; sometimes explosive up, sometimes explosive down, depending upon the simulation of the model coefficients. If the forecast for 2014:4 is (say) +40, some combinations of shocks has to account for the gap between +40 and the actual +10. And if the forecast is -40 instead, then the shocks need to provide a +50 contribution. Your results are within simulation error when you have a model as potentially unstable as this.
Yashodha
Posts: 35
Joined: Wed May 04, 2016 12:30 am

Re: Near-VAR with sign restrictions

Unread post by Yashodha »

Hi,

I want to plot both median and median target in the same IRF graphs. Could you please advise me on how to amend my code? Also, how can obtain the FEVD and historical graphs using the median target approach?

Thanking you in advance.
Last edited by Yashodha on Fri Jul 26, 2019 1:40 am, edited 1 time in total.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Near-VAR with sign restrictions

Unread post by TomDoan »

The median target calculation is the same for a near-VAR as for a regular VAR---it's a post-simulation calculation. Because of how it's computed, you can't do a FEVD or historical decomposition based upon it.
Yashodha
Posts: 35
Joined: Wed May 04, 2016 12:30 am

Re: Near-VAR with sign restrictions

Unread post by Yashodha »

Dear Tom,

Thank you very much for your kind reply. In fact, I was following Jaaskela and Smith (2011) paper (attached) and they present the FEVD and HD graphs based on a 'median target model'. Would you be able to explain what they have done in their paper?
Last edited by Yashodha on Fri Jul 26, 2019 1:43 am, edited 2 times in total.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Near-VAR with sign restrictions

Unread post by TomDoan »

I have no idea where they get bands on the FEVD from the median target calculation, since the median target calculation uses fixed coefficients and a fixed covariance matrix. You'd have to ask the authors. Actually you can get point estimates for the FEVD and for the historical decomposition for the median target by using the coefficients and covariance matrix from the SUR estimates of the near-VAR. Whether they're at all interesting is a different question. (I think the whole median-target idea is grossly overhyped).
Yashodha
Posts: 35
Joined: Wed May 04, 2016 12:30 am

Re: Near-VAR with sign restrictions

Unread post by Yashodha »

Dear Tom,

Thanks for your prompt reply and I understand what you say. I have amended my code to incorporate both the median and median target in my impulse responses. However, I have made a mistake somewhere though I can't figure-out what it is. When I run the model several times, the set of IRF graphs I get are very different from one another. Could you please help me to correct my model.
Last edited by Yashodha on Fri Jul 26, 2019 1:40 am, edited 1 time in total.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Near-VAR with sign restrictions

Unread post by TomDoan »

That's not how the median target method works. You just do the sign-restriction simulations on the point estimates of the model, not on simulated covariance matrices/coefficient vectors. (That's one of the reasons that I think the whole thing is overhyped.) You need to get rid of that outer loop and increase the number of subdraws.

The median target method is covered in the 2nd edition of the VAR e-course..
Yashodha
Posts: 35
Joined: Wed May 04, 2016 12:30 am

Re: Near-VAR with sign restrictions

Unread post by Yashodha »

Dear Tom,

Sorry for bothering you like this. But I am somewhat confused now.

A) According to Fry and Pagan (2011), median target technique selects a unique model that produces impulse responses that are closest to the median responses (paper attached - page 950-951). Then, median target should be calculated using the same simulation that we use to get our median response, isn't it? Then why should we get rid of the outer loop?

B) When I run previous versions of my model (i.e. without the median target part), I get different set of IRF graphs and FEVDs each time I run the model (at least there are minor differences). Is it because of a problem with my data set (though I replaced my INT variable with a new series as per your earlier comment) or is it a common problem that comes along with simulation? Is there a way to retain/save one set of IRF graphs so that every time I run the model, I would get consistent results?

Please bear with me for having so many questions like this. Your support is truly appreciated.
Last edited by Yashodha on Fri Jul 26, 2019 1:41 am, edited 1 time in total.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Near-VAR with sign restrictions

Unread post by TomDoan »

Yashodha wrote:Dear Tom,

Sorry for bothering you like this. But I am somewhat confused now.

A) According to Fry and Pagan (2011), median target technique selects a unique model that produces impulse responses that are closest to the median responses (paper attached - page 950-951). Then, median target should be calculated using the same simulation that we use to get our median response, isn't it? Then why should we get rid of the outer loop?
No. The median is being generated by different simulations from different covariance matrix/coefficient combinations. The median target has to be generated from a specific combination. (You can't do the optimization otherwise).
Yashodha wrote: B) When I run previous versions of my model (i.e. without the median target part), I get different set of IRF graphs and FEVDs each time I run the model (at least there are minor differences). Is it because of a problem with my data set (though I replaced my INT variable with a new series as per your earlier comment) or is it a common problem that comes along with simulation? Is there a way to retain/save one set of IRF graphs so that every time I run the model, I would get consistent results?
Use a SEED instruction.
Yashodha
Posts: 35
Joined: Wed May 04, 2016 12:30 am

Re: Near-VAR with sign restrictions

Unread post by Yashodha »

Dear Tom,

Thanks a lot for your reply. So if I want to plot both median and median target in the same IRF graph, I should run 2 simulations within the same program.
1. Simulation of covariance matrix/coefficients combinations to get the median.
2. Simulation on point estimates of the model to get the median target.
And then I plot both in the same graph. Is that the correct approach?

Then how can I plot the upper and lower error bands? Should I consider the upper and lower bands from the first simulation or the second simulation?
Post Reply