Impulse Response Functions

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

sean123
Posts: 34
Joined: Wed Apr 25, 2012 11:53 am

Impulse Response Functions

Postby sean123 » Wed Apr 24, 2013 12:41 pm

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!

sean123
Posts: 34
Joined: Wed Apr 25, 2012 11:53 am

Re: Impulse Response Functions

Postby sean123 » Tue Jun 04, 2013 5:47 am

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?

sean123
Posts: 34
Joined: Wed Apr 25, 2012 11:53 am

Re: Impulse Response Functions

Postby sean123 » Tue Jun 04, 2013 8:14 am

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...

sean123
Posts: 34
Joined: Wed Apr 25, 2012 11:53 am

Re: Impulse Response Functions

Postby sean123 » Wed Jun 05, 2013 6:11 am

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!

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13585
Joined: Tue Sep 16, 2008 5:38 pm

Re: Impulse Response Functions

Postby EViews Gareth » Wed Jun 05, 2013 7:57 am

Glad we could help! :wink:


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests