Page 1 of 1

Fry and Pagan (2011)

PostPosted: Wed Feb 24, 2010 9:17 am
by KOBE24
Dear Tom,

I am trying to apply Fry and Pagan (2011) criterion to a system in which I identify 3 shocks (demand, supply, monetary policy).
Before I start trying to write my own code, I would like to know if you have some suggestion or recommendation.

Thanks in advance for answering.

Re: Fry and Pagan (2011)

PostPosted: Thu Feb 25, 2010 6:05 am
by TomDoan
I'm not really convinced about the value of the idea. Note that all the code that we have done with sign restrictions computes error decompositions and historical decompositions using consistent sets of shocks. The whole idea is to get a range of possible values; not a single one.

Re: Fry and Pagan (2011)

PostPosted: Wed Mar 03, 2010 12:24 pm
by KOBE24
Dear Tom,

I see your point. But, apparently, no paper written using sign restrictions can be carefully evaluated by a referee without
performing such robustness criterion...

Re: Fry and Pagan (2011)

PostPosted: Wed Mar 03, 2010 3:03 pm
by TomDoan
KOBE24 wrote:Dear Tom,

I see your point. But, apparently, no paper written using sign restrictions can be carefully evaluated by a referee without
performing such robustness criterion...


I remain unconvinced but this will do the Fry-Pagan optimization, except that it doesn't normalize the penalty function for scale. That should be a fairly minor change.

Code: Select all
*
* Replication File for Uhlig(2005), "What are the effects of monetary
* policy on output? Results from an agnostic identification procedure",
* Journal of Monetary Economics, 52, pp 381-419.
*
* Fry-Pagan optimization
*
open data uhligdata.xls
calendar(m) 1965:1
data(format=xls,org=columns) 1965:1 2003:12 $
   gdpc1 gdpdef cprindex totresns bognonbr fedfunds
*
set gdpc1    = log(gdpc1)*100.0
set gdpdef   = log(gdpdef)*100.0
set cprindex = log(cprindex)*100.0
set totresns = log(totresns)*100.0
set bognonbr = log(bognonbr)*100.0
*
system(model=varmodel)
variables gdpc1 gdpdef cprindex fedfunds bognonbr totresns
lags 1 to 12
end(system)
estimate(noprint)
*
source uhligfuncs.src
*
dec vect[strings] vl(6)
compute vl=||"real GDP","GDP price defl","Comm. Price Ind.",$
   "Fed Funds Rate","Nonborr. Reserv.","Total Reserves"||
*
* n1 is the number of draws from the posterior of the VAR
* n2 is the number of draws from the unit sphere for each draw for the VAR
* nvar is the number of variables
* nstep is the number of IRF steps to compute
* KMAX is the "K" value for the number of steps constrained
*
compute n2=50000
compute nkeep=1000
compute nvar=6
compute nstep=60
compute KMIN=1
compute KMAX=5
*
* Most draws are going to get rejected. We allow for up to nkeep good
* ones. The variable accept will count the number of accepted draws.
* GOODRESP will be a RECT(nsteps,nvar) at each accepted draw.
*
declare vect[rect] goodresp(nkeep)
declare vector ik a(nvar) ones(nvar)
*
impulse(noprint,model=varmodel,factor=%decomp(%sigma),results=impulses,steps=nstep)
compute accept=0
infobox(action=define,progress,lower=1,upper=n2) $
   "Monte Carlo Integration"
do subdraws=1,n2
   *
   * Do the subdraws over the unit sphere. These give the weights on the
   * orthogonal components.
   *
   compute a=%ransphere(nvar)
   *
   * Check that the responses have the correct signs for steps 1 to
   * KMAX+1 (+1 because in the paper, the steps used 0-based
   * subscripts, rather than the 1 based subscripts used by RATS).
   *
   if UhligAccept(a,KMIN,KMAX+1,||+4,-3,-2,-5||)==0
      goto reject
   *
   * This is an accepted draw. Copy the information out. If we have
   * enough good ones, drop out of the overall loop.
   *
   compute accept=accept+1
   dim goodresp(accept)(nstep,nvar)
   ewise goodresp(accept)(i,j)=ik=%xt(impulses,i)*a,ik(j)
   infobox(current=subdraws)
   if accept>=nkeep
      break
:reject
end do subdraws
infobox(action=remove)
*
dec vect[series] targets(nvar)
do i=1,nvar
   set targets(i) 1 nstep = 0.0
   smpl 1 accept
   do k=1,nstep
      set work = goodresp(t)(k,i)
      compute frac=%fractiles(work,||.50||)
      compute targets(i)(k)=frac(1)
   end do k
end do i
*
dec vect g(nvar-1)
compute g=%fill(nvar-1,1,1.0)
nonlin g
dec real gap
find(trace) min gap
   compute a=%stereo(g)
   compute gap=0.0
   do k=1,nstep
      compute gap=gap+%normsqr(%xt(targets,k)-%xt(impulses,k)*a)
   end do k
end find
*
set resp 1 nstep = 0.0
spgraph(vfields=3,hfields=2,$
  hlabel="Figure 14. Impulse Responses; Fry-Pagan Minimizers")
do i=1,nvar
   set resp 1 nstep = ik=%xt(impulses,t)*a,ik(i)
   graph(ticks,number=0,picture="##.##",header="Impulse Responses for "+vl(i))
   # resp 1 nstep
end do i
*
spgraph(done)