code for SVAR

For questions regarding programming in the EViews programming language.

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

zezza
Posts: 23
Joined: Fri May 28, 2010 5:27 am

code for SVAR

Postby zezza » Thu Jun 30, 2022 10:49 am

Is there any example on how to code the estimation of a SVAR? I am particularly interested in obtaining the responses to structural VAR innovations for producing additional statistics and charts.
The manual mentions the @lrrsp vector, but varname.@lrrsp(1,1) returns a number which does not match any number in the table obtained with View > Impulse response
Thank you

EViews Matt
EViews Developer
Posts: 560
Joined: Thu Apr 25, 2013 7:48 pm

Re: code for SVAR

Postby EViews Matt » Thu Jun 30, 2022 1:58 pm

Hello,

There are a few small SVAR examples in the documentation, but I can provide a few more here. To answer you're question about @lrrsp, the accumulated impulse responses that data member holds are the theoretical/asymptotic responses, not the responses at the last horizon as shown in the impulse responses view. As a simple demonstration,

Code: Select all

create u 50
series x = 0
series y = 1
smpl 2 50
x = .5 * x(-1)  + rnd
y = .8 * y(-1) + .3 * x(-1) + nrnd
var v.ls 1 1 x y

v.impulse(a,imp=unit,se=a)
matrix auto_lrrsp = v.@lrrsp
matrix manual_lrrsp = @inverse(@identity(2) - v.@lagcoef(1))
show auto_lrrsp
show manual_lrrsp

The above code generates a trivial VAR and shows the accumulated impulse responses to unit innovations (for mathematical simplicity), as well as the @lrrsp matrix and a manual calculation of the long-run multiplier, psi. The two matrices should match, and represent the values that the accumulated responses are asymptotically approaching. Examining the response graphs or table, the values at the last horizon should be near those in the matrices though likely not identical.

The same idea holds if you're using EViews' built-in SVAR estimation, were there @lrrsp and @svarfmat matrices represent asymptotic behavior of the accumulated impulse responses. For example,

Code: Select all

create u 50
series x = 0
series y = 1
smpl 2 50
x = .5 * x(-1)  + rnd
y = .8 * y(-1) + .3 * x(-1) + nrnd
var v.ls 1 1 x y

v.svar(preset=1)
v.impulse(a,imp=struct,se=a)
matrix lrrsp = v.@lrrsp
matrix fmat = v.@svarfmat
show lrrsp
show fmat

Now, if you what you actually want to capture is the finite (horizon-limited) behavior of the responses as shown in the view window, there are options to copy that data to the workfile. For example,

Code: Select all

create u 50
series x = 0
series y = 1
smpl 2 50
x = .5 * x(-1)  + rnd
y = .8 * y(-1) + .3 * x(-1) + nrnd
var v.ls 1 1 x y

v.svar(preset=1)
v.impulse(a,imp=struct,se=a,matbyr=responses)
show responses

zezza
Posts: 23
Joined: Fri May 28, 2010 5:27 am

Re: code for SVAR

Postby zezza » Fri Jul 01, 2022 3:22 am

Thank you, you have been very clear, and the code works on my data!

zezza
Posts: 23
Joined: Fri May 28, 2010 5:27 am

Re: code for SVAR

Postby zezza » Fri Jul 01, 2022 4:18 am

One last question: Is there a way to get a matrix of the standard errors of the responses, to reproduce the charts with the confidence intervals?
Thank you

EViews Matt
EViews Developer
Posts: 560
Joined: Thu Apr 25, 2013 7:48 pm

Re: code for SVAR

Postby EViews Matt » Tue Jul 05, 2022 3:14 pm

Hello,

When using 'matbyr' or similar options, a second matrix with the suffix "_se" is created to hold the standard errors. So in my example code, matrices "responses" and "responses_se" are created as part of the impulse procedure.

zezza
Posts: 23
Joined: Fri May 28, 2010 5:27 am

Re: code for SVAR

Postby zezza » Tue Jul 12, 2022 10:26 am

Thank you! I should have noticed...


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 26 guests