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
out-of-sample forecasting with state space models and parameter re-estimation
Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13323
- Joined: Tue Sep 16, 2008 5:38 pm
Re: out-of-sample forecasting with state space models and parameter re-estimation
Declare the matrices outside the loop.
Follow us on Twitter @IHSEViews
Re: out-of-sample forecasting with state space models and parameter re-estimation
Hi Gareth, thank you so far.
But to place this matrices outside the loop is not enough for the code to work.
Let me explain more specific, i think the problem is here:
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
I have observed the following:
1. When i start the program without recursive re-estimation (the parameters are constant, only the states were updated through the forecast horizon), the code works.
2. When i re-estimate the model for each !h, i can produce forecasts for each !h+!forecasthorizon outside the code (i go to the estimated model and produce the forecast by means of the corresponding button)
3. when i start the complete code as stated above, the values are already missed in the signal series output (not only in the matrices prognose / prognosese)
Do you have another suggestion or do you remember a similar forum discussion about this topic?
Is it possible, that the input of the date by means of smpl 9/22/2014+!forecasthorizon+!h-1 is wrong?
Thanks and have a nice day!
Bye, Johannes
But to place this matrices outside the loop is not enough for the code to work.
Let me explain more specific, i think the problem is here:
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
I have observed the following:
1. When i start the program without recursive re-estimation (the parameters are constant, only the states were updated through the forecast horizon), the code works.
2. When i re-estimate the model for each !h, i can produce forecasts for each !h+!forecasthorizon outside the code (i go to the estimated model and produce the forecast by means of the corresponding button)
3. when i start the complete code as stated above, the values are already missed in the signal series output (not only in the matrices prognose / prognosese)
Do you have another suggestion or do you remember a similar forum discussion about this topic?
Is it possible, that the input of the date by means of smpl 9/22/2014+!forecasthorizon+!h-1 is wrong?
Thanks and have a nice day!
Bye, Johannes
Who is online
Users browsing this forum: No registered users and 39 guests