out-of-sample forecasting with state space models and parameter re-estimation
Posted: Tue Jun 06, 2017 6:11 pm
Hi,
i have a question regarding the correct programming of those state space models, where i want to forecast with re-estimated parameters in a recursive forecasting scheme (because in some circumstances i cannot include the parameters in the state vector).
First i set the estimation period (where !h is the indicator variable for a specific forecast date in the forecast horizon):
for !forecasthorizon=1 to 5 step 1
!foreper = !window-!forecasthorizon+1
for !h=1 to !foreper step 1
' generate state space model and save loglikelihood:
smpl 7/1/2009 9/22/2014+!h-1
after the estimation of the corresponding state space model, i set the forecasting period:
smpl 9/22/2014+!forecasthorizon+!h-1 9/22/2014+!forecasthorizon+!h-1
' sets the forecast horizon
{%modelname}{!forecasthorizon}.forecast(m=n,n=!forecasthorizon) @state * @signal {%modelname}{!forecasthorizon}_lcdsprognose_d @signalse {%modelname}{!forecasthorizon}_lcdsprognosese_d
' generates the forecasts
%date = @datestr(@dateval("9/22/2014")+!forecasthorizon+!h-1,"MM/DD/YYYY")
scalar dummyeins = @elem({%modelname}{!forecasthorizon}_lcdsprognose_d,%date)
scalar dummyzwei = @elem({%modelname}{!forecasthorizon}_lcdsprognosese_d,%date)
matrix(!foreper,1) prognose
matrix(!foreper,1) prognosese
prognose(!h,1) = dummyeins
prognosese(!h,1) = dummyzwei
the matrices prognose / prognosese should store the specific forecast value from the state space model for each !h, subsequently the parameters should be re-estimated and the matrices prognose / prognosese should store the forecast value for (!h+1). Totally the matrices prognose / prognosese should contain !foreper values, because !h goes from 1 to !foreper
But in reality, after a real simulation, the matrices prognose / prognosese contains only few values, 5 values for a forecast horizon of 1 day, 4 values for forecast horizon of 2 days, 3 values for forecast horizon of 3 days and so forth...
What goes wrong? Do you have suggestions where the error in the program is (is possibly the smpl command used wrong in any sense)?
Many thanks in advance for your regularly and excellent support!!!
Bye, Yohan
i have a question regarding the correct programming of those state space models, where i want to forecast with re-estimated parameters in a recursive forecasting scheme (because in some circumstances i cannot include the parameters in the state vector).
First i set the estimation period (where !h is the indicator variable for a specific forecast date in the forecast horizon):
for !forecasthorizon=1 to 5 step 1
!foreper = !window-!forecasthorizon+1
for !h=1 to !foreper step 1
' generate state space model and save loglikelihood:
smpl 7/1/2009 9/22/2014+!h-1
after the estimation of the corresponding state space model, i set the forecasting period:
smpl 9/22/2014+!forecasthorizon+!h-1 9/22/2014+!forecasthorizon+!h-1
' sets the forecast horizon
{%modelname}{!forecasthorizon}.forecast(m=n,n=!forecasthorizon) @state * @signal {%modelname}{!forecasthorizon}_lcdsprognose_d @signalse {%modelname}{!forecasthorizon}_lcdsprognosese_d
' generates the forecasts
%date = @datestr(@dateval("9/22/2014")+!forecasthorizon+!h-1,"MM/DD/YYYY")
scalar dummyeins = @elem({%modelname}{!forecasthorizon}_lcdsprognose_d,%date)
scalar dummyzwei = @elem({%modelname}{!forecasthorizon}_lcdsprognosese_d,%date)
matrix(!foreper,1) prognose
matrix(!foreper,1) prognosese
prognose(!h,1) = dummyeins
prognosese(!h,1) = dummyzwei
the matrices prognose / prognosese should store the specific forecast value from the state space model for each !h, subsequently the parameters should be re-estimated and the matrices prognose / prognosese should store the forecast value for (!h+1). Totally the matrices prognose / prognosese should contain !foreper values, because !h goes from 1 to !foreper
But in reality, after a real simulation, the matrices prognose / prognosese contains only few values, 5 values for a forecast horizon of 1 day, 4 values for forecast horizon of 2 days, 3 values for forecast horizon of 3 days and so forth...
What goes wrong? Do you have suggestions where the error in the program is (is possibly the smpl command used wrong in any sense)?
Many thanks in advance for your regularly and excellent support!!!
Bye, Yohan