Dear all,
As I told before, I am trying to build a rolling var forecast. The basic ideia is to build forecasts for "n" periods ahead as if the set of informational available is limited until certain data.
So far I had the following code:
Code: Select all
'create a group of dummies
group dummies jan fev mar abr mai jun jul ago set out nov
'declare data as series
series y= ipca12m
series x1= d_cambio
series x2= selic
series x3=hiato_rolling
'amostra com inicio em jun95=1
'primeira previsao 12 passos a frente para jan99 = 44 na amostra
!inicio = 31
!step = 12
'create vector to store 146 predictions (jan99 - fev11).
vector(146) y_hat
'counter of loops
!rowcounter=1
'define loop
' Ate 145 => previsao ate fev12
for !i=0 to 145
smpl @first @first+!inicio+!i
var var1.ls 1 2 x3 y x1 x2 @ dummies 'ordenamento do var: x3->y->x1->x2
' Dynamic Forecast VAR
var1.makemodel(mod1)
smpl @first+3 @first+!inicio+!i+!step
'define last value of the sample
!previsao = !inicio+!i+!step+1
'dinamic model
mod1.solve(d=d)
'keep ys series
series y_0_{!i} = y_0
'freeze the predicted values
freeze(tabley_0_{!i}) y_0_{!i}
'store the last predicted @ the vector y_hat
y_hat(!rowcounter)= (y_0_{!i} (!previsao))
!rowcounter=!rowcounter+1
d tabley_0_{!i} 'delete the frozen table
next
smpl @all
However, when I tested the code (manually) I realized that it was not working properly... as it seems to be using more information than it should in order to build its predictions.
For the sake of simplicity, I'll try to write an example of what it should be exactly doing, so, maybe, it gets easier for you guys to help me out. Here goes:
For i = 0 it should make the prediction considering all the info available (in each series) from @first until @first+31.
But the sample for the model to build predictions should be @first until @first+31+12, where the last 12 info (in each series ) should read as N/A...
In this case the model would build a prediction as if the only available info was from @first until @first+31...
With the code I built so far, I guess the only thing I'm still missing is how to set the proper range and/or sample to build the model. Could you help me with this step?
Thanks in advance.
Best regards.