Page 1 of 1

Skipping NA values in Forecast

Posted: Wed May 04, 2016 2:32 am
by muitpen
Hi,
I am having the following problem.

When doing 1-day ahead forecast with expanding estimation window, the code blocks because for one of the regressor (pcr130) there are missing values.
The way I want to modify the code by making it "skip" the forecast when observation for regressor is not available. Forecasting is static so there shouldn't be any problem if a forecast is skipped, since the 1-day ahead uses actual lagged values and not forecasted ones.

If I remove the regressor with missing observation, the code runs smoothly.

Any suggestion?
Many thanks

Code: Select all

'create series for forecast and standard error series y series ye 'forecasts start %d = "12/30/2011" '# obs until end - manually insert, calculated number of days until 8/31/2015 !end = 921 '1-step ahead forecast = 1 day !step = 1 'first sample for estimating equation smpl @first {%d}-{!step}+1 'set the cicle, from 0 to 921 for !i = 0 to {!end}-1 'define sample for equation smpl @first {%d}-{!step}+1+!i 'estimate equation eq1.ls _1future c _1future(-1) vixspot(-1) coma copa pcrall pcr130 'define forecast horizon - 1 day after the sample period smpl {%d}+!i+1 {%d}+!i+1 'forecast the equation and store the predicted value and standard error eq1.fit forecast forecast_se y=forecast ye=forecast_se next 'sample for calculating performance stats smpl 01/03/2012 8/31/2015 scalar mape = @mape( _1future, y) scalar mae = @mae( _1future, y) scalar theil = @theil( _1future, y) scalar rmse = @rmse( _1future, y) smpl 01/03/2012 8/31/2015 'smpl 8/03/2015 8/31/2015 when testing 1 month group A y _1future ( y - 1.96*ye) ( y + 1.96*ye) show a.line

Re: Skipping NA values in Forecast

Posted: Wed May 04, 2016 2:59 am
by EViews Gareth
Hard to see what you're describing without the workfile. By default EViews doesn't error or stop when forecasting and there is an NA in a dependent variable - it just produces the forecast NA and moves on.

Re: Skipping NA values in Forecast

Posted: Wed May 04, 2016 3:05 am
by muitpen
I attached the workfile and the program.

On 14/02/2012 there is NA for the independent variable "pcr130" and I get the following error: "Unable to compute due to missing data in "DO_ EQ1.FIT
FORECAST FORECAST_SE"

Thanks for your help

Re: Skipping NA values in Forecast

Posted: Wed May 04, 2016 3:10 am
by EViews Gareth
Ah, right, EViews will error if the forecast is completely NA due to missing values (as is your case since you're only forecasting one period at a time).

You can just use SETMAXERRS to set the maximum number of errors before failing.

Re: Skipping NA values in Forecast

Posted: Wed May 04, 2016 3:25 am
by muitpen
Great, it works.

Thanks