'IF' statement for time periods in models

For questions regarding programming in the EViews programming language.

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

jaime.nie
Posts: 1
Joined: Thu May 26, 2022 1:16 am

'IF' statement for time periods in models

Postby jaime.nie » Mon May 30, 2022 12:02 am

Good morning,

I am using Eviews 12 and programming a model that spans from 1971 to 2018 (yearly). My problem is the following:

While the vast majority of the explanatory variables have available data from 1971-2018, some dependent variables depend on explanatory variables only available from 1998 onward. So, the non-problematic equations with explanatory variables spanning 71-18 would be like this:

Code: Select all

Y1= B0+B1X1+B2X2+B3X3 +...

And the few (but important) problematic equations look like this:

Code: Select all

Y1=(B0*+B1*X1*+B2*X2*+B3*X3*+...)

with X3 spanning from 1998-2018.

We previously tried to solve the issue by the following method, suggested in this forum:

First, we estimated two different equations, one from 71-97 and another 98-18. Then we write this in the model window:

Code: Select all

Y1= (@year<1998) *(B0+B1X1+B2X2+B3X3+...) + (@year>=1998)* (B0*+B1*X1*+B2*X2*+B3*X3*+...)

It worked as long as the dependent variable for both equations had the same form, say: Y1 for both equations are in logs, or in first difference, or levels... Otherwise, it became problematic, i.e. the model crashes. So, as a simple solution, valid for running the model for out-of-sample forecasting purposes, we kept the 98-18 equation and excluded in scenarios that variable from 71-97. However, this is not good enough for counterfactual analysis.

Therefore, I was looking into 'if then else' statements in Eviews, but I am not being able to make it work. So, this is what I am writing:

Code: Select all

if @year>=1998 then

Y1=B0*+B1*X1* + B2*X2* + B3*X3* +...   

else

Y1=B0+B1X1 + B2X2 + B3X3 +...

endif

It does not work either when I write the equations as :eq1 and :eq2 instead of the "substituted coefficients" form.

I hope this all makes sense. Could I get help to solve this issue? Many thanks in advance.

Kind regards

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

Re: 'IF' statement for time periods in models

Postby EViews Gareth » Mon May 30, 2022 6:05 am

@recode
Follow us on Twitter @IHSEViews


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 14 guests