Page 1 of 1

Coding in sample ranges

Posted: Mon Feb 23, 2015 1:17 pm
by ian.e.preston
I'm trying to produce rolling month ahead forecasts to test a model. The way I'm doing this is by looping over years and months and then setting the sample appropriately. The only way I've found to set my sample range seems really backwards and I'm hoping for a better way. My data is daily with a 5 day week and I'm using Eviews 7.

Code: Select all

for !y = 2001 to 2015 'forecast over all available years if !y=2015 then !mm=@datepart(@now,"mm") else !mm = 12 'Only forecast from a starting point in the present endif for !m = 1 to !mm 'loop through the months of the year 'For each month we produce a remainder of the month forecast and 3 months out %from = @datestr(@makedate(!y, !m, 15, "yyyy mm dd"),"mm/dd/yyyy") %to = @datestr(@makedate(!y, !m+3, "yyyy mm"),"mm/dd/yyyy") smpl %from %to
I'm not sure why I can't just use

Code: Select all

smpl @makedate(!y, !m, 15, "yyyy mm dd") @makedate(!y, !m+3, "yyyy mm")
But if I do that I get an illegal date. The same happens if I don't assign %first or %last to the @datestr and put it in directly. I'm guessing this is caused by some misunderstanding on my part of how Eviews interprets samples, but I can't figure it out from reading the documentation. If someone could provide a simpler way of coding this, and the intuition behind it I'd be grateful

As a simpler example, this also doesn't work:

Code: Select all

smpl 2003 @makedate(2004,"yyyy")
even though this does

Code: Select all

smpl 2003 2004

Re: Coding in sample ranges

Posted: Mon Feb 23, 2015 4:16 pm
by EViews Gareth
The smpl command does not accept dates. Rather it accepts string representations of dates.
Store the dates you want into program variables, then use those string variables in the smpl statement.

Re: Coding in sample ranges

Posted: Tue Feb 24, 2015 10:21 am
by ian.e.preston
Ok, so why doesn't this work?

Code: Select all

smpl @datestr(@makedate(!y, !m, 15, "yyyy mm dd"),"mm/dd/yyyy") @datestr(@makedate(!y, !m+3, "yyyy mm"),"mm/dd/yyyy")
instead I have to use

Code: Select all

%from = @datestr(@makedate(!y, !m, 15, "yyyy mm dd"),"mm/dd/yyyy") %to = @datestr(@makedate(!y, !m+3, "yyyy mm"),"mm/dd/yyyy") smpl %from %to
I guess my issue is that this seems like a really unwieldy way of working with dates and samples. It works, but I feel like I'm doing things really inefficiently. Is there a better method I could be using to create my samples?

Re: Coding in sample ranges

Posted: Tue Feb 24, 2015 10:54 am
by EViews Gareth
I would probably do it the way you currently are.

Samples do allow simple observation addition.

So you could do:

Code: Select all

smpl 2005m1+11 2006m1+11
to mean December 2005 until December 2006, for example. You could possibly rewrite your loops to work in that format instead.