## Identification by Sign-Restrictions PLUS Zero-Restrictions

Questions and discussions on Vector Autoregressions

### Identification by Sign-Restrictions PLUS Zero-Restrictions

I am trying to implement code for an SVAR with identification of multiple shocks by a combination of sign-restrictions and zero-restrictions.

I am trying to modify the code from the replication files for Mountford and Uhlig (2009). I am struggling with doing this for nshocks>1.

I modified the code for identification of the first part by restricting the rotation vector as follows:
Code: Select all
`      ************************************************      * First in Order - Supply Shock      ************************************************      compute [vector] v1=%zeros(1,1)~~%ransphere(nvar-1)      if UhligAccept(v1,KMIN,KMAX,||+2,-3||)==0         goto reject      compute i1=p*v1`

By this I can make sure that the first variable does not respond on impact to the first structural shock.

The code goes on with forcing i1 as one column in the factorization ...
Code: Select all
`      @forcedfactor(force=column) sigmad i1 f      compute r2=inv(p)*%xsubmat(f,1,nvar,2,nvar)`

... and identifying the next shock:
Code: Select all
`      *****************************************************      *  Second in Order - Demand Shock      *****************************************************      compute [vector] v2=r2*%ransphere(nvar-1)      if UhligAccept(v2,KMIN,KMAX,||+1,+2,+3||)==0         goto reject      compute i2=p*v2`

The point at which I am struggling is how to impose the same zero-restriction also for this second shock (variable 1 should not respond also to the second shock on impact). How can I find the second rotation vector such that its first element is 0 and that it "fits" to the first one in terms of the orthogonality condition? I couldn't find any example in the replication section that uses a similar identification scheme.
jonasdovern

Posts: 97
Joined: Sat Apr 11, 2009 10:30 am

### Re: Identification by Sign-Restrictions PLUS Zero-Restrictio

Isn't the mu2009b2.rpf example largely on point? It has zero restrictions on the fiscal policy shocks. You just have to do the restrictions based upon the impulse responses even if they're just impact restrictions.
TomDoan

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

### Re: Identification by Sign-Restrictions PLUS Zero-Restrictio

Thanks, Tom, for pointing me to the panelty-function example with delayed shocks. I hadn't browsed these as I want to use the "pure sign-restriction approach" and did not find them via a text search.

Translating this code worked out well. I am posting my code below as an example for other RATS users that want to estimate similar models. (This is based on a four-variable VAR and the initial response of the first variable to the first and the second shock is restricted to be equal to zero.)
Code: Select all
`*** Setup for Structural Estimationdec vect[strings] vl(10)compute vl=||"Infl. Exp.","GDP","CPI","Policy Rate"||compute nvar  =4compute nstep =40compute nkeep=1000compute n1   =500compute n2   =1000compute KMIN  =1compute KMAX  =2** Compute scale factors for impulse responses*compute [vector] scales=%sqrt(%xdiag(%sigma))** This is the standard setup for MC integration of an OLS VAR*compute sigmad =%sigmacompute sxx    =%decomp(%xx)compute svt    =%decomp(inv(%nobs*%sigma))compute betaols=%modelgetcoeffs(mu_model_1)compute ncoef  =%rows(sxx)compute wishdof=%nobs-ncoef*dec vect[rect] %%responsesdim %%responses(nkeep)*dec rect[series] impulsesdeclare series[rect] irfsquared*source uhligfuncs.src** Parameter vectors for the nested optimization problems. They should* have a size equal to nvar less 1 + the number of constraints imposed* prior to their estimation. Those prior constraints can be* orthogonality to previous shocks, or can be zero restrictions.*compute nshocks=3dec vect[strings] sl(nshocks)compute sl=||"Supply","Demand","Monetary Policy"||********************************************************************************declare vector ik a(nvar) ones(nvar)compute ones=%const(1.0)source forcedfactor.src*infobox(action=define,progress,lower=1,upper=n1) "Monte Carlo Integration"compute accept=0do draw=1,n1   *   * Make a draw from the posterior for the VAR and compute its impulse   * responses.   *   compute sigmad  =%ranwisharti(svt,wishdof)   compute p       =%decomp(sigmad)   compute betadraw=betaols+%ranmvkron(p,sxx)   compute %modelsetcoeffs(mu_model_1,betadraw)   *   impulse(noprint,model=mu_model_1,factor=p,results=impulses,steps=nstep)   *   do subdraw=1,n2      ************************************************      * First in Order - Supply Shock      ************************************************      compute [vector] v1=%zeros(1,1)~~%ransphere(nvar-1)      if UhligAccept(v1,KMIN,KMAX,||+2,-3||)==0         goto reject      compute i1=p*v1      *      *****************************************************      *  Second in Order - Demand Shock      *****************************************************      dec rect r(1,nvar)      ewise r(i,j)=ix=%xt(impulses,i),ix(1,j)      @forcedfactor(force=column) sigmad i1~p*tr(r) f      compute r2=inv(p)*%xsubmat(f,1,nvar,2,nvar)      compute [vector] v2=r2*(%zeros(1,1)~~%ransphere(nvar-2))      if UhligAccept(v2,KMIN,KMAX,||+1,+2,+3||)==0         goto reject      compute i2=p*v2      *      *****************************************************      *  Third in Order - Monetary Policy Shock      *****************************************************      @forcedfactor(force=column) sigmad i1~i2 f      compute r3=inv(p)*%xsubmat(f,1,nvar,3,nvar)      compute [vector] v3=r3*(%ransphere(nvar-2))      if UhligAccept(v3,KMIN,KMAX,||+2,+3,-4||)==0         goto reject      compute i3=p*v3      *      * Meets all restrictions      *      compute accept=accept+1      dim %%responses(accept)(nshocks*nvar,nstep)      *      * Save the desired sets of linear combinations of the Choleski      * responses      *      compute vweights=v1~v2~v3      ewise %%responses(accept)(i,j)=(ik=%vec(%xt(impulses,j)*vweights)),ik(i)      if accept>=nkeep         break   :reject   end do subdraw   if accept>=nkeep      break   infobox(current=draw)   :newdrawend do drawinfobox(action=remove)disp "Acceptances" accept "on" draw "main draws"`
jonasdovern

Posts: 97
Joined: Sat Apr 11, 2009 10:30 am

### Re: Identification by Sign-Restrictions PLUS Zero-Restrictio

Dear jonasdovern,

Thank you very much for sharing this!
My question might be trivial: how do you restrict the initial response to a shock of the first and second variable to zero?
Since I am new to RATS, I do not see immediately in your code what imposed the zero restriction...

economarvell

Posts: 4
Joined: Thu Aug 10, 2017 10:18 am

### Re: Identification by Sign-Restrictions PLUS Zero-Restrictio

In the above, this is the processing for the second shock. This has to be orthogonal to the first shock, and also the design is to have it have a zero impact on the variable 1:

dec rect r(1,nvar)
ewise r(i,j)=ix=%xt(impulses,i),ix(1,j)
compute r2=inv(p)*%xsubmat(f,1,nvar,2,nvar)
compute [vector] v2=r2*(%zeros(1,1)~~%ransphere(nvar-2))

A somewhat cleaner way to write the last three lines is

compute forcedcols=i1~p*tr(r)
compute r2=inv(p)*%xsubmat(f,1,nvar,%cols(forcedcols)+1,nvar)
compute v2=r2*%ransphere(%cols(r2))

If you look at the current versions of the Mountford-Uhlig examples, you'll see them written that way and you should probably work off those rather than this.

The R is what codes up the zero impact restriction(s). In this case, there's just one. If you want to change this to force zero impacts on 1 and 2, you would need

dec rect r(2,nvar)
ewise r(i,j)=ix=%xt(impulses,1),ix(i,j)

The "i" in the above example was taken from an example that did multiple steps on a single variable---now it does multiple variables at a single step (%xt(impulses,1) is the N x N matrix of impacts with shocks in the columns and variables in the rows).
TomDoan

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

### Re: Identification by Sign-Restrictions PLUS Zero-Restrictio

Dear Tom,

I tried implementing the code for only one shock but got an "## SX11. Identifier I1 is Not Recognizable." error which I could not work around...
My idea is to identify only one shock and restrict the signs on impact of the first, second and sixth variable to zero while implementing sign restrictions for the remaining ones. Would you kindly have any advice on doing so with your code above?

Kind regards and many thanks!
economarvell

Posts: 4
Joined: Thu Aug 10, 2017 10:18 am

### Re: Identification by Sign-Restrictions PLUS Zero-Restrictio

i1 doesn't exist when you're picking the first shock. You have no sign restrictions on the first shock? Three zero restrictions isn't going to be much of a restriction (for instance, it doesn't fix the sign of any response, and will give roughly equal +/- signs on all the other impacts).
TomDoan

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

### Re: Identification by Sign-Restrictions PLUS Zero-Restrictio

I do have three sign restrictions and three zero restrictions on the first and only identified shock. There is only one unrestricted variable.
Shouldn't this work?
economarvell

Posts: 4
Joined: Thu Aug 10, 2017 10:18 am

### Re: Identification by Sign-Restrictions PLUS Zero-Restrictio

If you work off the newer versions of the Mountford-Uhlig programs, your first shock would be done with something like (this is for the rejection method):

compute step0=%xt(impulses,1)
compute rirf=%xrow(step0,1)~~%xrow(step0,2)~~%xrow(step0,6)
compute forcedcols=sigmap*tr(rirf)
compute r1=inv(sigmap)*%xsubmat(ffactor,1,nvar,%cols(forcedcols)+1,nvar)
compute [vector] v1=r1*%ransphere(%cols(r1))
goto reject
compute i1=sigmap*v1
TomDoan

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

### Re: Identification by Sign-Restrictions PLUS Zero-Restrictio

Dear Tom,

is it possible to retrieve the parameters of the underlying reduced form VAR?
Moreover, when changing variables in the model, I get the following error message

"## MAT1. Matrix %%RESPONSES(2) Has Not Been Dimensioned
The Error Occurred At Location 776, Line 43 of loop/block"

where the number after RESPONSES differs from iteration to iteration. Would you know what the matter is?
economarvell

Posts: 4
Joined: Thu Aug 10, 2017 10:18 am

### Re: Identification by Sign-Restrictions PLUS Zero-Restrictio

economarvell wrote:Dear Tom,

is it possible to retrieve the parameters of the underlying reduced form VAR?

I'm not sure what you mean. Sign restrictions very specifically don't have a model.

economarvell wrote:Moreover, when changing variables in the model, I get the following error message

"## MAT1. Matrix %%RESPONSES(2) Has Not Been Dimensioned
The Error Occurred At Location 776, Line 43 of loop/block"

where the number after RESPONSES differs from iteration to iteration. Would you know what the matter is?

Sounds like you never set NSHOCKS which is the number of shocks you're saving

dim %%responses(accept)(nshocks*nvar,nstep)
TomDoan

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

### Re: Identification by Sign-Restrictions PLUS Zero-Restrictio

Dear Tom,

I am struggling in understanding whether the IRFs of my VAR are satisfying my desired mix of zero and sign restrictions. As a matter of fact, I feel I am doing something wrong in imposing the zeros (i.e. building the matrices), but I hope to clarify in a second.

I basically have a 5 variables VAR model (oil price, policy rate, term spread, consumer prices and real GDP in that order just to have a candidate Cholesky as a starting point with some convenient choices for imposing zeros). I rely on codes based on Mountford -Uhlig (2009) and your suggestions (as I understood them).
1. The first thing I want to do is to impose that an aggregate supply shock has a zero impact on oil price (in order to disentangle "real" supply from oil supply disturbances)
2. the second one is to identify a spread compression shock (Baumeister & Benati, IJCB 2013), and to do so I put a zero on the policy rate.
3. finally, when looking at oil supply shocks, I also want to impose that they do not move the term spread on impact (zerio restriction).

Below is my code. Could you please tell me whether it is correct, based also on the graph that I am attaching? In particular, I do not get whether by using the constraints I posted below I should also see restricted to zero, for example, oil price in the unconventional monetary shock. In this case, I could have "well behaved" IRFs just by chance.

Thanks in advance for your time and help, I am really struggling on a deadline because of this.

Code: Select all
`   do subdraw=1,n2******* =========================================================== ************** First in Order - Domestic supply shock (one zero on oil price)               ************** =========================================================== *******      compute [vector] v1=%zeros(1,1)~~%ransphere(4)      if UhligAccept(v1,KMIN,KMAX,||+2,+4,-5||)==0         goto reject      compute i1=p*v1******* =========================================================== ************** Second in Order - Unconventional MP shock(one zero on rate)              ************** =========================================================== *******      dec rect r(1,nvar)      ewise r(i,j)=ix=%xt(impulses,i),ix(2,j)      @forcedfactor(force=column) sigmad i1~p*tr(r) f      compute r2=inv(p)*%xsubmat(f,1,nvar,2,nvar)      compute [vector] v2=r2*(%zeros(1,1)~~%ransphere(nvar-2))      if UhligAccept(v2,KMIN,KMAX,||-3,+4,+5||)==0        goto reject      compute i2=p*v2    ******* =========================================================== ************** Third in Order - Oil Supply Shock (one zero on tspread)                        ************** =========================================================== *******      dec rect r(1,nvar)      ewise r(i,j)=ix=%xt(impulses,i),ix(3,j)      @forcedfactor(force=column) sigmad i1~i2~p*tr(r) f      compute r3=inv(p)*%xsubmat(f,1,nvar,3,nvar)      compute  [vector] v3 = r3*(%zeros(1,1)~~%ransphere(nvar-3))      if UhligAccept(v3,KMIN,KMAX,||+1,+4,-5||)==0        goto reject      compute i3=p*v3      *dis v3`
Attachments IRFS_for_TomDoan.pdf
KOBE24

Posts: 51
Joined: Tue Jul 21, 2009 9:10 am

### Re: Identification by Sign-Restrictions PLUS Zero-Restrictio

Hi Tom,

I am trying to estimate a 5 variable VAR using sign and zero restrictions. I am following Mountford and Uhlig (2009) penalty function replication file with delayed shocks.
I'm struggling to modify the code such that both first and second variable are restricted to 0 on impact.
I get that replacing 1 with 2 in ewise will impose zero restriction on variable 2. But I want to impose zero restriction on variable 1 and 2 both.

dec rect rirf(KZERO,nvar)
ewise rirf(i,j)=ix=%xt(impulses,i),ix(1,j)
compute forcedcols=i1x~sigmap*tr(rirf)
compute r2x=inv(sigmap)*%xsubmat(ffactor,1,nvar,%cols(forcedcols)+1,nvar)

If I restrict two variables to 0 , the parameter vector for (let's say) second identification would also change?
compute [vect] g1x=%fill(nvar-1,1,1.0) #1st identified shock
compute [vect] g2x=%fill(nvar-3,1,1.0) #2nd identified shock
Size of parameter for 2nd identified shock would then be nvar-4 for additional zero restriction.

Also, how should the 1st identified shock be modified such that the first shock also imposes zero constraints on variable 1 and 2?
dec rect rirf(KZERO,nvar)
ewise rirf(i,j)=ix=%xt(impulses,i),ix(1,j)
nonlin g1x
find(noprint,pmethod=genetic,piters=50,method=simplex) min func
compute v1x=%stereo(g1x)
compute func=UhligPenalty(v1x,KMIN,KMAX,||-3,+4||)
end find
compute i1x=sigmap*v1x
sak777

Posts: 1
Joined: Tue Feb 27, 2018 2:53 am