Jorda(2005)—Local Projection Impulse Responses

Use this forum for posting example programs or short bits of sample code.

Jorda(2005)—Local Projection Impulse Responses

Unread postby TomDoan » Mon Jul 23, 2018 3:12 pm

This computes the impulse responses by local projections from Jorda(2005), "Estimation and Inference of Impulse Responses by Local Projections", American Economic Review, 95(1), pp 161-182. This does the New Keynesian model example (3 variable VAR using Cholesky factor shocks).

is_example.rpf
Program file
(3.54 KiB) Downloaded 1204 times
is_new.csv
Data file
(6.97 KiB) Downloaded 1155 times


The calculations for this are actually quite simple. The h step responses are computed by regressing Y(t) on Y(t-h), Y(t-(h+1)), ... and extracting the coefficient vector on the leading lag (that is, the Y(t-h)) in that. That n x n matrix gives the local projection responses of the n variables (rows) to unit shocks in the n variables (columns). Different shock patterns can be obtained by post-multiplying that matrix by a set of weights on the unit shocks (in this case, by the Cholesky factor of the residuals from a standard VAR). (Standard IRF's effectively do the same thing for multi-step responses except the multi-step projection is a known function of the standard VAR coefficients rather than being estimated directly).

The regression with skipped lags will have serially correlated errors. The standard errors of the IRF's are computed using some form of HAC covariance estimates for that lead coefficient matrix. Because there are different ways of computing those, the standard errors will differ as well.

A few things to note.

  1. The graphs in the RATS program label the impact shock as 0 (as is more typical) while Jorda uses 1.
  2. The RATS graphs are organized in the more typical way with variables across and shocks down. They also use a common scale going across for all responses of a given variable.
  3. This does not do the cubic projections. That's not dramatically more complicated, but it's not clear that there's a great advantage to it, and the cubic responses have to be linearized about some value for the lagged y's anyway (which the linear projection responses are independent of those).
TomDoan
 
Posts: 7147
Joined: Wed Nov 01, 2006 5:36 pm

Re: Jorda(2005)—Local Projection Impulse Responses

Unread postby twada » Mon Jul 30, 2018 3:42 am

Dear Tom,

Thanks so much for the sample code! I have the following 2 questions:
1. It seems that the number of observations used to get the local projection IR changes (decreases) as h increases. Am I right? Some of the sample codes posted on Oscar Jorda's website uses the same number of observations for all horizons, h=0, 1,....,hmax.
2. I think there is local projection IR for h=0 (which is just the Cholesky matrix times shock), and h=2, 3,... but I am wondering is there is no IR for h=1. I am sorry if I am wrong.

Thanks for your time,
Tatsuma
twada
 
Posts: 2
Joined: Sun Mar 19, 2017 11:32 pm
Location: Japan

Re: Jorda(2005)—Local Projection Impulse Responses

Unread postby TomDoan » Mon Jul 30, 2018 11:07 am

twada wrote:Dear Tom,

Thanks so much for the sample code! I have the following 2 questions:
1. It seems that the number of observations used to get the local projection IR changes (decreases) as h increases. Am I right? Some of the sample codes posted on Oscar Jorda's website uses the same number of observations for all horizons, h=0, 1,....,hmax.


I don't think there's a strong reason to prefer one vs the other.

twada wrote:2. I think there is local projection IR for h=0 (which is just the Cholesky matrix times shock), and h=2, 3,... but I am wondering is there is no IR for h=1. I am sorry if I am wrong.


You're correct. I've fixed the program. Note that the labeling of the responses in the paper is wrong---the h=1 really are the impact shocks.
TomDoan
 
Posts: 7147
Joined: Wed Nov 01, 2006 5:36 pm

Re: Jorda(2005)—Local Projection Impulse Responses

Unread postby twada » Mon Nov 19, 2018 11:34 am

Thanks, Tom. I checked the code and confirmed that my results are the same as yours.
Thanks also for pointing out the difference between the figures in the paper and those by Rats's.

Tatsuma
twada
 
Posts: 2
Joined: Sun Mar 19, 2017 11:32 pm
Location: Japan

Re: Jorda(2005)—Local Projection Impulse Responses

Unread postby ABDHUT123 » Tue Feb 18, 2020 12:40 pm

Dear Tom, how to obtain the local projection impulse response along with corresponding standard errors in table format??
ABDHUT123
 
Posts: 13
Joined: Thu Aug 02, 2018 9:37 am

Re: Jorda(2005)—Local Projection Impulse Responses

Unread postby TomDoan » Tue Feb 18, 2020 4:11 pm

The linear projection IRF's are in LINPRJIRF(i,j) and the corresponding standard errors are in LINPRJSTDERR(i,j) where i is the target variable and j is the shock. I'm not sure how you want to organize a table of those, but you can use PRINT or COPY to get the values.
TomDoan
 
Posts: 7147
Joined: Wed Nov 01, 2006 5:36 pm

Re: Jorda(2005)—Local Projection Impulse Responses

Unread postby Ozmando » Sun Aug 29, 2021 5:13 am

TomDoan wrote:This computes the impulse responses by local projections from Jorda(2005), "Estimation and Inference of Impulse Responses by Local Projections", American Economic Review, 95(1), pp 161-182. This does the New Keynesian model example (3 variable VAR using Cholesky factor shocks).

is_example.rpf
is_new.csv


The calculations for this are actually quite simple. The h step responses are computed by regressing Y(t) on Y(t-h), Y(t-(h+1)), ... and extracting the coefficient vector on the leading lag (that is, the Y(t-h)) in that. That n x n matrix gives the local projection responses of the n variables (rows) to unit shocks in the n variables (columns). Different shock patterns can be obtained by post-multiplying that matrix by a set of weights on the unit shocks (in this case, by the Cholesky factor of the residuals from a standard VAR). (Standard IRF's effectively do the same thing for multi-step responses except the multi-step projection is a known function of the standard VAR coefficients rather than being estimated directly).

The regression with skipped lags will have serially correlated errors. The standard errors of the IRF's are computed using some form of HAC covariance estimates for that lead coefficient matrix. Because there are different ways of computing those, the standard errors will differ as well.

A few things to note.

  1. The graphs in the RATS program label the impact shock as 0 (as is more typical) while Jorda uses 1.
  2. The RATS graphs are organized in the more typical way with variables across and shocks down. They also use a common scale going across for all responses of a given variable.
  3. This does not do the cubic projections. That's not dramatically more complicated, but it's not clear that there's a great advantage to it, and the cubic responses have to be linearized about some value for the lagged y's anyway (which the linear projection responses are independent of those).


I am trying to modify the code so that the graphs are generated individually rather than in the 3 by 3 format as it is now; Any help please? Thanks.
Ozmando
 
Posts: 42
Joined: Sun Jul 15, 2012 4:04 pm

Re: Jorda(2005)—Local Projection Impulse Responses

Unread postby TomDoan » Sun Aug 29, 2021 8:12 am

You have to comment out the SPGRAPH instructions (two lines at the top, one at the bottom):

*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) 4
# baseirf(i,j)
# linprjirf(i,j)
# lower(j) / 3
# upper(j) / 3
end do j
end do i
*spgraph(done)


That also eliminates the labeling, so you would have to add a header or footer option to the GRAPH instruction.
TomDoan
 
Posts: 7147
Joined: Wed Nov 01, 2006 5:36 pm

Re: Jorda(2005)—Local Projection Impulse Responses

Unread postby Ozmando » Mon Aug 30, 2021 2:47 pm

TomDoan wrote:You have to comment out the SPGRAPH instructions (two lines at the top, one at the bottom):

*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) 4
# baseirf(i,j)
# linprjirf(i,j)
# lower(j) / 3
# upper(j) / 3
end do j
end do i
*spgraph(done)


That also eliminates the labeling, so you would have to add a header or footer option to the GRAPH instruction.


Thanks Tom, working perfectly now.
However, VAR and LLP response are plotted in the same graph (please see example 1 attached). I am only interested in the LLP plots. Please how doI get rid off of the VAR response?
Thanks.
Attachments
Example1.RGF
(668 Bytes) Downloaded 192 times
Ozmando
 
Posts: 42
Joined: Sun Jul 15, 2012 4:04 pm

Re: Jorda(2005)—Local Projection Impulse Responses

Unread postby TomDoan » Mon Aug 30, 2021 8:31 pm

Change this to graph 3 rather than 4, and delete the # baseirf(i,j) line

graph(row=i,col=j,number=0,min=%minimum,max=%maximum) 4
# baseirf(i,j)
# linprjirf(i,j)
# lower(j) / 3
# upper(j) / 3
TomDoan
 
Posts: 7147
Joined: Wed Nov 01, 2006 5:36 pm

Re: Jorda(2005)—Local Projection Impulse Responses

Unread postby Ozmando » Wed Sep 01, 2021 12:50 pm

TomDoan wrote:Change this to graph 3 rather than 4, and delete the # baseirf(i,j) line

graph(row=i,col=j,number=0,min=%minimum,max=%maximum) 4
# baseirf(i,j)
# linprjirf(i,j)
# lower(j) / 3
# upper(j) / 3



Thanks Tom. All working fine now. Much appreciated.
Oz
Ozmando
 
Posts: 42
Joined: Sun Jul 15, 2012 4:04 pm


Return to Examples and Sample Code

Who is online

Users browsing this forum: No registered users and 2 guests

cron