Page 1 of 1
Recursive OOS forecast
Posted: Tue Jun 28, 2011 1:56 pm
by hxh
Hi
I have a question and a Problem.
In this loop i tried to make an 1 step recursive OOS AR(2) forecast with an intercept a trend and two dummy variables.
Eviews is doing this loop, but Its writing 1 forecast more than I need, but the forecast error has the right length.
Is there something wrong ?
Code: Select all
series rmse=0
series mae=0
for !i=179 to 215
smpl @first @first+!i
equation eq1.ls y c d1 d2 @trend y(-1) y(-2)
series fy(!i+1)=c(1)+d1(!i)*c(2)+d2(!i)*c(3)+c(4)*!i+c(5)*y(!i)+c(6)*y(!i-1)
series u1(!i+1)=y(!i+1)-fy(!i+1)
series rmse(!i+1)=u1(!i+1)^2+rmse(!i)
series mae(!i+1)=abs(u1(!i+1))+mae(!i)
next
scalar MMAE=1/36*mae(216)
scalar RRMSE=(rmse(216)/36)^(1/2)
Re: Recursive OOS forecast
Posted: Tue Jun 28, 2011 2:12 pm
by EViews Gareth
It isn't clear what you're asking here.
However, I will point out that when you write something along the lines of:
and X and Y are series, you are
not assigning into the (!i+1)th row of X. Rather you are assigning into every row of X with a lead (the opposite of a lag) of !i+1.
I'm not 100% certain I follow what you're doing, so I'm not sure if that was what you intended or not.
Re: Recursive OOS forecast
Posted: Tue Jun 28, 2011 3:39 pm
by hxh
That could be the case why it is wrong.
What i want to do is to write in the element !i+1 or use the element !i of a series. This is how it works in matlab or gauss. Probably its wrong here and my results are wrong because of this.
How can I do it correct ?
Re: Recursive OOS forecast
Posted: Tue Jun 28, 2011 3:48 pm
by EViews Gareth
Gauss and Matlab are matrix languages, and the EViews matrix language does work like that. You're not dealing with matrices in your program though :(
For series, the easiest thing to do is to use samples:
Code: Select all
smpl !first+!i @first+!i
x = c(1)*y
Re: Recursive OOS forecast
Posted: Tue Jun 28, 2011 4:05 pm
by hxh
I thought so, that it cant work like in matlab.
Ok I still havent got it how i can set up my AR2 forecast now, because i need for example
f(100)=c(1)+@trend*99+c(3)*y(99)+c(4)*y(98)
where in this loop do i have to add your recommendation ?
Re: Recursive OOS forecast
Posted: Tue Jun 28, 2011 4:27 pm
by EViews Gareth
Translating your line into EViews:
Code: Select all
!i=100
smpl @first+!i-1 @first+!i-1
f = c(1) + @trend*(!i-1) + c(3)*y(-1) + c(4)*y(-2)
Re: Recursive OOS forecast
Posted: Tue Jun 28, 2011 4:43 pm
by hxh
mh somehow he doesnt write , but think its close to work soon
muste be because of the two smpl i set up ?
Code: Select all
for !i=179 to 214
smpl @first @first+!i
equation eq1.ls y c d1 d2 @trend y(-1) y(-2)
smpl @first+!i+1 @first+!i+1
series fy=c(1)+d1(!i-1)*c(2)+d2(!i-1)*c(3)+c(4)*(!i-1)+c(5)*y(-1)+c(6)*y(-2)
series u1=y-fy
next
Re: Recursive OOS forecast
Posted: Tue Jun 28, 2011 4:51 pm
by EViews Gareth
No idea what D1 is, but you probably don't want d1(!i-1)
Re: Recursive OOS forecast
Posted: Tue Jun 28, 2011 5:00 pm
by hxh
d1 is a step dummy variable which takes the value 1 for time >140 and 0 else
d2 is an impulse dummy which takes 1 for 141 and 0 else, ok d2 can be dropped from the forecast
edit : i just used d1 and it works now, ok :)
Re: Recursive OOS forecast
Posted: Mon Aug 15, 2011 5:06 am
by felma
Hi
I'm doing out-of-sample forecasts from a predictive regression model ( i.e y(1) c x y )
It's a recursive scheme and I'm using FOR loop. The problem is that I can't construct the one-period ahead forecasts because I have the error message: forecast doe not support dependent variables with leads or lags.
Is there any possibility to construct the forecast in another way?
Please help me!
Re: Recursive OOS forecast
Posted: Mon Aug 15, 2011 6:28 am
by startz
y c x(-1) y(-1) ?