Page 1 of 1

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

Posted: Thu Apr 26, 2018 7:46 am
by batejwani
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

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

Posted: Thu Apr 26, 2018 7:50 am
by EViews Gareth

Code: Select all

%last = {%i}.@last smpl {%last}+1 @last

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

Posted: Thu Apr 26, 2018 8:15 am
by batejwani
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?

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

Posted: Thu Apr 26, 2018 8:33 am
by EViews Gareth
I fixed a typo, try again.

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

Posted: Thu Apr 26, 2018 8:49 am
by batejwani
This worked! Thank you so much :D

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

Posted: Wed Jan 25, 2023 7:21 am
by BoxyJr
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

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

Posted: Wed Jan 25, 2023 9:08 am
by EViews Gareth
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?

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

Posted: Wed Jan 25, 2023 9:23 am
by BoxyJr
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!