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
Manipulating estimated coefficients
Moderators: EViews Gareth, EViews Moderator
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Manipulating estimated coefficients
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
Who is online
Users browsing this forum: No registered users and 1 guest
