Getting last observation and (last observation + 1 month) date in eviews

For questions regarding programming in the EViews programming language.

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

batejwani
Posts: 3
Joined: Thu Apr 26, 2018 3:55 am

Getting last observation and (last observation + 1 month) date in eviews

Postby batejwani » Thu Apr 26, 2018 7:46 am

Hello,
I am working on a group of variables and running autoregression and forecasting monthly values. Since it is a group function, to run autoregression, I need to set last observation date and for forecasting I need to get (last observation date+next month). What formula can I use to resolve this, as the last observation date differs across variables?
For example,
smpl 2000Q1 (code for latest quarter for each variable)
group all_variables variable_1 variable_2 variable_3
for !i = 1 to all_variables.@count
smpl 2000Q1 (code for latest quarter for each variable)
%i= all_variables.@seriesname(!i)
equation eq_{!i}.ls {%i} c ar(1)
'Forecasts
smpl (code for latest quarter for each variable+1 quarter) 2018Q4
eq_{!i}.forecast {%i}_fcst

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

Re: Getting last observation and (last observation + 1 month) date in eviews

Postby EViews Gareth » Thu Apr 26, 2018 7:50 am

Code: Select all

%last = {%i}.@last
smpl {%last}+1 @last
Follow us on Twitter @IHSEViews

batejwani
Posts: 3
Joined: Thu Apr 26, 2018 3:55 am

Re: Getting last observation and (last observation + 1 month) date in eviews

Postby batejwani » Thu Apr 26, 2018 8:15 am

Thank you for replying. I am relatively new to Eviews. When I try the codes you suggested, I get the error @last is not defined or is an illegal command. Any way to fix this?

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

Re: Getting last observation and (last observation + 1 month) date in eviews

Postby EViews Gareth » Thu Apr 26, 2018 8:33 am

I fixed a typo, try again.
Follow us on Twitter @IHSEViews

batejwani
Posts: 3
Joined: Thu Apr 26, 2018 3:55 am

Re: Getting last observation and (last observation + 1 month) date in eviews

Postby batejwani » Thu Apr 26, 2018 8:49 am

This worked! Thank you so much :D

BoxyJr
Posts: 3
Joined: Sat Jan 07, 2023 4:46 am

Re: Getting last observation and (last observation + 1 month) date in eviews

Postby BoxyJr » Wed Jan 25, 2023 7:21 am

I have a similar task. I'm trying to use automatic ARIMA modelling to complete the quarter for several variables. Some end in m10 and some end in m11. How do I modify the code so that a variable that ends at m10 has two forecasted months (m11 and m12), whereas a variable that has data to m11 only produces a forecast for m+1 (m12)?

As an example, this is how I've been doing it (manually):
for %c gr at 'countries with data going to 2022m10
smpl 2006 2022m10' update
i_{%c}.autoarma(eqname=e_i_{%c}) i_{%c}_f c spike2020m4 spike2020m4(-1)
smpl 2022m11 2022m12
e_i_{%c}.forecast i_{%c}f
series i_{%c}=i_{%c}f
next

for %c be cz fi fr ro es 'countries with data going to 2022m11
smpl 2006 2022m11
i_{%c}.autoarma(eqname=e_i_{%c}) i_{%c}_f c spike2020m4 spike2020m4(-1)
smpl 2022m12 2022m12
e_i_{%c}.forecast i_{%c}f
series i_{%c}=i_{%c}f
next

Any help is greatly appreciated.

AH

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

Re: Getting last observation and (last observation + 1 month) date in eviews

Postby EViews Gareth » Wed Jan 25, 2023 9:08 am

Could always just set the sample to be whenever the series has NA:

Code: Select all

smpl if i_{%c} = na


Also, why use the autoarima forecast, and then produce the same forecast from an equation?
Follow us on Twitter @IHSEViews

BoxyJr
Posts: 3
Joined: Sat Jan 07, 2023 4:46 am

Re: Getting last observation and (last observation + 1 month) date in eviews

Postby BoxyJr » Wed Jan 25, 2023 9:23 am

Thank you.

Good question! On reflection, the autoarma would automatically produce an "f" for the specified forecast period, wouldn't it? All I need to do is rename it!


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 17 guests