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
Recursive forecast question
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
-
EViews Esther
- EViews Developer
- Posts: 149
- Joined: Fri Sep 03, 2010 7:57 am
Re: Recursive forecast question
Can you post your workfile? I am curious about the workfile range.
Re: Recursive forecast question
Okay, I have attached the file in excel form. However the only variables needed for the command i posted are SPOT USDGBP (sgbp), FORWARD USDGBP(fgbp) and to generate a third variable named xgbp = sgbp - fgbp. If you run the command i posted earlier with the variables, you will see what i mean and might be able to see where i am going wrong.
Thanks
Thanks
- Attachments
-
- Complete data.xlsx
- (133.51 KiB) Downloaded 562 times
Re: Recursive forecast question
Hi Esther
Just wanted to ask if you've done anything with the data yet, i couldn't send as eviews workfile because i don't have eviews at home..Please let me know if you are able to see what's wrong with my commands
Thanks
Just wanted to ask if you've done anything with the data yet, i couldn't send as eviews workfile because i don't have eviews at home..Please let me know if you are able to see what's wrong with my commands
Thanks
Re: Recursive forecast question
I have now attached my eviews workfile from the uni
- Attachments
-
- eviews data 1972-2006.wf1
- (154.72 KiB) Downloaded 440 times
-
EViews Esther
- EViews Developer
- Posts: 149
- Joined: Fri Sep 03, 2010 7:57 am
Re: Recursive forecast question
The program bug comes from the bad indexation. In order to resolve this problem, we should clarify the problem settings again.
According to your program, the matrix emh_forecast_{!j} (!j=1,...46) should have j-period-ahead forecast at its first column where each emh_forecast_{!j} is the !j-period-forecast matrix. Specifically, 1-by-1 element of emh_forecast_1 contains 1-period-ahead forecast from ecm_1 and 2-by-1 element contains 1-period-ahead forecast from ecm_2, and so on. Is this what you think about the problem?
Or, do you think that the 2-by-1 element should be 2-period-ahead forecast from ecm_1, and so on?
According to your program, the matrix emh_forecast_{!j} (!j=1,...46) should have j-period-ahead forecast at its first column where each emh_forecast_{!j} is the !j-period-forecast matrix. Specifically, 1-by-1 element of emh_forecast_1 contains 1-period-ahead forecast from ecm_1 and 2-by-1 element contains 1-period-ahead forecast from ecm_2, and so on. Is this what you think about the problem?
Or, do you think that the 2-by-1 element should be 2-period-ahead forecast from ecm_1, and so on?
Re: Recursive forecast question
Thanks for the reply Esther. I think the second case should apply, so the 2-by-1 element should be 2-period-ahead forecast from ecm_1, and so on? I have found the problem to be on my forecasting equation but yet to be resolved. What i found is that in the equation below,if i remove the last element EMH_resid_{!i}(-1) *EMH_ECM_{!i}.@coefs(26), the forecast command works, so the problem is on that element..I think what is going on is that from ecm_1, the one step ahead forecast can be done because it is able to pick up the last residuals at time T, but in order to make the two-steps ahead forecast, from ecm_1 (i.e. T+2), it needs the residual T+1 which is unavailable from the ecm_1 estimation. The forecasts without the residuals can be made because the command includes the real series of sgbp and fgbp. So as much as I'm carrying forward the forecast from other elements to be able to make forecasts for T+1,......T+46, I also need to carry forward the residuals. Any suggestion on how i can do this please?
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)
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)
-
EViews Esther
- EViews Developer
- Posts: 149
- Joined: Fri Sep 03, 2010 7:57 am
Re: Recursive forecast question
Let me know how it works.
Code: Select all
!hmax = 46
for !i=1 to 51
'First step: create 46 matrices each with 46 rows and 2 columns: ignored 3rd col (the actual values)
matrix (46,2) emh_forecast_{!i}
'Second step: generate forecast_emh recursively and make the out of sample values zero
series forecast_emh = 0
smpl @first 1989m09+!i*3 '!i*3 = rolling window
forecast_emh = sgbp
'Third step: estimate my emh model
smpl 1980m12 1989m09+!i*3
equation EMH_{!i}.cointreg(method=dols,lltype=none) sgbp c xgbp
series 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: create my forecast from each recusions
for !h=1 to !hmax
smpl 1989m09+!i*3+!h 1989m09+!i*3+!h
forecast_emh = forecast_emh(-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_ECM_{!i}.@coefs(26)
next
smpl @all
'Fifth step: replace the zeros in the matrices with my forecast values
vector submat1 = @subextract(forecast_emh,@dtoo("1989m09")+!i*3+1,1,@dtoo("1989m09")+!i*3+46,1)
vector submat2 = @subextract(sgbp,@dtoo("1989m09")+!i*3+1,1,@dtoo("1989m09")+!i*3+46,1)
matplace(emh_forecast_{!i},submat1,1,1)
matplace(emh_forecast_{!i},submat2,1,2)
next
Who is online
Users browsing this forum: No registered users and 2 guests
