Page 1 of 1

Manipulating estimated coefficients

Posted: Tue Jun 05, 2012 5:58 am
by ziki6368
Hi,

I made a expanding window forecast for the stock return(exstock) against (yspr(-1)). Now what i want is: if the estimation coefficient is positive we keep it and when it is negative we set it to zero for the recursive forecast, so that there will be no forecast power. In this way, we can reduce the prediction error if we know the parameter should have a certain sign. I want to do this through a if command? And how do we specify the coeficient to be 0?

Thanks

for !i = 1 to !length-!window+1-!step step !step
' set sample to estimation period
smpl @first @first+!i+!window-2
' estimate equation
eq1.ls exstock c yspr(-1)
' reset sample to forecast period
smpl @first+!i+!window-1 @first+!i+!window-2+!step
' make forecasts in temporary series first
eq1.forecast(f=na) tmp_yhat tmp_se
' copy data in current forecast sample
yhat = tmp_yhat
yhat_se = tmp_se
next

Re: Manipulating estimated coefficients

Posted: Tue Jun 05, 2012 7:48 am
by EViews Gareth
You cannot set the coefficient for the forecast. However, it looks like you are copying the forecast into another series, so you could always only do that copy if the coefficient is positive.

Code: Select all

if eq1.@coef(2)>0 then yhat = tmp_yhat yhat_se = tmp_se endif