Page 1 of 1

Rolling window ARMA Forecast

Posted: Sun Mar 23, 2014 1:31 pm
by garderobert
Hi!

I'm having some problems with programming an rolling window Arma (2,1) forecast for my project. I'm a rookie at programming in eviews but I have acquired a program that has been used for the same purpose but I have modified it to fit my number of observations. The problem is that it doesn't work when I try to run the program, it says "error in sample, Range error". I have 2470 daily observations and the purpose is to construct a rolling window sample of 1000 obs that will forecast the next 22. The window is then supposed to move one step so the first forecast is generated from obs 1-1000 and the next is generated by 2-1001 and so on until all observations are covered.

I would appreciate it if someone could take a look at the code. Thanks in advance!

I use Eviews 7 but the code is originally written for the 6th edition if that matters.

Code: Select all

scalar noobs=2470 scalar nw=1000 matrix(2470,22) armaforecast vector(22) forecastresult for !i=nw to noobs smpl !i-nw+1 !i equation arma_n arma_n.ls rvdaily c ar(1) ar(2) ma(1) for !j=1 to 22 if !j=1 then forecastresult(1)=arma_n.@coefs(2)*rvdaily(!i)+ arma_n.@coefs(3)*rvdaily(!i-1)+ arma_n.@coefs(4)*resid(!i) endif if !j=2 then forecastresult(2)=arma_n.@coefs(2)*forecastresult(1)+arma_n.@coefs(3)*rvdaily(!i) endif if !j=3 then forecastresult(3)=arma_n.@coefs(2)*forecastresult(2)+arma_n.@coefs(3)*forecastresult(1) endif if !j>3 then forecastresult(!j)=arma_n.@coefs(2)*forecastresult(!j-1)+ arma_n.@coefs(3)*forecastresult(!j-2) endif next !j rowplace(armaforecast,@transpose(forecastresult),!i) next!i

Re: Rolling window ARMA Forecast

Posted: Sun Mar 23, 2014 9:37 pm
by EViews Gareth
Change

Code: Select all

smpl !i-nw+1 !i
to be:

Code: Select all

smpl @first+!i-nw @first+!i-1

Re: Rolling window ARMA Forecast

Posted: Mon Mar 24, 2014 2:24 pm
by garderobert
Thanks for the help Gareth! The problem is that I also need all the estimated parameters of ar(1), ar(2) and Ma(1) over the whole in-sample estimation period stored, and I have been trying to construct another code that does that. But again I run into "sample error" on the Arma (2,1) model. Another problem is that the in-sample estimation period does not roll, it only estimates using the first 1000 observations, it does not role through. Also right before the ARMA code starts I've tried to do a rolling ADF-test. But somehow that does not work since the window does not roll there either. There is also something wrong when I try to generate new series (under "generate basic series") since they are still empty after the program has been run.

I have uploaded my complete program since something weird happened when I tried to slice it up. But I would appreciate if you could look at the parts that I highlighted, they are in the beginning of the program.

Thanks!

Re: Rolling window ARMA Forecast

Posted: Mon Mar 24, 2014 3:30 pm
by EViews Gareth
ok, I'll try to explain the underlying problem.

Workfiles in EViews can be dated or undated.

Undated workfiles just have a number of observations, and each row of data is identified by its observation number. The first observation is identified by "1", the 2nd observation by "2", and so on.

In undated workfiles you can set the sample by stating the start number and end number of the range of observations you're interested in. Thus you can do "3 10" to indicate you want to work with observations 3 through 10.

In dated workfiles, observations are not identified by a number. Rather, they are identified by a date. When specifying the sample, you cannot use a part of simple integers to identify which observations your'e interested in, you have to use a pair of dates. Thus, something like: "05/05/2004 06/07/2010" could be used.

In your program you are setting samples using pairs of integers. But your workfile is dated. Hence the error.

There is a way around it though. Rather than using a pair of dates, or a pair of integers, you can use a pair of offsets. You can use the @first and @last keywords to indicate the first observation and last observation in the workfile. You can use @first+1 to indicate the 2nd observation in the workfile. You can use @first+100 to indicate the 101st observation in the workfile.

Thus if you want to use observations 15 through 30 in a dated workfile, you would set the sample to be @first+14 @first+29.