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