Page 1 of 1

Help with Labelling-please

Unread postPosted: Thu Dec 23, 2021 3:38 am
by Ozmando
Hi, trying to label each of the individual graphs (ifrs) based on a 3 variables VARS/llp. What I please need is to have a heading for each of the computed graphs.
The code is a modified version of the original Jorda (2005) where the results of the VAR have been removed.
The code is below:
Thanks
Oz

Code: Select all
*
* Replication file for Jorda(2005), "Estimation and Inference of
* Impulse Responses by Local Projections", American Economic
* Review, vol 95, no 1, 161-182.
*
* New Keynesian Model
*
open data "is_new.csv"
calendar(q) 1955:1
data(format=prn,nolabels,org=columns) 1955:01 2003:01 ygap infl rate
*
@nbercycles(down=down)
spgraph(vfields=3,footer="Figure 4 Time Plots of Output Gap, Inflation, Federal Funds Rate")
 graph(key=below,klabel=||"Output Gap"||,shade=down,picture="##.#")
 # ygap
 graph(key=below,klabel=||"Inflation"||,shade=down,picture="##.#")
 # infl
 graph(key=below,klabel=||"Federal Funds Rate"||,shade=down,picture="##.#")
 # rate
spgraph(done)
*
@varlagselect(lags=8,crit=sbc)
# ygap infl rate
@varlagselect(lags=8,crit=aic)
# ygap infl rate
*
compute nlags=4
*
system(model=basevar)
variables ygap infl rate
lags 1 to nlags
det constant
end(system)
*
compute varlabels=||"Y-Gap","Inflation","Fed Funds"||
*
estimate
compute nregeqn=%nreg
*
* This sets the shocks to be used and the labels for the graph. In
* this case, the shocks are Cholesky shocks, so they are associated
* 1-1 with the variables. To use different shocks, change the way
* <<fshock>> is computed and make the required adjustment to the
* <<shocklabels>>
*
compute nstep=12
compute fshock=%decomp(%sigma)
compute nshock=%cols(fshock)
compute shocklabels=||"Y-Gap","Inflation","Fed Funds"||
*
* Do the shocks using the standard VAR methods, saved into baseirf
*
impulse(steps=nstep+1,factor=fshock,model=basevar,results=baseirf)
*
dec rect pix(%nvar,%nvar) pixvar(%nvar,%nvar)
dec rect[series] linprjirf(%nvar,nshock)
dec rect[series] linprjstderr(%nvar,nshock)
clear(length=nstep+1) linprjirf linprjstderr
dec rect deltawt(%nregsystem,%nvar)
dec integer k
*
* The impacts are the ones specified by the choice of the <<fshock>>
* matrix. Because RATS series are based at entry 1, the impacts go
* in entry 1 and the h step responses into h+1.
*
compute %pt(linprjirf,1,fshock)
do h=1,nstep
   system(model=linvar)
   variables ygap infl rate
   lags h to h+nlags-1
   det constant
   end(system)
   *
   * Estimate by SUR with system Newey-West covariance matrix
   *
   sur(model=linvar,robust,lwindow=newey,lags=h-1,noprint)
   *
   * Pull out the leading lag matrix and post-multiply by the
   * desired factor of the covariance matrix.
   *
   compute pix=%modellagmatrix(linvar,h)
   compute %pt(linprjirf,h+1,pix*fshock)
   *
   do i=1,%nvar
      do j=1,%nvar
         ewise deltawt(k,j)=(k==(i-1)*nregeqn+(j-1)*nlags+1)
      end do j
      compute pixvar=%mqform(%xx,deltawt)
      do j=1,nshock
         compute linprjstderr(i,j)(h+1)=sqrt(%qform(pixvar,%xcol(fshock,j)))
      end do j
   end do i
end do h
*
dec vect[series] lower(nshock) upper(nshock)
*spgraph(hfields=nshock,vfields=%nvar,xlabels=varlabels,ylabels=shocklabels,$
*   footer="Figure 5. Impulse Responses for the New Keynesian Model based on a VAR and Linear Projections")
 do i=1,%nvar
   *
   * Compute the upper and lower bounds for each of the responses
   * for variable i, then find the max and min across all the shocks
   *
   do j=1,nshock
      set lower(j) 1 nstep+1 = linprjirf(i,j)-2.0*linprjstderr(i,j)
      set upper(j) 1 nstep+1 = linprjirf(i,j)+2.0*linprjstderr(i,j)
   end do j
   table(noprint) 1 nstep+1 lower upper
   do j=1,nshock
      graph(row=i,col=j,number=0,min=%minimum,max=%maximum) 3
      *# baseirf(i,j)
      # linprjirf(i,j) /4
      # lower(j) / 3
      # upper(j) / 3
   end do j
 end do i
*spgraph(done)

Re: Help with Labelling-please

Unread postPosted: Thu Dec 23, 2021 11:34 am
by TomDoan
If I understand you correctly, you want to replace the graph instruction in the inner loop with

compute header="Response of "+varlabels(1,i)+" to "+shocklabels(1,j)
graph(row=i,col=j,number=0,min=%minimum,max=%maximum,header=header) 3

(or something like that with the compute header=...)

Re: Help with Labelling-please

Unread postPosted: Fri Dec 24, 2021 8:48 am
by Ozmando
TomDoan wrote:If I understand you correctly, you want to replace the graph instruction in the inner loop with

compute header="Response of "+varlabels(1,i)+" to "+shocklabels(1,j)
graph(row=i,col=j,number=0,min=%minimum,max=%maximum,header=header) 3

(or something like that with the compute header=...)


Thanks for the help.
works perfectly now.
Oz