Anzuini, Lombardi and Pagano (2013, IJCB)

If you are seeking RATS code for implementing a particular technique or replicating results from a paper, post your request here. Be sure to include complete citations for any papers or books.
samprop3
Posts: 4
Joined: Wed Mar 19, 2014 7:10 pm

Anzuini, Lombardi and Pagano (2013, IJCB)

Unread post by samprop3 »

Hi, I'm a complete novice with the RATS software and am having a few issues trying to replicate the model in Anzuini, Lombardi and Pagano (2013, IJCB)- The Impact of Monetary Policy Shocks on Commodity Prices. The structural identification used in their paper is based on Kim (1999) after identifying the monetary policy shock the marginal method is used to trace the response of an individual commodity price [Both specifications can be found here: http://postimg.org/image/bm0txte8p/].

I have attempted to code a CVMODEL based on the helpful examples and some of the threads in the forums but I am having a few issues getting beyond the first identification scheme [my code is attached]. I would really appreciate some help with regards to the issues in my code and how I would go about moving from identifying the shock to adding in the individual commodity prices and tracing the price response. Thanks in advance!
Attachments
Anzuini.rtf
(1.16 KiB) Downloaded 783 times
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Anzuini, Lombardi and Pagano (2013, IJCB)

Unread post by TomDoan »

That looks fine. Did you Select All and Run or did you try to execute a line at a time? The latter isn't generally a good idea with already written programs as it's really easy for execution to get behind and miss a line.
samprop3
Posts: 4
Joined: Wed Mar 19, 2014 7:10 pm

Re: Anzuini, Lombardi and Pagano (2013, IJCB)

Unread post by samprop3 »

I was executing line by line! I will try to run the whole thing when I get back to my desktop.
samprop3
Posts: 4
Joined: Wed Mar 19, 2014 7:10 pm

Re: Anzuini, Lombardi and Pagano (2013, IJCB)

Unread post by samprop3 »

Hi Tom,

I've edited the code for Uhlig(2005) sign restricted irfs [Uhlig2.rpf] to match the Anzuini VAR specification. However, the literature generally shows the irfs to 100 basis point monetary policy shocks. How would I go about specifying the size of the impulse in the code?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Anzuini, Lombardi and Pagano (2013, IJCB)

Unread post by TomDoan »

The following would standardize the shock in the uhlig2.rpf program to be unit impact on the interest rate series (# 4 in the model). Note that you can't use the standardized shocks for doing the FEVD. (The first and last are already existing---the comments and the compute [vector] ... need to be added).

dim goodresp(accept)(i,j)=...
*
* Standardize shock to unit on interest rate
*
compute [vector] impact=%xt(impulses,1)*a,a=a/impact(4)
ewise goodresp(accept)(i,j)=...
samprop3
Posts: 4
Joined: Wed Mar 19, 2014 7:10 pm

Re: Anzuini, Lombardi and Pagano (2013, IJCB)

Unread post by samprop3 »

Just what I was after! Thanks
IRJ
Posts: 48
Joined: Wed Jan 10, 2007 1:15 am

Re: Anzuini, Lombardi and Pagano (2013, IJCB)

Unread post by IRJ »

To follow up on the first entry in this thread, I am posting below my coding attempt at replicating Anzuini, Lombardi and Pagano (2013). Sepcifically, the code below modifies MONTEVAR.RPF (After reading a number of Tom's responses on the forum) to obtain the responses to a negative 100 basis point decrease in the Federal funds rate (FFR) (as the authors do) along with their Confidence Intervals. The MONTEVAR.RPF is modified using:

Code: Select all

compute fsigma2 = fsigma*inv(%diag(%xdiag(fsigma)))
to obtain a one unit shock (1%) to the FFR and

Code: Select all

compute flipper = ||-1.0,1.0,1.0,1.0,1.0||
as well as:

Code: Select all

 compute fsigma3 = fsigma2*%diag(flipper)
to obtain the negative FFR shock. Given that I reconstructed the authors' data, the magnitudes of the responses are off (so is the shape for the CPI and the commodity price index). The responses I obtain are attached. I am posting this just in case it is useful for those of you trying to work with the paper's VAR model.

Code: Select all

*
* MONTEVAR.RPF for Anzuini, Lombardi and Pagano (2013)
* RATS Version 8, User's Guide, Example 16.2
* Monte Carlo Integration of Impulse Responses
*
compute lags=12				;*Number of lags
compute nstep=50			;*Number of response steps
compute ndraws=10000		        ;*Number of keeper draws
*
calendar(m) 1970:01
allocate 2008:12
OPEN DATA "C:\Replications VAR Commodities\Anzuini, Lombardi and Pagano (2013)\ALP_Data.xlsx"
DATA(FORMAT=XLSX,ORG=COLUMNS) 1970:01 2008:12 CPI FFR IP M2 CRB_BLS Oil
*
**Obtain log levels of variables
set lm2 = log(m2)
set lcpi = log(cpi)
set lcrb = log(crb_bls)
set lip = log(ip)
*
system(model=varmodel)
variables ffr lip lm2 lcpi lcrb
lags 1 to lags
det constant
end(system)

******************************************************************
estimate(noprint)
compute nvar   =%nvar
compute fxx    =%decomp(%xx)
compute fwish  =%decomp(inv(%nobs*%sigma))
compute wishdof=%nobs-%nreg
compute betaols=%modelgetcoeffs(varmodel)
*
*
dec frml[rect] afrml
nonlin g12 g15 g21 g23 g24 g34 g51 g52 g53 g54
frml afrml = || 1.0, g12, 0.0, 0.0, g15|$
                g21, 1.0, g23, g24, 0.0|$
                0.0, 0.0, 1.0, g34, 0.0|$
                0.0, 0.0, 0.0, 1.0, 0.0|$
                g51, g52, g53, g54, 1.0||
cvmodel(a=afrml,method=bfgs,iters=1000,factor=fsigma) %sigma

declare vect[rect] %%responses(ndraws)
declare rect[series] impulses(nvar,nvar)

infobox(action=define,progress,lower=1,upper=ndraws) "Monte Carlo Integration"
do draw=1,ndraws
   *
   * On the odd values for <<draw>>, a draw is made from the inverse Wishart
   * distribution for the covariance matrix. This assumes use of the
   * Jeffrey's prior |S|^-(n+1)/2 where n is the number of equations in
   * the VAR. The posterior for S with that prior is inverse Wishart with
   * T-p d.f. (p = number of explanatory variables per equation) and
   * covariance matrix inv(T(S-hat)).
   *
   * Given the draw for S, a draw is made for the coefficients by adding
   * the mean from the least squares estimate to a draw from a
   * multivariate Normal with  (factor of) covariance matrix as the
   * Kroneker product of the factor of the draw for S and a factor of
   * the X'X^-1 from OLS.
   *
   * On even draws, the S is kept at the previous value, and the
   * coefficient draw is reflected through the mean.
   *
   if %clock(draw,2)==1 {
      compute sigmad  =%ranwisharti(fwish,wishdof)
      compute fsigma  =%decomp(sigmad)
      compute betau   =%ranmvkron(fsigma,fxx)
      compute betadraw=betaols+betau
   }
   else
      compute betadraw=betaols-betau
   *
   * Push the draw for the coefficient back into the model.
   *
   compute %modelsetcoeffs(varmodel,betadraw)
   compute fsigma2 = fsigma*inv(%diag(%xdiag(fsigma)))
   compute flipper = ||-1.0,1.0,1.0,1.0,1.0||
   compute fsigma3 = fsigma2*%diag(flipper)

   impulse(noprint,model=varmodel,factor=fsigma3,$
     results=impulses,steps=nstep)
   *
   * Save the impulse responses
	*
   dim %%responses(draw)(nvar*nvar,nstep)
   ewise %%responses(draw)(i,j)=ix=%vec(%xt(impulses,j)),ix(i)
   infobox(current=draw)
end do draw
infobox(action=remove)
*
@mcgraphirf(model=varmodel,page=byshock)

Attachments
ALP_responses.pdf
(85.6 KiB) Downloaded 741 times
Post Reply