Page 1 of 1

Impulse Response Functions

Posted: Wed Apr 24, 2013 12:41 pm
by sean123
Hi,

I'm trying to program the impulse response functions using the Cholesky factorization, but I'm somewhat stuck. I need them for VARs with restrictions (i.e. estimated in a system object). Here's what I have to start with:

Code: Select all

Edit: See next post
I always thought it was the Cholesky decomposition (i.e. P), and not the inverse of it, but that's what I found in the User's guide. How would I proceed? Help would be much appreciated!

Re: Impulse Response Functions

Posted: Tue Jun 04, 2013 5:47 am
by sean123
Hi again,

I have been working on this a while now, it's making me a little crazy. My code yields the same output for the first time period as I get when using the built-in function, but for some reason after that it's different. I have been looking at Helmut Lütkepohl's New Introduction to Multiple Time Series Analysis and I redid his example (page 59), but the same thing isn't working for this new data. Do you have any ideas? Please tell me if you do.

Here's the code:

Code: Select all

create wf q 1990q1 2012q4 rndseed 1 series x=nrnd series y=nrnd series z=nrnd VAR VAR.LS 1 1 X Y Z VAR.IMPULSE(4, t, imp = uni) matrix coefmat=var.@coefmat coefmat=@subextract(coefmat, 1, 1, 3, 3) sym residmat=var.@residcov matrix P=@cholesky(residmat) 'P = @identity(3) matrix theta0 = P matrix theta1 = @transpose(coefmat * P) matrix theta2 = @transpose(coefmat * coefmat * P) matrix theta3 = @transpose(coefmat * coefmat * coefmat * P) table(15, 4) responses responses(1,1)="X" responses(6,1)="Y" responses(11,1)="Z" for !shock=0 to 2 responses(1+!shock*5, 2)="X" responses(1+!shock*5, 3)="Y" responses(1+!shock*5, 4)="Z" next for !i=1 to 3 for !j=0 to 2 for !k=0 to 3 responses(2+!j*5+!k,1+!i)=theta!k(1+!j, !i) next next next show responses
Do note that my P matrix is identical to the one obtained from "var.@impfact". But how is this then used?

Re: Impulse Response Functions

Posted: Tue Jun 04, 2013 8:14 am
by sean123
I tested with letting the P matrix be the identity matrix to get the same as the built-in function with one unit innovations. I realized that the assignment of values to the final table was not entirely correct as some matrices needed to be transposed first for the assignment to be correct. I'm assuming this is purely a programming issue and nothing else. The code in the previous post has been updated.

One interesting thing though: the bottom right part of my table is identical to the built-in function's (Z's response to shock in Z)! However, it's the only one, and I can't really figure out why...

Re: Impulse Response Functions

Posted: Wed Jun 05, 2013 6:11 am
by sean123
It turns out that what I was missing was that the coefficient matrix needed to be transposed first. Now it yields the same output as Eviews!

Re: Impulse Response Functions

Posted: Wed Jun 05, 2013 7:57 am
by EViews Gareth
Glad we could help! :wink: