Recursive OOS forecast

For questions regarding programming in the EViews programming language.

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

hxh
Posts: 13
Joined: Fri Jun 17, 2011 12:02 am

Recursive OOS forecast

Postby hxh » Tue Jun 28, 2011 1:56 pm

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)

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

Re: Recursive OOS forecast

Postby EViews Gareth » Tue Jun 28, 2011 2:12 pm

It isn't clear what you're asking here.

However, I will point out that when you write something along the lines of:

Code: Select all

x(!1+1) = c(1)*y(!i+1)
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.

hxh
Posts: 13
Joined: Fri Jun 17, 2011 12:02 am

Re: Recursive OOS forecast

Postby hxh » Tue Jun 28, 2011 3:39 pm

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 ?

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

Re: Recursive OOS forecast

Postby EViews Gareth » Tue Jun 28, 2011 3:48 pm

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

hxh
Posts: 13
Joined: Fri Jun 17, 2011 12:02 am

Re: Recursive OOS forecast

Postby hxh » Tue Jun 28, 2011 4:05 pm

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 ?

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

Re: Recursive OOS forecast

Postby EViews Gareth » Tue Jun 28, 2011 4:27 pm

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)

hxh
Posts: 13
Joined: Fri Jun 17, 2011 12:02 am

Re: Recursive OOS forecast

Postby hxh » Tue Jun 28, 2011 4:43 pm

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

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

Re: Recursive OOS forecast

Postby EViews Gareth » Tue Jun 28, 2011 4:51 pm

No idea what D1 is, but you probably don't want d1(!i-1)

hxh
Posts: 13
Joined: Fri Jun 17, 2011 12:02 am

Re: Recursive OOS forecast

Postby hxh » Tue Jun 28, 2011 5:00 pm

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 :)

felma
Posts: 1
Joined: Mon Aug 15, 2011 4:52 am

Re: Recursive OOS forecast

Postby felma » Mon Aug 15, 2011 5:06 am

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!

startz
Non-normality and collinearity are NOT problems!
Posts: 3798
Joined: Wed Sep 17, 2008 2:25 pm

Re: Recursive OOS forecast

Postby startz » Mon Aug 15, 2011 6:28 am

y c x(-1) y(-1) ?


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest