IRF in VARX

For technical questions regarding estimation of single equations, systems, VARs, Factor analysis and State Space Models in EViews. General econometric questions and advice should go in the Econometric Discussions forum.

Moderators: EViews Gareth, EViews Moderator

Alfa318
Posts: 4
Joined: Sat Jul 25, 2020 6:54 pm

IRF in VARX

Postby Alfa318 » Sat Jul 25, 2020 8:11 pm

I'm running a VARX model and I'd like to obtain the response of the endogenous variables to a shock in the exogenous variable. How do I do this in EViews (I'm using EViews 11)?

Please bare in mind that I'm extremely novice. :oops:

Many thanks.

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

Re: IRF in VARX

Postby EViews Matt » Tue Jul 28, 2020 11:32 am

Hello,

I assume you're using an EViews VAR object for your model, and unfortunately the built-in IRF tools don't support shocks to exogenous variables. Conceptually, all you need to do is zero all your endogenous and exogenous data, except for the shock you want, and then run a forecast. From a practical standpoint, it's probably easiest to to wrap the VAR object in a MODEL object. For example,

Code: Select all

' Create a sample VAR(2) with 2 exogenous variables create u 100 series x = rnd series y = nrnd series z = rnd series j = rnd series k = rnd var v.ls 1 2 x y z @ j k ' Create a model object from the VAR v.makemodel(m) ' Switch to a model scenario where we can specify overrides m.scenario "scenario 1" ' Create new series for the VAR that are all zeros. series x_1 = 0 series y_1 = 0 series z_1 = 0 series j_1 = 0 j_1(3) = 1 ' This is our shock series k_1 = 0 ' Force the model to use the *_1 series instead of the original series. m.override x y z j k m.exclude x("1 2") y("1 2") z("1 2") ' Solve the model, effectively performing a forecast m.solve ' Results for our endogenous variables are in x_1, y_1, and z_1. View them. group g x_1 y_1 z_1 g.line(m)

Alfa318
Posts: 4
Joined: Sat Jul 25, 2020 6:54 pm

Re: IRF in VARX

Postby Alfa318 » Thu Aug 13, 2020 7:49 pm

Hi Matt,

Many thanks for your help! I'm running a panel VARX and when I reach the step of "m.solve" I get an error message: "Error in Sample: Range Error". When I did it with the code you provided, it was running perfectly. But when I switch to my panel dataset, I get this error. Any advice please?

Thank you very much.

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

Re: IRF in VARX

Postby EViews Matt » Fri Aug 14, 2020 1:04 pm

Hello,

I've modified my example below to operate over a simple panel. If it works fine on your machine then there may be a sample issue with your dataset, would you be able to post your workfile and whatever program you've used to create the IRFs?

Code: Select all

' Create a sample VAR(2) with 2 exogenous variables create a 2000 2020 3 series x = rnd series y = nrnd series z = rnd series j = rnd series k = rnd var v.ls 1 2 x y z @ j k ' Create a model object from the VAR v.makemodel(m) ' Switch to a model scenario where we can specify overrides m.scenario "scenario 1" ' Create new series for the VAR that are all zeros. series x_1 = 0 series y_1 = 0 series z_1 = 0 series j_1 = 0 j_1(v.@lagorder + 1) = 1 ' This is our shock series k_1 = 0 ' Force the model to use the *_1 series instead of the original series. m.override x y z j k %ex_range = @otod(1) + " " + @otod(v.@lagorder) m.exclude x(%ex_range) y(%ex_range) z(%ex_range) ' Solve the model, effectively performing a forecast m.solve ' Results for our endogenous variables are in x_1, y_1, and z_1. View them. group g x_1 y_1 z_1 g.line(m)

minko.markovski123
Posts: 4
Joined: Sun Dec 11, 2022 7:54 am

Re: IRF in VARX

Postby minko.markovski123 » Sun Jan 08, 2023 12:50 am

Hello,

I tried to replicate your code for VARX but apparently I have an issue with the solve function.

It gives me the error "Error in Sample: Range Error in "M.SOLVE"". Could you please clarify what might be the issue and how to solve it?

Many thanks

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

Re: IRF in VARX

Postby EViews Matt » Mon Jan 09, 2023 5:51 pm

Hello,

The generic "Range Error" message indicates that EViews was expecting a pair of dates to specify a range (or multiple pairs for multiple ranges in some cases) but there was a problem with the provided specification. Usually, if an individual date specification is bad then a more descriptive error is generated. More likely is that only a single date was provided where a date range (two dates) was expected.

If you've adapted my sample code to your dataset, I believe the only place this error could arise is in a modification to the variable exclusion statement, "m.exclude x(%ex_range) ...". The parenthetical expects a sample string, which is commonly a pair of dates. If you've manually set the exclusion ranges, it's easy to forgot to specify a range when a single date would seemingly work. For example, in a monthly workfile, excluding an entire year still requires specifying a range, e.g. x("2022 2022"), even though it might be tempting to write x("2022"). Such an error isn't caught until the model object fully processes the sample string during the subsequent solve procedure.

minko.markovski123
Posts: 4
Joined: Sun Dec 11, 2022 7:54 am

Re: IRF in VARX

Postby minko.markovski123 » Mon Jan 09, 2023 10:58 pm

Many thanks Matt,

It was very useful and it worked.

Could you please also help with extra code (for the first one in this topic) to produce and chart historical decomposition and variance decomposition?

Many thanks in advance

dakila
Posts: 489
Joined: Tue Nov 24, 2015 4:57 pm

Re: IRF in VARX

Postby dakila » Tue Jan 10, 2023 4:20 am


minko.markovski123
Posts: 4
Joined: Sun Dec 11, 2022 7:54 am

Re: IRF in VARX

Postby minko.markovski123 » Tue Jan 10, 2023 8:57 pm

Thank you Dakila,

Actually the impulse response works well for me.

I am interested in the variance decomposition and historical decomposition codes only now.

Many thanks in advance


Return to “Estimation”

Who is online

Users browsing this forum: No registered users and 2 guests