Basic Rolling Regression
Moderators: EViews Gareth, EViews Moderator
Re: Basic Rolling Regression
Here it is!
I found out that the coefficient matrix does give enough entries. With 372 obs and a window of 50 the coef matrix gives 322 entries.
So the only problems I have are with the fcast series.
I found out that the coefficient matrix does give enough entries. With 372 obs and a window of 50 the coef matrix gives 322 entries.
So the only problems I have are with the fcast series.
 Attachments

 rollregr.wf1
 (35.75 KiB) Downloaded 390 times

 EViews Developer
 Posts: 149
 Joined: Fri Sep 03, 2010 7:57 am
Re: Basic Rolling Regression
I see that the spreadsheet for "fcast" presents its output from the 24th entry.
 Attachments

 rollregr.wf1
 (35.71 KiB) Downloaded 346 times
Re: Basic Rolling Regression
So what do I do wrong? Here is a screenshot where you can clearly see the spreadsheet from the 13th entry
 Attachments

 PrintScreen.JPG (209.2 KiB) Viewed 17431 times

 EViews Developer
 Posts: 149
 Joined: Fri Sep 03, 2010 7:57 am
Re: Basic Rolling Regression
Please delete the fcast series before running the program?
Re: Basic Rolling Regression
That should do it, I'm sorry for the inconvenience!
Re: Basic Rolling Regression
Hi,
i am trying to do a GARCH (1,1) dynamic forecast, with a rolling window which overlaps. I have 1015 daily observations, and would like to use the past 500days data to forecast the variance for next 21 days. and this is then repeated by moving the window one day forward, such that the no. of days used in forecasting, and forecasted data have same length.
I am using eviews 5, have tried to replicate this using Esther's code for 4 step ahead rolling regression. However, i am getting zeros as my results.
Attached is the code which i have done so far and workfile.
Can someone pls shed some light on how to correct this pls?
Thank you very much.
i am trying to do a GARCH (1,1) dynamic forecast, with a rolling window which overlaps. I have 1015 daily observations, and would like to use the past 500days data to forecast the variance for next 21 days. and this is then repeated by moving the window one day forward, such that the no. of days used in forecasting, and forecasted data have same length.
I am using eviews 5, have tried to replicate this using Esther's code for 4 step ahead rolling regression. However, i am getting zeros as my results.
Attached is the code which i have done so far and workfile.
Can someone pls shed some light on how to correct this pls?
Thank you very much.
 Attachments

 test 1.WF1
 (42.28 KiB) Downloaded 290 times

 thesis code 1.prg
 (1.67 KiB) Downloaded 625 times
Re: Basic Rolling Regression
Dear all,
I am doing a recursive regression modelling and I do not know how to fix the starting date so it does forecasting recursively and not rolling. And I need to know how I can put the first 10 years as the forecasting period. I have data from 1980(1) to 2011(12) and I need it to use 1980(1) to 1989(12) to forecast 1990(1) and so on.
I appreciate any help.
Best
I am doing a recursive regression modelling and I do not know how to fix the starting date so it does forecasting recursively and not rolling. And I need to know how I can put the first 10 years as the forecasting period. I have data from 1980(1) to 2011(12) and I need it to use 1980(1) to 1989(12) to forecast 1990(1) and so on.
I appreciate any help.
Best
Re: Basic Rolling Regression
Hi Gareth,
I am new to eviews and forecasting thingy. My data ranges from 2001.012012.06 monthly data .
Since im using the usoil price at t to forecast exchange rate usdaud at t+1, equation I used is simple as usdaud c usoil, I have adjusted data accordingly, so it wud appear as usoil price at t to forecast exchange rate usdaud at t to avoid my confusion.
I want to use rolling window forecast use sample from 2001.012002.12 24 observations to forecast the 2003.01 and then include the 2003.01 in my sample as 2001.022003.01 to forecast 2003.02 until 2012.06.
Do I need to have the 2001.012012.06 monthly data x and y ready in the workfile to start with the forecasting?
What should I replace the " u 800" in your original code?
could you please help me check if the programme is correct?
I changed couple of things for my basic rolling forecast
Many thanks!!!!!!!!!!!!!!!!!!!
I am new to eviews and forecasting thingy. My data ranges from 2001.012012.06 monthly data .
Since im using the usoil price at t to forecast exchange rate usdaud at t+1, equation I used is simple as usdaud c usoil, I have adjusted data accordingly, so it wud appear as usoil price at t to forecast exchange rate usdaud at t to avoid my confusion.
I want to use rolling window forecast use sample from 2001.012002.12 24 observations to forecast the 2003.01 and then include the 2003.01 in my sample as 2001.022003.01 to forecast 2003.02 until 2012.06.
Do I need to have the 2001.012012.06 monthly data x and y ready in the workfile to start with the forecasting?
What should I replace the " u 800" in your original code?
could you please help me check if the programme is correct?
I changed couple of things for my basic rolling forecast
Code: Select all
'create some data where usdaud as y usoil as x and I am not sure what I shall replace for the below sentence u 800 as the name of my workfile questioning
create u 800
usdaud =nrnd
usoil =nrnd
'
'run rolling regression
' set window size 200101 to 200212 24 data to forecast 200301
!window = 24
' set step size as 200301 to 201206 9 years plus 6month gives 114
!step = 114
' get size of workfile
!length = @obsrange
' declare equation for estimation
equation eq1
'calculate number of rolls
!nrolls = @round((!length!window)/!step)
'matrix to store coefficient estimates
matrix(2,!nrolls) coefmat ' where 2 is the number of coefficients
'variable keeping track of how many rolls we've done
!j=0
' move sample !step obs at a time
for !i = 1 to !length!window+1!step step !step
!j=!j+1
' set sample to estimation period
smpl @first+!i1 @first+!i+!window2
' estimate equation  where the equation is usdaud=c(1) + c(2)*usoil
eq1.ls usdaud c usoil
'store coefficients
colplace(coefmat,eq1.@coefs,!j)
next
show coefmat
Many thanks!!!!!!!!!!!!!!!!!!!
 Attachments

 forecast data.wf1
 the original page indicates all orginal data ( log diff) , the f1 page is the data adjusted by me and ready to go...
 (107.7 KiB) Downloaded 293 times

 01 forecast.wf1
 thats what my manually forecasted file look like.
 (453.48 KiB) Downloaded 287 times

 EViews Developer
 Posts: 149
 Joined: Fri Sep 03, 2010 7:57 am
Re: Basic Rolling Regression
The following three lines will create an undated workfile (named UNTITLED) and generate random series usdaud and usoil.Do I need to have the 2001.012012.06 monthly data x and y ready in the workfile to start with the forecasting?
What should I replace the " u 800" in your original code?
Code: Select all
create u 800 'will create undated workfile with 800 observations
usdaud = nrnd
usoil = nrnd
Since you are trying to do 1period ahead forecast, the following lines should be included in your code.I want to use rolling window forecast use sample from 2001.012002.12 24 observations to forecast the 2003.01 and then include the 2003.01 in my sample as 2001.022003.01 to forecast 2003.02 until 2012.06.
Code: Select all
' 1periodahead forecast
%1pers = @otod(@dtoo(%start)+!i+!window1) 'start point
%1pere = @otod(@dtoo(%start)+!i+!window) 'end point
In your example, each roll would be specified as
2001/01  2002/12
2001/02  2003/01
....
The window size is 24 because each roll has 24 observations, and therefore
Code: Select all
' set window size 200101 to 200212 24 data to forecast 200301
!window = 24
Since the difference between 2001/01 and 2001/02 is "1", the step size should be fixed to be 1.
Code: Select all
' set step size as 1
!step = 1
Re: Basic Rolling Regression
Hi Esther,
Many thanks for your correction.
Please see below as I tidy up the whole code:
Please let me know if there is anything else I need to correct? felt i ask so low level questions
Many thanks for your correction.
Please see below as I tidy up the whole code:
Code: Select all
'run rolling regression
' 1periodahead forecast
%1pers = @otod(@dtoo(%start)+!i+!window1) 'start point
%1pere = @otod(@dtoo(%start)+!i+!window) 'end point
' set window size 200101 to 200212 24 data to forecast 200301
!window = 24
' set step size as 1
!step = 1
' get size of workfile
!length = @obsrange
' declare equation for estimation
equation eq1
'calculate number of rolls
!nrolls = @round((!length!window)/!step)
'matrix to store coefficient estimates
matrix(2,!nrolls) coefmat ' where 2 is the number of coefficients
'variable keeping track of how many rolls we've done
!j=0
' move sample !step obs at a time
for !i = 1 to !length!window+1!step step !step
!j=!j+1
' set sample to estimation period
smpl @first+!i1 @first+!i+!window2
' estimate equation  where the equation is usdaud=c(1) + c(2)*usoil
eq1.ls usdaud c usoil
'store coefficients
colplace(coefmat,eq1.@coefs,!j)
next
show coefmat
Please let me know if there is anything else I need to correct? felt i ask so low level questions

 EViews Developer
 Posts: 149
 Joined: Fri Sep 03, 2010 7:57 am
Re: Basic Rolling Regression
Code: Select all
'run rolling regression
' set window size
!window = 24
' set step size
!step = 1
' get size of workfile
!length = @obsrange
' declare equation for estimation
equation eq1
'calculate number of rolls
!nrolls = @floor((!length!window)/!step)
'matrix to store coefficient estimates
matrix(2,!nrolls) coefmat ' where 2 is the number of coefficients
'series to store forecast estimates
series fcast
'*EDITED: catching start and end points
%start = "@first" '@otod(@ifirst(ser))
%end = "@last" '@otod(@ilast(ser))
'variable keeping track of how many rolls we've done
!j=0
' move sample !step obs at a time
for !i = 1 to !length!window+1!step step !step
!j=!j+1
' set sample for estimation period
%first = @otod(@dtoo(%start)+!i1)
%last = @otod(@dtoo(%start)+!i+!window2)
smpl {%first} {%last}
' estimate equation  where the equation is P =c(1) + c(2)*P1(1)
eq1.ls usdaud c usoil
' store coefficients
colplace(coefmat,eq1.@coefs,!j)
' 1periodahead forecast
%1pers = @otod(@dtoo(%start)+!i+!window1)
%1pere = @otod(@dtoo(%start)+!i+!window)
if @dtoo(%end) < @dtoo(%4pere) then 'check whether the forecast end point is greater than the workfile end point
exitloop
endif
' set smpl for forecasting period
smpl {%1pers} {%1pere}
' forecast with command *forecast* (see also *fit*)
eq1.forecast(f=na) yf
' set sampl to obtain the 4th period observation
smpl {%1pere} {%1pere}
' store forecasts
fcast = yf
next
smpl @all
show coefmat
show fcast.line
d(noerr) yf
Re: Basic Rolling Regression
EViews Esther wrote:Code: Select all
'run rolling regression
' set window size
!window = 24
' set step size
!step = 1
' get size of workfile
!length = @obsrange
' declare equation for estimation
equation eq1
'calculate number of rolls
!nrolls = @floor((!length!window)/!step)
'matrix to store coefficient estimates
matrix(2,!nrolls) coefmat ' where 2 is the number of coefficients
'series to store forecast estimates
series fcast
'*EDITED: catching start and end points
%start = "@first" '@otod(@ifirst(ser))
%end = "@last" '@otod(@ilast(ser))
'variable keeping track of how many rolls we've done
!j=0
' move sample !step obs at a time
for !i = 1 to !length!window+1!step step !step
!j=!j+1
' set sample for estimation period
%first = @otod(@dtoo(%start)+!i1)
%last = @otod(@dtoo(%start)+!i+!window2)
smpl {%first} {%last}
' estimate equation  where the equation is P =c(1) + c(2)*P1(1)
eq1.ls usdaud c usoil
' store coefficients
colplace(coefmat,eq1.@coefs,!j)
' 1periodahead forecast
%1pers = @otod(@dtoo(%start)+!i+!window1)
%1pere = @otod(@dtoo(%start)+!i+!window)
if @dtoo(%end) < @dtoo(%4pere) then 'check whether the forecast end point is greater than the workfile end point
exitloop
endif
' set smpl for forecasting period
smpl {%1pers} {%1pere}
' forecast with command *forecast* (see also *fit*)
eq1.forecast(f=na) yf
' set sampl to obtain the 4th period observation
smpl {%1pere} {%1pere}
' store forecasts
fcast = yf
next
smpl @all
show coefmat
show fcast.line
d(noerr) yf
' set sampl to obtain the 4th period observation
smpl {%1pere} {%1pere}
Before you said it cos mine is 1 period 1 period forecasting... i dnt understand why there is a 4th period ?
Please could you explain? thanks
Re: Basic Rolling Regression
Hi Esther,
I ran this programe but says error
Please see screen shot.
I ran this programe but says error
Please see screen shot.
 Attachments

 Untitled.png (3.44 KiB) Viewed 17171 times

 EViews Developer
 Posts: 149
 Joined: Fri Sep 03, 2010 7:57 am
Re: Basic Rolling Regression
Please change the line to
Code: Select all
if @dtoo(%end) < @dtoo(%4pere) then
Code: Select all
if @dtoo(%end) < @dtoo(%1pere) then
Re: Basic Rolling Regression
Hi Esther,
Many thanks for the help with the code, it works!!!!
You know if you manually forecast 1 period, the fcast graph showed on eviews have information contains " RMSE" and
What should I change if I want to store the RMSE information?
Thanks!
Many thanks for the help with the code, it works!!!!
You know if you manually forecast 1 period, the fcast graph showed on eviews have information contains " RMSE" and
What should I change if I want to store the RMSE information?
Thanks!
Return to “Program Repository”
Who is online
Users browsing this forum: No registered users and 0 guests