Moving sample

For questions regarding programming in the EViews programming language.

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

miorinnovo
Posts: 199
Joined: Sun Mar 01, 2015 5:01 pm

Moving sample

Postby miorinnovo » Sat Mar 14, 2015 7:08 pm

Hi,

I'm wondering if there's a way to program an equation so that its estimation uses all data up to point of the next forecast. For example, right now I have one part of the sample (sample1) used to estimate the equation and the rest of the sample (sample2) to create the forecast. As here:

smpl sample1
equation eq1.ls y c x
smpl sample2
eq1.fit y_f

What I'd like to do is have the sample1 not be a fixed set of dates but all the data up to the point of the forecast, so it moves.

Any ideas?

Much appreciated and thanks in advance.

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

Re: Moving sample

Postby EViews Gareth » Sat Mar 14, 2015 8:59 pm

It is called a rolling regression or forecast and there are tons of examples on the forum

Afterall
Posts: 16
Joined: Tue May 27, 2014 7:49 am

Re: Moving sample

Postby Afterall » Mon May 18, 2015 9:12 am

Does anyone know what is wrong in a sample time for this program.:

scalar start= @dtoo("12/31/2012")
scalar end= @dtoo("12/31/2013")
equation eq1
!step=1
for !i =start to end step !step
%date = @otod(!i-1)
scalar element = @elem(h_window, %date)

'reg. equation
smpl (!i-element) (!i)
eq1.ls mah01 c mah01(-1) mah01(-7)

' make forecasts
smpl !i !i
eq2.forecast(f=na) tmp_yhat tmp_se'
mahh01f= tmp_yhat
mahh01f_se = tmp_se
next

The algorithm has to be good, because is taken from some other program language. But I'm not so good program user in eviews.
Attachments
worfile_mah.wf1
(51.26 KiB) Downloaded 289 times

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

Re: Moving sample

Postby EViews Gareth » Mon May 18, 2015 10:20 am

You're trying to set the sample with integers, but your file is dated, so you need to set the sample with dates. You can use the @otod function to convert from an integer observation number into a date.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests