one step ahead forecasts with expanding window

For questions regarding programming in the EViews programming language.

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

Etienne Wijler
Posts: 10
Joined: Mon Nov 17, 2014 1:48 pm

one step ahead forecasts with expanding window

Postby Etienne Wijler » Mon Nov 17, 2014 1:59 pm

Hello,

I am new to Eviews and have never programmed before, so my apologies for the ignorance that will shine through in the code I am about to post below.

My problem is the following. I have a sample consisting of 1757 observation and I want to perform dynamic one step ahead forecasting on the last 450 observation. The estimation sample for every 1 step ahead forecast should include all observations prior to the respective forecast and is thus increasing with the number of forecasts. I have accumulated a little knowledge on this forum, but have difficulty understanding some of the examples posted by board members, so I hope I can show you the very small program I have made (which is obviously not working properly).

Code: Select all

'define loop for !i = 1 to 450 smpl @first @first+(1757-451)+!i equation forecast1.ls co_5_d_i c @trend ar(1) ma(1 to 3) @expand(@quarter, @dropfirst) tu we th fr sa su 'series to store estimates series fcast 'dynamic forecast arma model smpl @first+(1757-450)+!i @first+(1757-450)+!i forecast1.forecast yhat fcast = yhat next smpl @all
When I run this program I can clearly see eviews working its way through all the observation, but the created series "yhat" remains empty.

Hope you can help out (and if you can, please dummy it down a bit for me :D )

Thanks a lot!

Etienne

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

Re: one step ahead forecasts with expanding window

Postby EViews Gareth » Mon Nov 17, 2014 2:19 pm

Works for me:

Code: Select all

create d7 1990 2000 series co_5_d_i = nrnd series tu = @weekday=2 series we = @weekday=3 series th = @weekday=4 series fr = @weekday=5 series sa = @weekday=6 series su = @weekday=7 'define loop for !i = 1 to 450 smpl @first @first+(1757-451)+!i equation forecast1.ls co_5_d_i c @trend ar(1) ma(1 to 3) @expand(@quarter, @dropfirst) tu we th fr sa su 'series to store estimates series fcast 'dynamic forecast arma model smpl @first+(1757-450)+!i @first+(1757-450)+!i forecast1.forecast yhat fcast = yhat next smpl @all

Etienne Wijler
Posts: 10
Joined: Mon Nov 17, 2014 1:48 pm

Re: one step ahead forecasts with expanding window

Postby Etienne Wijler » Mon Nov 17, 2014 2:27 pm

My apologies, I used the wrong loop size before and edited this in my post, which seems to have solved the problem indeed. :oops:

Thanks for the verification!

Etienne Wijler
Posts: 10
Joined: Mon Nov 17, 2014 1:48 pm

Re: one step ahead forecasts with expanding window

Postby Etienne Wijler » Wed Nov 19, 2014 12:58 pm

OK, one more question. I hope somebody will read this so I do not need to open a new topic, as the question is kind of related to the previous one.

I am again trying to produce a series of recursive (expanding window) one step ahead forecasts. This time I am using a VAR model with endogenous and exogenous variables. I am only interested in the estimation of the first two equations in the VAR, but don't mind forecasting all variables. The problem is that I don't know how to store the series of one step ahead forecasts. I use the following code:

Code: Select all

'define loop for !i = 1 to 550 smpl @first @first+(1756-552)+!i var var1.ls 1 1 co_5_d_i no2_5_d_i nox_5_d_i o3_5_d_i pm10_5_d_i rain_5_d_i so2_5_d_i sr_5_d_i tmp_5_d_i wd_5_d_i ws_5_d_i @ tu we th fr sa su @trend @expand(@quarter, @dropfirst) 'Endogenous variable before "@" and exogenous variables after. ' Dynamic Forecast VAR smpl @first+(1756-551)+!i @first+(1756-551)+!i var1.makemodel(mod1) mod1.solve(d=d) ytilda 'store estimates series VAR1_forecast = ytilda next smpl @all
This time I receive the error that the series ytilda is not defined, so apparently eviews doesn't recognize ytilda as a name after the command mod1.solve(d=d).

I hope somebody can help me on this, as this is the last thing preventing me from completing a school assignment :D

Thank you for your support.

Etienne

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

Re: one step ahead forecasts with expanding window

Postby EViews Gareth » Wed Nov 19, 2014 1:03 pm

You can't specify the name of the forecast series with the model.solve command. Instead they are given names equal to the name of the dependent variable followed by a "_0". Thus the name of the first forecast series will be co_5_d_i_0, not ytilda.

Etienne Wijler
Posts: 10
Joined: Mon Nov 17, 2014 1:48 pm

Re: one step ahead forecasts with expanding window

Postby Etienne Wijler » Wed Nov 19, 2014 1:18 pm

Thanks for the fast response again. I understand what you mean, but do you perhaps know of any clever way to get the forecasts in a series? Generating 11*550 new variables might not be the most efficient way to go about this :|

Etienne Wijler
Posts: 10
Joined: Mon Nov 17, 2014 1:48 pm

Re: one step ahead forecasts with expanding window

Postby Etienne Wijler » Wed Nov 19, 2014 1:44 pm

From another topic on this forum I found this method:

Code: Select all

'define loop for !i = 1 to 550 smpl @first @first+(1756-552)+!i table varforecast var var1!i.ls 1 1 co_5_d_i no2_5_d_i nox_5_d_i o3_5_d_i pm10_5_d_i rain_5_d_i so2_5_d_i sr_5_d_i tmp_5_d_i wd_5_d_i ws_5_d_i @ tu we th fr sa su @trend @expand(@quarter, @dropfirst) ' Dynamic Forecast VAR smpl @first+(1756-551)+!i @first+(1756-551)+!i var1!i.makemodel(mod1!i) mod1!i.solve fcast(1+!i, 1)= @elem(co_5_d_i_0, %date) next smpl @all
where you (Eviews Gareth) suggested to add the %date part. However, this returns the message that there is an illegal date in fcast :cry:

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

Re: one step ahead forecasts with expanding window

Postby EViews Gareth » Wed Nov 19, 2014 1:45 pm

You don't need to generate 11*550.

Just replace the line:

Code: Select all

'store estimates series VAR1_forecast = ytilda
with

Code: Select all

'store estimates series VAR1_forecast = co_5_d_i_0

Etienne Wijler
Posts: 10
Joined: Mon Nov 17, 2014 1:48 pm

Re: one step ahead forecasts with expanding window

Postby Etienne Wijler » Wed Nov 19, 2014 1:50 pm

You sir, are officially awesome!!!

We are lucky to have people like you helping us out. Thanks a bunch!


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests