Sign Restrictions with zero constraints
Sign Restrictions with zero constraints
Dear Tom,
I am trying to impose zero constraints with sign restrictions. There are three foreign variables and four domestic variables in my model. I want to impose two domestic shocks which will not affect the three foreign variables in the impact period. I have ordered the three foreign variables before the domestic variables. I have coded the two shocks as below.
***********************************************
* First Domestic Shock
************************************************
compute [vector] v1=%zeros(3,1)~~%ransphere(nvar-3)
if UhligAccept(v1,KMIN,KMAX,||+4,+5,+6||)==0
goto reject
compute i1=sigmap*v1
*****************************************************
* Second Domestic Shock
*****************************************************
dec rect rirf1(1,nvar)
ewise rirf1(i,j)=ix=%xt(impulses,i),ix(1,j)
dec rect rirf2(1,nvar)
ewise rirf2(i,j)=ix=%xt(impulses,i),ix(2,j)
dec rect rirf3(1,nvar)
ewise rirf3(i,j)=ix=%xt(impulses,i),ix(3,j)
compute forcedcols=i1~sigmap*(tr(rirf1)~tr(rirf2)~tr(rirf3))
@forcedfactor(force=column) sigmad forcedcols ffactor
compute r2=inv(sigmap)*%xsubmat(ffactor,1,nvar,%cols(forcedcols)+1,nvar)
compute [vector] v2=r2*(%zeros(3,1)~~%ransphere(nvar-4))
if UhligAccept(v2,KMIN,KMAX,||-4,+5,-6||)==0
goto reject
compute i2=sigmap*v2
*******************************************************************************
But I get the following error message.
'## MAT2. Matrices with Dimensions 7 x 3 and 6 x 1 Involved in * Operation
The Error Occurred At Location 1640, Line 55 of loop/block'
Could you please help me to correct my code.
Thank you.
I am trying to impose zero constraints with sign restrictions. There are three foreign variables and four domestic variables in my model. I want to impose two domestic shocks which will not affect the three foreign variables in the impact period. I have ordered the three foreign variables before the domestic variables. I have coded the two shocks as below.
***********************************************
* First Domestic Shock
************************************************
compute [vector] v1=%zeros(3,1)~~%ransphere(nvar-3)
if UhligAccept(v1,KMIN,KMAX,||+4,+5,+6||)==0
goto reject
compute i1=sigmap*v1
*****************************************************
* Second Domestic Shock
*****************************************************
dec rect rirf1(1,nvar)
ewise rirf1(i,j)=ix=%xt(impulses,i),ix(1,j)
dec rect rirf2(1,nvar)
ewise rirf2(i,j)=ix=%xt(impulses,i),ix(2,j)
dec rect rirf3(1,nvar)
ewise rirf3(i,j)=ix=%xt(impulses,i),ix(3,j)
compute forcedcols=i1~sigmap*(tr(rirf1)~tr(rirf2)~tr(rirf3))
@forcedfactor(force=column) sigmad forcedcols ffactor
compute r2=inv(sigmap)*%xsubmat(ffactor,1,nvar,%cols(forcedcols)+1,nvar)
compute [vector] v2=r2*(%zeros(3,1)~~%ransphere(nvar-4))
if UhligAccept(v2,KMIN,KMAX,||-4,+5,-6||)==0
goto reject
compute i2=sigmap*v2
*******************************************************************************
But I get the following error message.
'## MAT2. Matrices with Dimensions 7 x 3 and 6 x 1 Involved in * Operation
The Error Occurred At Location 1640, Line 55 of loop/block'
Could you please help me to correct my code.
Thank you.
Re: Sign Restrictions with zero constraints
You're trying to mix two different ways of handling the zero restrictions when picking the second shock. You don't want or need the %zeros(3,1) in that because the forcedcols are already taking care of the zero restrictions.
Re: Sign Restrictions with zero constraints
Dear Tom,
Thanks for your advice. I have corrected the code as per your suggestion.
Now I am trying to get the median target, but I get very weird lines for the median target measures, especially for the second and third shocks. The median target is completely out of the error bands in some IRF graphs and does not even have the correct sign.
I think the problem lies with the optimization part. In the optimization output, the initial 'old' and 'new functions' have extremely large values for the second and third optimization. At the end of the optimization, the function values are as large as 1.5527e+018.
I don't know how to correct this problem. Truly appreciate if you could help.
Thank you.
Thanks for your advice. I have corrected the code as per your suggestion.
Now I am trying to get the median target, but I get very weird lines for the median target measures, especially for the second and third shocks. The median target is completely out of the error bands in some IRF graphs and does not even have the correct sign.
I think the problem lies with the optimization part. In the optimization output, the initial 'old' and 'new functions' have extremely large values for the second and third optimization. At the end of the optimization, the function values are as large as 1.5527e+018.
I don't know how to correct this problem. Truly appreciate if you could help.
Thank you.
Last edited by Yashodha on Fri Jul 26, 2019 1:38 am, edited 1 time in total.
Re: Sign Restrictions with zero constraints
Have you found any paper that has done median target responses for 2nd and 3rd shocks? Offhand, I can't think of how you could even do that. The median target calculation is based upon choosing an impulse vector from a fixed factorization, which only exists when picking the first shock. The second and later shocks are chosen from a "floating" universe of shocks which depend upon the shocks chosen earlier.
Note also that even for the first shock, the median target response can be outside the error bounds and can have the wrong sign.
Note also that even for the first shock, the median target response can be outside the error bounds and can have the wrong sign.
Re: Sign Restrictions with zero constraints
Dear Tom,
Fry and Pagan (2009) paper has median and median target responses for all three shocks (in a three variable VAR) (page 22). To my understanding, they have done their optimization across all three shocks and across all variables to select one model which has impulse responses closest to the medians (page 21).
So, is it possible to do this optimization in RATS? If possible, how should I change my code to achieve that optimization?
Thanking you in advance.
Fry and Pagan (2009) paper has median and median target responses for all three shocks (in a three variable VAR) (page 22). To my understanding, they have done their optimization across all three shocks and across all variables to select one model which has impulse responses closest to the medians (page 21).
So, is it possible to do this optimization in RATS? If possible, how should I change my code to achieve that optimization?
Thanking you in advance.
Re: Sign Restrictions with zero constraints
You would have to figure out how to parameterize the space of orthonormal matrices that will satisfy your zero restrictions. And I don't believe that's mathematically possible. From the VAR course:
It’s important to note that, while the order is unimportant (except perhaps for
efficiency) if you are doing multiple unrestricted shocks, that is no longer the
case if you have multiple shocks with one or more having zero restrictions as
well. It’s easiest to see that if, for instance, you are doing a full set of four
shocks in a four variable model. If one has a zero restriction, it simply can’t
be ordered last—if you’ve already chosen three shocks, there are no “degrees of
freedom” left to choose that last shock. Thus, there is no way to force the zero
restriction in addition to orthogonality to the first three shocks. It’s possible for
the restricted shock to be the first, second or third shock chosen, but the distribution
will be different depending upon where you order it. This is unavoidable
if you want a combination of multiple shocks with zero restrictions.
Re: Sign Restrictions with zero constraints
Dear Tom,
Thank you for your reply. I understand your point. However, this is not an issue since I have 7 variables in my model and I have only 3 shocks specified by sign and zero restrictions.
But my question is, once I have simulated model and selected the admissable shocks how should I do the optimization problem to select the model that is closest to all the medians across all shocks and variables. So far, I have been trying to do this optimization for each shock separately, which I believe is not right.
So could you explain, how I can modify the Fry-Pagan example file in the RATS course to get the median targets, if we have multiple shocks specified by the sign restrictions?
Thank you for your reply. I understand your point. However, this is not an issue since I have 7 variables in my model and I have only 3 shocks specified by sign and zero restrictions.
But my question is, once I have simulated model and selected the admissable shocks how should I do the optimization problem to select the model that is closest to all the medians across all shocks and variables. So far, I have been trying to do this optimization for each shock separately, which I believe is not right.
So could you explain, how I can modify the Fry-Pagan example file in the RATS course to get the median targets, if we have multiple shocks specified by the sign restrictions?
Re: Sign Restrictions with zero constraints
That doesn't matter. The issue is that the zero restrictions make the selection of shocks depend upon the order. The example just demonstrates that.
The Fry-Pagan example uses Givens matrices (of which there would be 21 in a seven variable system), but those (1) wouldn't be able to handle the zero constraints and (2) aren't designed to isolate just three shocks out of seven.
The Fry-Pagan example uses Givens matrices (of which there would be 21 in a seven variable system), but those (1) wouldn't be able to handle the zero constraints and (2) aren't designed to isolate just three shocks out of seven.
Re: Sign Restrictions with zero constraints
Dear Tom,
Sorry to bother you like this.
Assume, there are no zero restrictions in the model, but there are multiple shocks specified by the sign restrictions. Then, how should we modify the Fry-Pagan example file to get the median target across all shocks (or at least the shocks specified by sign restrictions)?
Thanking you in advance.
Sorry to bother you like this.
Assume, there are no zero restrictions in the model, but there are multiple shocks specified by the sign restrictions. Then, how should we modify the Fry-Pagan example file to get the median target across all shocks (or at least the shocks specified by sign restrictions)?
Thanking you in advance.
Re: Sign Restrictions with zero constraints
My suggestion is that you contact Fry and/or Pagan. You're trying to extend their work. Perhaps they've either thought about it, or have seen papers by someone else who has done this first. The issue is that while there are ways to parameterize an entire orthogonal matrix, I'm not aware of any straightforward way to get three columns out of an 7 x 7 orthonormal matrix, except through a sequential process, and that wouldn't lend itself to optimization. You could overparameterize it by doing the whole matrix, but then you would have multiple sets of parameters which would lead to the same objective function.
Re: Sign Restrictions with zero constraints
Dear Tom,
My supervisor is keen on seeing a median target measure - i.e. impulse responses coming from a singe model across all shocks so that I can ensure that measure is actually representing orthogonal shocks (if I use the mean, it comes from different different models so I cannot be sure of the orthogonality of the shocks).
So, he suggested that I should at least show the impulse responses coming from the single model that was selected through the optimization for one shock (if I can't optimize across all shocks). I understand that I have to use the weights of the selected model to weight all my impulse responses but I do not know how to achieve this on RATS. My supervisor has never used RATS so he can't help me on this.
I would truly appreciate if you can explain how to weight all my impulse responses using the weights of a single model (after the optimization) and to save them for later use.
Thanking you in advance.
My supervisor is keen on seeing a median target measure - i.e. impulse responses coming from a singe model across all shocks so that I can ensure that measure is actually representing orthogonal shocks (if I use the mean, it comes from different different models so I cannot be sure of the orthogonality of the shocks).
So, he suggested that I should at least show the impulse responses coming from the single model that was selected through the optimization for one shock (if I can't optimize across all shocks). I understand that I have to use the weights of the selected model to weight all my impulse responses but I do not know how to achieve this on RATS. My supervisor has never used RATS so he can't help me on this.
I would truly appreciate if you can explain how to weight all my impulse responses using the weights of a single model (after the optimization) and to save them for later use.
Thanking you in advance.
Re: Sign Restrictions with zero constraints
That doesn't make any sense. The "weights" for picking the first shock generate one and only one shock. They can't be used to generate three.
Re: Sign Restrictions with zero constraints
Dear Tom,
But can we pick out a model from the admissible models obtained from the simulation based on the weight of first shock and see the impulse responses generated by that particular model for the other sign restricted shocks.
But can we pick out a model from the admissible models obtained from the simulation based on the weight of first shock and see the impulse responses generated by that particular model for the other sign restricted shocks.
Re: Sign Restrictions with zero constraints
No. A single shock isn't a "model". FP's concept of a model is a complete factorization of the covariance matrix. You have to pick a complete factorization, not just one shock (or, for that matter, three out of seven).
Re: Sign Restrictions with zero constraints
Thank you very much for your explanation.