Asking the code for sign restrictions

Questions and discussions on Vector Autoregressions
Lee Nguyen
Posts: 7
Joined: Tue May 31, 2016 11:26 pm

Asking the code for sign restrictions

Unread post by Lee Nguyen »

Dear Tom,
Can you help me to correct the code below please? I want to restrict "when Government expenditure (Gt) increases, government expenditure (gt) will increase, Taxes (Tt) will increase, GDP (Yt) will increase and Unemployment rate (Xt) will decrease". My codes are:

Code: Select all

OPEN DATA "E:\metarials  fiscal shocks\data for running model\var6.xls"
CALENDAR(Q) 1984:1
DATA(FORMAT=XLS,ORG=COLUMNS,SHEET="data for VAR (2)") 1984:01 2014:04 Yt Gt Tt Xt It Pt
* detrend by hp filter*
filter(type=hp,tuning=1600) gt / hpgt
set gt = gt-hpgt
filter(type=hp,tuning=1600) tt / hptt
set tt = tt-hptt
filter(type=hp,tuning=1600) yt / hpyt
set yt = yt-hpyt
filter(type=hp,tuning=1600) xt / hpxt
set xt = xt-hpxt
filter(type=hp,tuning=1600) it / hpit
set it = it-hpit
SYSTEM(MODEL=FISCALPOLICY)
VARIABLES GT TT YT XT IT PT
LAGS 1 TO 2
DET
END(SYSTEM)
ESTIMATE 1984:01 2014:04
dec vect[strings] vl(6)
compute vl=||"gt","tt","yt","xt","it","pt"||
*set various limits*
compute nvar  =6
compute nsteps=60
compute nkeep =1000
compute n2    =50000
compute KMIN  =1
compute KMAX  =6
*Compute standard impulse response functions*
compute atilde=%decomp(%sigma)
impulse(model=fiscalpolicy,steps=nsteps,results=impulses,$
factor=atilde,print)
*
dec vect[series] mini(nvar) maxi(nvar)
dec series[vect] oneresp
dec vect a(nvar) atest ik
dec vect[series] impacts(nvar)
*
do i=1,nvar
set impacts(i) 1 nkeep = %na
end do i
*
do i=1,nvar
set mini(i) 1 nsteps = 1.e+10
set maxi(i) 1 nsteps = -1.e+10
end do i
*
compute accept=0
infobox(action=define,progress,lower=1,upper=nkeep) $
"Monte Carlo Integration"
do draws=1,n2
**Take a draw from the unit sphere.*
compute a=%ransphere(nvar)
**Transform back to the original variable space*
compute atest=atilde*a
**Flip the sign if the GE shock is negative*
if atest(1)<0
compute a=-1.0*a
do k=KMIN,KMAX
compute ik=%xt(impulses,k)*a
if ik(1)<0.or.ik(2)<0.or.ik(3)<0.or.ik(4)>0
goto reject
end do k
gset oneresp 1 nsteps = %xt(impulses,t)*a
do i=1,nvar
set maxi(i) 1 nsteps = %max(oneresp{0}(i),maxi(i))
set mini(i) 1 nsteps = %min(oneresp{0}(i),mini(i))
end do i
compute accept=accept+1
compute %pt(impacts,accept,atilde*a)
infobox(current=accept)
if accept==nkeep
break
:reject
end do draws
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Asking the code for sign restrictions

Unread post by TomDoan »

You probably want to think of a better way to describe that than as a government expenditure shock. What you have looks correct. Why do you think anything's wrong?
Lee Nguyen
Posts: 7
Joined: Tue May 31, 2016 11:26 pm

Re: Asking the code for sign restrictions

Unread post by Lee Nguyen »

I followed 7 steps in Sign restrictions chapter in RATs handbook for Vector Autoregressions and based on Uhlig 2005. It looks to be ok but the results (graphs of response) showed not correct with the restrictions. I wonder that the restrictions codes I wrote is not correct.
if atest(1)<0
compute a=-1.0*a
do k=KMIN,KMAX
compute ik=%xt(impulses,k)*a
if ik(1)<0.or.ik(2)<0.or.ik(3)<0.or.ik(4)>0
goto reject
end do k
Do you think so?
Sorry for asking a silly question but I am stuck on my thesis. this is my first work based on RATs model, so sometime I am not profession in this program.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Asking the code for sign restrictions

Unread post by TomDoan »

I'm guessing that you're getting 0 acceptances on the restrictions. (You can do

disp accept

after the end of the draw loop to check that). Unlike the Uhlig and Mountford-Uhlig papers, you're using data that have had most of the serial correlation removed by HP detrending. There's almost no set of data which will allow you to sign-constrain four sets of six-step responses for a VAR in HP-detrended form.
Lee Nguyen
Posts: 7
Joined: Tue May 31, 2016 11:26 pm

Re: Asking the code for sign restrictions

Unread post by Lee Nguyen »

Dear TomDoan,
Thank you for helping me.
I checked the acceptation and it got 422 acceptances.
Do you think with this acceptances, it can be accepted?
Thank so much
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Asking the code for sign restrictions

Unread post by TomDoan »

If you increase N2, you should increase the number of acceptances. (It sounds like you need maybe 150000 to guarantee 1000 acceptances).

However, if you're getting 422 acceptances, the max and min responses will, by construction, have to satisfy your constraints, so you probably aren't interpreting the output correctly.
Lee Nguyen
Posts: 7
Joined: Tue May 31, 2016 11:26 pm

Re: Asking the code for sign restrictions

Unread post by Lee Nguyen »

Thanks Tomdoan for your help.
Can I have an other question about Uhlig2.rpf file. the explanation
"Post-processing. Graph the mean of the responses along with the 16%
* and 84%-iles." and the code " compute frac=%fractiles(work,||.16,.84||)"
can you please explain for me a little bit more why we choose 16% and 84%
many thanks :D
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Asking the code for sign restrictions

Unread post by TomDoan »

16-84 is a "robust" version of one-standard error bands.
Lee Nguyen
Posts: 7
Joined: Tue May 31, 2016 11:26 pm

Re: Asking the code for sign restrictions

Unread post by Lee Nguyen »

Dear Tom,
Can I ask you one question please?
I used Uhligpenalty function for my model and I also tried to use Uhligaccept function. the results of both of them look the same. so what is the differences between Uhligpenalty function and Uhligaccept function?
many thanks
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Asking the code for sign restrictions

Unread post by TomDoan »

The rejection method (done by UhligAccept) and the penalty function (done by UhligPenalty) are two ways to handle sign restrictions. Both are described in the original Uhlig paper. The rejection method requires that there be at least some draws which satisfy all the restrictions, while UhligPenalty doesn't (it finds the shock direction which comes "closest" to meeting them). If it isn't that hard to find acceptable draws, then the two should give similar results.
Lee Nguyen
Posts: 7
Joined: Tue May 31, 2016 11:26 pm

Asking the function in RATs

Unread post by Lee Nguyen »

Dear Tom,
Can you please answer me a question?
I run my model using Uhligpenalty function similar to Mountfort anf Uhlig 2009. however, each time I run the model, the output seems to be a bit different from last output. I think each time I run the model, The result takes one matrix H that need to satisfy H*H’=I. is that right? Do we have any function that can control the random numbers generated process to make sure the result are the same for each run?
Please let me know and this will be very helpful for me.
All the best
Lee Nguyen
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Asking the code for sign restrictions

Unread post by TomDoan »

Yes. SEED. Put it at the top of the program.
Lee Nguyen
Posts: 7
Joined: Tue May 31, 2016 11:26 pm

Re: Asking the code for sign restrictions

Unread post by Lee Nguyen »

Dear Tom,
thank you for your help at last question.
Can you help me to answer another question please?
I now can stimulate the response of other variables to one shock. however, I now want to calculate cumulative response of some variables to this shock. for example, I want to draw the graph of cumulative response of 6 variables in the file attached below. do we have any function to make this response?
Thank you so much
all the best
Lee Nguyen
Attachments
response to deficit tax cut.docx
(26.05 KiB) Downloaded 675 times
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Asking the code for sign restrictions

Unread post by TomDoan »

I have no idea what those are, but if you are using @MCGRAPHIRF, it has an ACCUMULATE option.
Post Reply