Page 1 of 1

rolling window help

Posted: Tue Apr 21, 2009 12:41 pm
by g_anluca
greetings everyone!

i am trying to do a rolling window static forecast out of a simple ECM model but i cannot manage to obtain the complete forecast: that is when i look in the forecast output (wtifore) i only get the results for the last iteration of the loop. here's the code

scalar obs=5490
scalar window= 500

for !i = window to obs-window

smpl !i-window+1 !i
equation prova_ecm
prova_ecm.ls d(wti) c d(wti_f3) u(-1)

smpl !i+1 !i+window
prova_ecm.fit wtifore


next

smpl @all


i know i should create something to contain the forecasted values after each iteration to avoid overwriting them, but i just can't figure out how. can anyone help me?

tx in advance [edit: i'll attach also the wf]

Re: rolling window help

Posted: Fri May 01, 2009 3:10 am
by trubador
Try this way:

Code: Select all

scalar obs=5490 scalar window= 500 matrix(window,obs-2*window+1) results for !i = window to obs-window smpl !i-window+1 !i equation prova_ecm prova_ecm.ls d(wti) c d(wti_f3) u(-1) sample s !i+1 !i+window prova_ecm.fit wtifore stom(wtifore,rvector,s) colplace(results,rvector,!i-window+1) delete s rvector next smpl @all