Page 1 of 1
Out of sample forecast with missing values
Posted: Mon Sep 13, 2010 2:21 pm
by PMaier
Hi,
I'm trying to program out-of-sample forecasts (horizon: 3 years, monthly data) with some of the variables containing missing values (I'd like to simply set the forecasts to NA for these observations). Here's what I have to far:
--- snip
for %j var1 var2 var3
for !loop=1 to 36 step 3
smpl %firstdate %lastdate-36+!loop-1
eq_{%j}.ls ' Equation has been defined prior
smpl %lastdate-36+!loop-1 %lastdate-36+!loop
eq_{%j}.fit temp
series projcurr_{%j} = temp
next
next
--- snip
The code works as expected, except for those occasions in which var1-var3 contain missing values. I can set the error count really high, but I'm wondering whether there's a more "elegant" way to test whether a specific observation in a series is an NA. I've experimented with @isna, but that didn't seem to work.
I'm using Eviews 6. Any suggestions would be appreciated.
Many thanks, Philipp
Re: Out of sample forecast with missing values
Posted: Mon Sep 13, 2010 2:29 pm
by EViews Gareth
For a simple case, you could simply set the sample to be the non-NA values:
Code: Select all
for %j var1 var2 var3
for !loop=1 to 36 step 3
smpl %firstdate %lastdate-36+!loop-1
eq_{%j}.ls ' Equation has been defined prior
smpl %lastdate-36+!loop-1 %lastdate-36+!loop if {%j}<>na
eq_{%j}.fit temp
series projcurr_{%j} = temp
next
next
Re: Out of sample forecast with missing values
Posted: Tue Sep 14, 2010 7:27 am
by PMaier
Well,
Unfortunately, it doesn't quite work as expected. I had left out a small complication, but as it turns out, the small complication generates an error message.
My smpl if command also tests whether I'm in a specific month (!m can take the values 1-3, depending on the month in the quarter). So my smpl command read as follows:
smpl %lastdate-36+!loop-1 %lastdate-36+!loop if month=!m
Now I've changed as you suggested to:
smpl %lastdate-36+!loop-1 %lastdate-36+!loop if month=!m and {%j}<>na
... and I get the following error:
"Error in sample: Numeric operator applied to string data...."
Strangely enough, each of the conditions in the smpl if command separately works fine, but the combination of the two doesn't.
Any suggestions would be highly appreciated,
Philipp
PS Here's the code again:
for %j var1 var2 var3
for !loop=1 to 36 step 3
smpl %firstdate %lastdate-36+!loop-1
eq_{%j}.ls ' Equation has been defined prior
smpl %lastdate-36+!loop-1 %lastdate-36+!loop if month=!m and {%j}<>na
eq_{%j}.fit temp
series projcurr_{%j} = temp
next
next
Re: Out of sample forecast with missing values
Posted: Tue Sep 14, 2010 8:12 am
by EViews Gareth
I can't replicate that behaviour. In essence I believe you're doing something similar to this:
Code: Select all
create m 1990 2010
series month = @month
series x=nrnd
!m = 3
%j = "x"
smpl 1991 1995 if month=!m
smpl 1991 1995 if {%j}<>na
smpl 1991 1995 if month=!m and {%j}<>na
All three smpl lines run fine for me.
Re: Out of sample forecast with missing values
Posted: Tue Sep 14, 2010 9:55 am
by PMaier
Gareth,
Thanks for your help. The last line is exactly what I'm trying to accomplish:
smpl 1991 1995 if month=!m and {%j}<>na
More precisely, I get the following:
Error in sample: Numeric operator applied to string data in "SMPL "2010M6"-36-1 "2010M6"-36-1 IF MONTH=1 AND "AUTO"<>NA".
Quite honestly, the IF statement reads exactly as it should read, so I'm a little confused here. Could it be a bug in the Eviews version I'm using? It the June 19 2007 build.
Thanks again, Philipp
Re: Out of sample forecast with missing values
Posted: Tue Sep 14, 2010 10:16 am
by EViews Gareth
That version is massively out of date, so possibly. Try updating.
Re: Out of sample forecast with missing values
Posted: Wed Sep 15, 2010 10:34 am
by PMaier
Well,
I did (now I'm running the Jul. 29, 2010 build), but I still get the same error. On a colleague's machine - he has Eviews 7 - I didn't get the error, though.
Has Eviews changed the SMPL IF command? If so, is there any way I can get this to work in Eviews 6 (any workaround)?
Thanks, Philipp
Re: Out of sample forecast with missing values
Posted: Wed Sep 15, 2010 10:44 am
by EViews Gareth
Nope, nothing has changed, and my code runs fine for me in my EViews 6.