Recursive forecast question
Posted: Thu Nov 01, 2012 1:52 am
Hi there
I am currently doing my masters dissertation on forecasting and I am currently using eveiws 7.2 for my work. I want to forecast spot exchange rate from my error correction model (ecm) for two variables with b(1 -1) as a restriction in the model. However i want to make the forecast from 51 ecm recursions (so I estimate 51 ecm by rolling the sample size three months foreward until I exhaust my sample estimation period). And im using each recursions from 1-51 to forecast spot exchange (for horizon 1-46). Since i plan to do forecast evaluation, I also use the actual exchange rate values as well as forecast from a random walk. So my first step was to create 46 matrices each with 51 rows and 3 columns. So the first matrix will contain one step ahead forecast from all 51 recursions from ecm, random walk and actual series (in the 3 rows), while the second matrix will contain two step ahead forecast and so on. My second step was to generate forecast_emh (emh means efficient market hypothesis, although written in an error correction form) recursively and make the out of sample values zero. My third step was to estimate my emh model where sgbp is my spot exchange rate, fgbp is my forward exchange rate and xgbp is spot-forward (for the restriction). My fourth step was to create my forecast from each recusions and my fifth step is to replace the zeros in the matrices with my forecast values and finally my sixth step was for eviews to hold only the 46 matrices i created in the first step. Eviews reported the 46 matrices but only the first matrix had all the forecast values. I did this manually to check and found the values to match. However the first column of all the other matrices, which is suppose to contain h-horizon forecast from the ecm with h=2,....,46, had "not available (N/A)" in them.. Thus what eveiws has done is forecast only 1-step ahead from all 51 recursions, even though i added the command for !h=1 to !hmax. Could anyone please advice on how i can create 2-46 steps ahead forecast for all 51 recursion...
first step
!hmax=46
for !j=1 to !hmax
matrix (51,3) emh_forecast_!j =0
next
second step
for !i=1 to 51
smpl @first 1989m09+!i*3
genr forecast_emh_{!i} = sgbp
smpl 1989m09+!i*3+1 @last
forecast_emh_{!i} = 0
Third step
smpl 1980m12 1989m09+!i*3
equation EMH_{!i}.cointreg(method=dols,lltype=none) sgbp c xgbp
genr EMH_resid_{!i}=resid
smpl 1981m01 1989m09+!i*3
equation EMH_ECM_{!i}.ls d(sgbp) c d(sgbp(-1)) d(fgbp(-1)) d(sgbp(-2)) d(fgbp(-2)) d(sgbp(-3))d(fgbp(-3)) d(sgbp(-4)) d(fgbp(-4)) d(sgbp(-5)) d(fgbp(-5)) d(sgbp(-6)) d(fgbp(-6)) d(sgbp(-7)) d(fgbp(-7)) d(sgbp(-8)) d(fgbp(-8)) d(sgbp(-9)) d(fgbp(-9)) d(sgbp(-10)) d(fgbp(-10)) d(sgbp(-11)) d(fgbp(-11)) d(sgbp(-12)) d(fgbp(-12)) EMH_resid_{!i}(-1)
Fourth step
for !h=1 to !hmax
smpl 1989m09+!i*3+!h 1989m09+!i*3+!h
forecast_emh_{!i} = forecast_emh_{!i}(-1)+EMH_ECM_{!i}.@coefs(1) + d(sgbp(-1))*EMH_ECM_{!i}.@coefs(2) + d(fgbp(-1))*EMH_ECM_{!i}.@coefs(3) + d(sgbp(-2))*EMH_ECM_{!i}.@coefs(4) + d(fgbp(-2))*EMH_ECM_{!i}.@coefs(5) + d(sgbp(-3))*EMH_ECM_{!i}.@coefs(6) + d(fgbp(-3))*EMH_ECM_{!i}.@coefs(7) + d(sgbp(-4))*EMH_ECM_{!i}.@coefs(8) + d(fgbp(-4))*EMH_ECM_{!i}.@coefs(9) + d(sgbp(-5))*EMH_ECM_{!i}.@coefs(10) + d(fgbp(-5))*EMH_ECM_{!i}.@coefs(11) + d(sgbp(-6))*EMH_ECM_{!i}.@coefs(12) + d(fgbp(-6))*EMH_ECM_{!i}.@coefs(13) + d(sgbp(-7))*EMH_ECM_{!i}.@coefs(14) + d(fgbp(-7))*EMH_ECM_{!i}.@coefs(15) + d(sgbp(-8))*EMH_ECM_{!I}.@coefs(16) + d(fgbp(-8))*EMH_ECM_{!i}.@coefs(17) + d(sgbp(-9))*EMH_ECM_{!i}.@coefs(18)+ d(fgbp(-9))*EMH_ECM_{!i}.@coefs(19) + d(sgbp(-10))*EMH_ECM_{!i}.@coefs(20) + d(fgbp(-10))*EMH_ECM_{!I}.@coefs(21) + d(sgbp(-11))*EMH_ECM_{!i}.@coefs(22) + d(fgbp(-11))*EMH_ECM_{!i}.@coefs(23) + d(sgbp(-12))*EMH_ECM_{!i}.@coefs(24) + d(fgbp(-12))*EMH_ECM_{!i}.@coefs(25) + EMH_resid_{!i}(-1) *EMH_ECM_{!i}.@coefs(26)
Fifth step
emh_forecast_!h(!i,1) = forecast_emh_{!i}(@dtoo("1989m09")+!i*3+!h)
emh_forecast_!h(!i,2)=sgbp(@dtoo("1989m09")+!i*3+!h)
emh_forecast_!h(!i,3)=sgbp(@dtoo("1989m09")+!i*3)
next
Sixth step
delete forecast_emh_{!i}
delete EMH_{!i}
delete EMH_resid_{!i}
delete EMH_ECM_{!i}
next
I am currently doing my masters dissertation on forecasting and I am currently using eveiws 7.2 for my work. I want to forecast spot exchange rate from my error correction model (ecm) for two variables with b(1 -1) as a restriction in the model. However i want to make the forecast from 51 ecm recursions (so I estimate 51 ecm by rolling the sample size three months foreward until I exhaust my sample estimation period). And im using each recursions from 1-51 to forecast spot exchange (for horizon 1-46). Since i plan to do forecast evaluation, I also use the actual exchange rate values as well as forecast from a random walk. So my first step was to create 46 matrices each with 51 rows and 3 columns. So the first matrix will contain one step ahead forecast from all 51 recursions from ecm, random walk and actual series (in the 3 rows), while the second matrix will contain two step ahead forecast and so on. My second step was to generate forecast_emh (emh means efficient market hypothesis, although written in an error correction form) recursively and make the out of sample values zero. My third step was to estimate my emh model where sgbp is my spot exchange rate, fgbp is my forward exchange rate and xgbp is spot-forward (for the restriction). My fourth step was to create my forecast from each recusions and my fifth step is to replace the zeros in the matrices with my forecast values and finally my sixth step was for eviews to hold only the 46 matrices i created in the first step. Eviews reported the 46 matrices but only the first matrix had all the forecast values. I did this manually to check and found the values to match. However the first column of all the other matrices, which is suppose to contain h-horizon forecast from the ecm with h=2,....,46, had "not available (N/A)" in them.. Thus what eveiws has done is forecast only 1-step ahead from all 51 recursions, even though i added the command for !h=1 to !hmax. Could anyone please advice on how i can create 2-46 steps ahead forecast for all 51 recursion...
first step
!hmax=46
for !j=1 to !hmax
matrix (51,3) emh_forecast_!j =0
next
second step
for !i=1 to 51
smpl @first 1989m09+!i*3
genr forecast_emh_{!i} = sgbp
smpl 1989m09+!i*3+1 @last
forecast_emh_{!i} = 0
Third step
smpl 1980m12 1989m09+!i*3
equation EMH_{!i}.cointreg(method=dols,lltype=none) sgbp c xgbp
genr EMH_resid_{!i}=resid
smpl 1981m01 1989m09+!i*3
equation EMH_ECM_{!i}.ls d(sgbp) c d(sgbp(-1)) d(fgbp(-1)) d(sgbp(-2)) d(fgbp(-2)) d(sgbp(-3))d(fgbp(-3)) d(sgbp(-4)) d(fgbp(-4)) d(sgbp(-5)) d(fgbp(-5)) d(sgbp(-6)) d(fgbp(-6)) d(sgbp(-7)) d(fgbp(-7)) d(sgbp(-8)) d(fgbp(-8)) d(sgbp(-9)) d(fgbp(-9)) d(sgbp(-10)) d(fgbp(-10)) d(sgbp(-11)) d(fgbp(-11)) d(sgbp(-12)) d(fgbp(-12)) EMH_resid_{!i}(-1)
Fourth step
for !h=1 to !hmax
smpl 1989m09+!i*3+!h 1989m09+!i*3+!h
forecast_emh_{!i} = forecast_emh_{!i}(-1)+EMH_ECM_{!i}.@coefs(1) + d(sgbp(-1))*EMH_ECM_{!i}.@coefs(2) + d(fgbp(-1))*EMH_ECM_{!i}.@coefs(3) + d(sgbp(-2))*EMH_ECM_{!i}.@coefs(4) + d(fgbp(-2))*EMH_ECM_{!i}.@coefs(5) + d(sgbp(-3))*EMH_ECM_{!i}.@coefs(6) + d(fgbp(-3))*EMH_ECM_{!i}.@coefs(7) + d(sgbp(-4))*EMH_ECM_{!i}.@coefs(8) + d(fgbp(-4))*EMH_ECM_{!i}.@coefs(9) + d(sgbp(-5))*EMH_ECM_{!i}.@coefs(10) + d(fgbp(-5))*EMH_ECM_{!i}.@coefs(11) + d(sgbp(-6))*EMH_ECM_{!i}.@coefs(12) + d(fgbp(-6))*EMH_ECM_{!i}.@coefs(13) + d(sgbp(-7))*EMH_ECM_{!i}.@coefs(14) + d(fgbp(-7))*EMH_ECM_{!i}.@coefs(15) + d(sgbp(-8))*EMH_ECM_{!I}.@coefs(16) + d(fgbp(-8))*EMH_ECM_{!i}.@coefs(17) + d(sgbp(-9))*EMH_ECM_{!i}.@coefs(18)+ d(fgbp(-9))*EMH_ECM_{!i}.@coefs(19) + d(sgbp(-10))*EMH_ECM_{!i}.@coefs(20) + d(fgbp(-10))*EMH_ECM_{!I}.@coefs(21) + d(sgbp(-11))*EMH_ECM_{!i}.@coefs(22) + d(fgbp(-11))*EMH_ECM_{!i}.@coefs(23) + d(sgbp(-12))*EMH_ECM_{!i}.@coefs(24) + d(fgbp(-12))*EMH_ECM_{!i}.@coefs(25) + EMH_resid_{!i}(-1) *EMH_ECM_{!i}.@coefs(26)
Fifth step
emh_forecast_!h(!i,1) = forecast_emh_{!i}(@dtoo("1989m09")+!i*3+!h)
emh_forecast_!h(!i,2)=sgbp(@dtoo("1989m09")+!i*3+!h)
emh_forecast_!h(!i,3)=sgbp(@dtoo("1989m09")+!i*3)
next
Sixth step
delete forecast_emh_{!i}
delete EMH_{!i}
delete EMH_resid_{!i}
delete EMH_ECM_{!i}
next