recursive estimation by choosing lag followed by forecasting
Posted: Mon Jul 18, 2011 8:40 am
Dear EviewsTeam,
thank you so much but im falling asleep trying to do this to finalise some papers.
the steps:
1.Choose the best model of y and x-lags by sic. Estimate it from 1990Q1 to 1999Q1 then forecast for 1999Q2 value.
2. Program should then run recursively. This means next will be estimation of 1990Q1 to 1999Q2, choose lags by SC then forecast 1999Q3.
3. Forecast a list of 1999Q2 to 2005Q1 and use y - forecasted y to find RMSE.
i have tried the following but cant seem to join:
'create a variable
series y = dlhs
series x = dpiet
'create empty equation to be used inside the loop
equation eq
'variable to store the minimum AIC. Initialise it to a large number
!sc = 99999999
'variable saying how many lags to go up to
!maxlags = 10
'Variable to store the "best" number of lags
!bestlag = 0
'set sample to be the !maxlag'th value onwards
smpl 1990q1+!maxlags 1999q1
for !i=1 to !maxlags
eq.ls(cov=hac) y c x( to -!i) 'run regression of Y on a constant and lagged values of itself up to the iTH lag.
if eq.@sc < !sc then
!bestlag = !i 'if this lag specification has the best AIC, then store this lag as !bestlag.
!sc = eq.@sc
endif
next
show eq.ls(cov=hac) y c x( to -!bestlag)
'reset sample
smpl @all
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I cant seem to make the date run. How can i do that? How can i also ask for the forecasted value instead of the eqn? i tried to read the rolling out of sample but it gives only coefficients i cant comprehend.
I need a list of forecasted value by recurvsive est. this is for RMSE later.
'create some data
create u 800
series y=nrnd
series x1=nrnd
series x2=nrnd
series z=nrnd
'-------------------------------------------------------------------------------------
'run rolling regression
' set window size
!window = 750
' set step size
!step = 40
' 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(3,!nrolls) coefmat ' where 3 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
-------------------------------------------------------------im so sorry for asking but i have tried part by part.
thank you so much but im falling asleep trying to do this to finalise some papers.
the steps:
1.Choose the best model of y and x-lags by sic. Estimate it from 1990Q1 to 1999Q1 then forecast for 1999Q2 value.
2. Program should then run recursively. This means next will be estimation of 1990Q1 to 1999Q2, choose lags by SC then forecast 1999Q3.
3. Forecast a list of 1999Q2 to 2005Q1 and use y - forecasted y to find RMSE.
i have tried the following but cant seem to join:
'create a variable
series y = dlhs
series x = dpiet
'create empty equation to be used inside the loop
equation eq
'variable to store the minimum AIC. Initialise it to a large number
!sc = 99999999
'variable saying how many lags to go up to
!maxlags = 10
'Variable to store the "best" number of lags
!bestlag = 0
'set sample to be the !maxlag'th value onwards
smpl 1990q1+!maxlags 1999q1
for !i=1 to !maxlags
eq.ls(cov=hac) y c x( to -!i) 'run regression of Y on a constant and lagged values of itself up to the iTH lag.
if eq.@sc < !sc then
!bestlag = !i 'if this lag specification has the best AIC, then store this lag as !bestlag.
!sc = eq.@sc
endif
next
show eq.ls(cov=hac) y c x( to -!bestlag)
'reset sample
smpl @all
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I cant seem to make the date run. How can i do that? How can i also ask for the forecasted value instead of the eqn? i tried to read the rolling out of sample but it gives only coefficients i cant comprehend.
I need a list of forecasted value by recurvsive est. this is for RMSE later.
'create some data
create u 800
series y=nrnd
series x1=nrnd
series x2=nrnd
series z=nrnd
'-------------------------------------------------------------------------------------
'run rolling regression
' set window size
!window = 750
' set step size
!step = 40
' 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(3,!nrolls) coefmat ' where 3 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
-------------------------------------------------------------im so sorry for asking but i have tried part by part.