Page 1 of 1

code for SVAR

Posted: Thu Jun 30, 2022 10:49 am
by zezza
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

Re: code for SVAR

Posted: Thu Jun 30, 2022 1:58 pm
by EViews Matt
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

Re: code for SVAR

Posted: Fri Jul 01, 2022 3:22 am
by zezza
Thank you, you have been very clear, and the code works on my data!

Re: code for SVAR

Posted: Fri Jul 01, 2022 4:18 am
by zezza
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

Re: code for SVAR

Posted: Tue Jul 05, 2022 3:14 pm
by EViews Matt
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.

Re: code for SVAR

Posted: Tue Jul 12, 2022 10:26 am
by zezza
Thank you! I should have noticed...