panel data and rolling window
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
panel data and rolling window
Hello!
Do the example in the sample programs in eviews 7 on rolling forecast with re-estimating coefs work for panel/pool data?
Please advise!!
Do the example in the sample programs in eviews 7 on rolling forecast with re-estimating coefs work for panel/pool data?
Please advise!!
Re: panel data and rolling window
Hello, I am performing a rolling window regression. I tried to elaborate on the existing codes on this forum but I am keeping getting an endless of error messages. Sorry for my simple and silly question, but I am totally beginner in using eviews.. please advise!!! I will attach the WF
Error in Sample: Numeric operator applied to string data in "SMPL IF DATEID = "_ARGENTINA" OR DATEID = "_BRAZIL" OR DATEID = "_ ...
1994M01 is not defined in "%FIRST = @OTOD(@DTOO("@FIRST 1994M01")+1-1)".
1994M01 is not defined in "%LAST = @OTOD(@DTOO("@FIRST 1994M01")+1+12-2)".
Incomplete command in batch mode in "SMPL".
Near singular matrix in "DO_ EQ1.LS PR2 C DC DCG GDP LVIX VIX OV STD_RES P_C".
Equation estimates are invalid or nonexistent in "COLPLACE(COEFMAT,EQ1.@COEFS,1)".
1994M01 is not defined in "%4PERS = @OTOD(@DTOO("@FIRST 1994M01")+1+12-1)".
1994M01 is not defined in "%4PERE = @OTOD(@DTOO("@FIRST 1994M01")+1+12+2)".
2011M12 is not defined in "IF @DTOO("@LAST 2011M12") < @DTOO("") THEN".
Incomplete command in batch mode in "SMPL".
Equation estimates are not valid in "DO_ EQ1.FORECAST(F=NA) PR2F".
Incomplete command in batch mode in "SMPL".
Load onepanel1
smpl dateid = "_Argentina" dateid = "_Brazil" or dateid = "_China" dateid ="_Chile" dateid = "_Czech" or dateid = "_Honk" dateid = "_Hungary" dateid = "_Indonesia" dateid = "_Korea" dateid = "_Mexico" dateid = "_Malaysia" dateid = "_Philippine" dateid = "_Poland" dateid = "_Russia" dateid = "_Singapore" dateid = "_Thailand" dateid = "_Turkey" dateid = "_Venezuela"
!window = 12
' set step size
!step = 4
' 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(7,!nrolls) coefmat
'series to store forecast estimates
series fcast
series pr2f
smpl @first 94M01
smpl @last 2011M12
'*EDITED: catching start and end points
%start = "@first 1994M01" '@otod(@ifirst(ser))
%end = "@last 2011M12" '@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)+!i-1)
%last = @otod(@dtoo(%start)+!i+!window-2)
smpl {%first} {%last}
' estimate equation - where the equation is P =c(1) + c(2)*P1(-1)
eq1.ls pr2 c dc dcg gdp lvix vix ov std_res p_c
' store coefficients
colplace(coefmat,eq1.@coefs,!j)
' 4-period-ahead forecast
%4pers = @otod(@dtoo(%start)+!i+!window-1) 'start point
%4pere = @otod(@dtoo(%start)+!i+!window+2) 'end point: %4pere - %4pers +1 = 4
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 {%4pers} {%4pere}
' forecast with command *forecast* (see also *fit*)
eq1.forecast(f=na) pr2f
' set sampl to obtain the 4th period observation
smpl {%4pere} {%4pere}
' store forecasts
fcast = pr2f
next
smpl @all
show coefmat
show fcast.line
Error in Sample: Numeric operator applied to string data in "SMPL IF DATEID = "_ARGENTINA" OR DATEID = "_BRAZIL" OR DATEID = "_ ...
1994M01 is not defined in "%FIRST = @OTOD(@DTOO("@FIRST 1994M01")+1-1)".
1994M01 is not defined in "%LAST = @OTOD(@DTOO("@FIRST 1994M01")+1+12-2)".
Incomplete command in batch mode in "SMPL".
Near singular matrix in "DO_ EQ1.LS PR2 C DC DCG GDP LVIX VIX OV STD_RES P_C".
Equation estimates are invalid or nonexistent in "COLPLACE(COEFMAT,EQ1.@COEFS,1)".
1994M01 is not defined in "%4PERS = @OTOD(@DTOO("@FIRST 1994M01")+1+12-1)".
1994M01 is not defined in "%4PERE = @OTOD(@DTOO("@FIRST 1994M01")+1+12+2)".
2011M12 is not defined in "IF @DTOO("@LAST 2011M12") < @DTOO("") THEN".
Incomplete command in batch mode in "SMPL".
Equation estimates are not valid in "DO_ EQ1.FORECAST(F=NA) PR2F".
Incomplete command in batch mode in "SMPL".
Load onepanel1
smpl dateid = "_Argentina" dateid = "_Brazil" or dateid = "_China" dateid ="_Chile" dateid = "_Czech" or dateid = "_Honk" dateid = "_Hungary" dateid = "_Indonesia" dateid = "_Korea" dateid = "_Mexico" dateid = "_Malaysia" dateid = "_Philippine" dateid = "_Poland" dateid = "_Russia" dateid = "_Singapore" dateid = "_Thailand" dateid = "_Turkey" dateid = "_Venezuela"
!window = 12
' set step size
!step = 4
' 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(7,!nrolls) coefmat
'series to store forecast estimates
series fcast
series pr2f
smpl @first 94M01
smpl @last 2011M12
'*EDITED: catching start and end points
%start = "@first 1994M01" '@otod(@ifirst(ser))
%end = "@last 2011M12" '@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)+!i-1)
%last = @otod(@dtoo(%start)+!i+!window-2)
smpl {%first} {%last}
' estimate equation - where the equation is P =c(1) + c(2)*P1(-1)
eq1.ls pr2 c dc dcg gdp lvix vix ov std_res p_c
' store coefficients
colplace(coefmat,eq1.@coefs,!j)
' 4-period-ahead forecast
%4pers = @otod(@dtoo(%start)+!i+!window-1) 'start point
%4pere = @otod(@dtoo(%start)+!i+!window+2) 'end point: %4pere - %4pers +1 = 4
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 {%4pers} {%4pere}
' forecast with command *forecast* (see also *fit*)
eq1.forecast(f=na) pr2f
' set sampl to obtain the 4th period observation
smpl {%4pere} {%4pere}
' store forecasts
fcast = pr2f
next
smpl @all
show coefmat
show fcast.line
Last edited by Nas1 on Wed Sep 26, 2012 5:24 pm, edited 1 time in total.
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: panel data and rolling window
From the EViews manual...
...the observation number is not uniquely specified by a date.Note that @dtoo will generate an error if used in a panel structured workfile.
Re: panel data and rolling window
Dear Glenn,
thank you so much for your answer, but please, what is the substitute solution of @dtoo for the panel ??? is it correct to identify countries as above??
I am using Eviews 7.2
when i imported the data from the excel file, the eviews recognize it as a balanced panel file with monthly frequency. how in this case the data is not specified by a date???
Kind regards,
thank you so much for your answer, but please, what is the substitute solution of @dtoo for the panel ??? is it correct to identify countries as above??
I am using Eviews 7.2
when i imported the data from the excel file, the eviews recognize it as a balanced panel file with monthly frequency. how in this case the data is not specified by a date???
Kind regards,
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: panel data and rolling window
@dtoo is returning a single observation number associated with the date. In a panel workfile there are multiple observations associated with a single date.
To be honest, I'm not certain what you are trying to do so it's difficult for me to make concrete suggestions. I will note that you can specify a date pair sample in panels, using the same offsets as in a non panel workfile.
To be honest, I'm not certain what you are trying to do so it's difficult for me to make concrete suggestions. I will note that you can specify a date pair sample in panels, using the same offsets as in a non panel workfile.
Code: Select all
for !i=1 to 20
smpl 1972+!i 1972+!i+50
nextRe: panel data and rolling window
thanks you so much for the suggestion. What I am trying to do is to forecast pr2 series in my WF by using rolling window regression. i was trying to figure out what is the problem but i messed up the codes .
Regards
Regards
Re: panel data and rolling window
I modified the codes but I am still getting this message:
Error in Sample: Range Error in "SMPL. why I am still getting this message??
!window = 216
' set step size
!step = 4
' get size of workfile
!length = @obsrange
' declare equation for estimation
equation eq1
series pr2hat ' point estimates
series pr2hat_se ' forecast std.err.
for !i=1 to 50
smpl 1994+!i 1994+!i+12
next
' move sample !step obs at a time
for !i = 1 to !length-!window+1-!step step !step
' set sample to estimation period
smpl @first+!i-1 @first+!i+!window-2
' estimate equation
eq1.ls pr2 c dc dcg gdp lvix vix ov std_res p_c
' reset sample to forecast period
smpl @first+!i+!window-1 @first+!i+!window-2+!step
' make forecasts in temporarpr2 series first
eq1.forecast(f=na) tmp_pr2hat tmp_se
' coppr2 data in current forecast sample
pr2hat = tmp_pr2hat
pr2hat_se = tmp_se
next
' construct forecast confidence bounds
' approximate 95% interval assuming normal distribution
smpl @all
series pr2hat_upp = pr2hat + 2.0*pr2hat_se
series pr2hat_low = pr2hat - 2.0*pr2hat_se
Error in Sample: Range Error in "SMPL. why I am still getting this message??
!window = 216
' set step size
!step = 4
' get size of workfile
!length = @obsrange
' declare equation for estimation
equation eq1
series pr2hat ' point estimates
series pr2hat_se ' forecast std.err.
for !i=1 to 50
smpl 1994+!i 1994+!i+12
next
' move sample !step obs at a time
for !i = 1 to !length-!window+1-!step step !step
' set sample to estimation period
smpl @first+!i-1 @first+!i+!window-2
' estimate equation
eq1.ls pr2 c dc dcg gdp lvix vix ov std_res p_c
' reset sample to forecast period
smpl @first+!i+!window-1 @first+!i+!window-2+!step
' make forecasts in temporarpr2 series first
eq1.forecast(f=na) tmp_pr2hat tmp_se
' coppr2 data in current forecast sample
pr2hat = tmp_pr2hat
pr2hat_se = tmp_se
next
' construct forecast confidence bounds
' approximate 95% interval assuming normal distribution
smpl @all
series pr2hat_upp = pr2hat + 2.0*pr2hat_se
series pr2hat_low = pr2hat - 2.0*pr2hat_se
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: panel data and rolling window
You've probably set the sample outside of the workfile range.
Re: panel data and rolling window
thank you for your quick answer.. may you please check the data. I know it is a simple issue, but it is confusing me so much and I could not point where is the problem of the range...You've probably set the sample outside of the workfile range.
Last edited by Nas1 on Thu Oct 04, 2012 4:14 am, edited 2 times in total.
Re: panel data and rolling window
I re-modified the dates but still something wrong
' set window size
!window = 12
' get size of workfile
!length = @obsrange
' declare equation for estimation
equation eq1
series pr2hat ' point estimates
series pr2hat_se ' forecast std.err.
' set step size
!step = 4
for !i=1 to 1
smpl 1994M01+!i 1994M01+!i+12
next
' move sample !step obs at a time
for !i = 1 to !length-!window+1-!step step !step
' set sample to estimation period
smpl @first 2011m12+!i-1 @first 2011m12+!i+!window-2
' estimate equation
eq1.ls pr2 c dc dcg gdp lvix vix ov std_res p_c
' reset sample to forecast period
smpl @first 2011m12+!i+!window-1 @first 2011m12+!i+!window-2+!step
' make forecasts in temporarpr2 series first
eq1.forecast(f=na) tmp_pr2hat tmp_se
' coppr2 data in current forecast sample
pr2hat = tmp_pr2hat
pr2hat_se = tmp_se
next
' construct forecast confidence bounds
' approximate 95% interval assuming normal distribution
smpl @all
series pr2hat_upp = pr2hat + 2.0*pr2hat_se
series pr2hat_low = pr2hat - 2.0*pr2hat_se
' set window size
!window = 12
' get size of workfile
!length = @obsrange
' declare equation for estimation
equation eq1
series pr2hat ' point estimates
series pr2hat_se ' forecast std.err.
' set step size
!step = 4
for !i=1 to 1
smpl 1994M01+!i 1994M01+!i+12
next
' move sample !step obs at a time
for !i = 1 to !length-!window+1-!step step !step
' set sample to estimation period
smpl @first 2011m12+!i-1 @first 2011m12+!i+!window-2
' estimate equation
eq1.ls pr2 c dc dcg gdp lvix vix ov std_res p_c
' reset sample to forecast period
smpl @first 2011m12+!i+!window-1 @first 2011m12+!i+!window-2+!step
' make forecasts in temporarpr2 series first
eq1.forecast(f=na) tmp_pr2hat tmp_se
' coppr2 data in current forecast sample
pr2hat = tmp_pr2hat
pr2hat_se = tmp_se
next
' construct forecast confidence bounds
' approximate 95% interval assuming normal distribution
smpl @all
series pr2hat_upp = pr2hat + 2.0*pr2hat_se
series pr2hat_low = pr2hat - 2.0*pr2hat_se
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: panel data and rolling window
What is wrong?
Re: panel data and rolling window
I set the rolling window to be 12 months, but I am getting a full the predicted series including the first 12 observation! Please correct me if I am wrong... is this connected with the type of data I am using or is it the codes??
-
EViews Esther
- EViews Developer
- Posts: 149
- Joined: Fri Sep 03, 2010 7:57 am
Re: panel data and rolling window
Following Glenn's suggestion, the starting point is set to be 1994m01 (as specified in your workfile). The trick that keeps your sample stay in the workfile is to compare the end point (i.e. 1994m01+215) with the forecast end point (i.e. 1994m01+!i+!window+2) and exit the loop when the forecast end point exceeds the end point.
Code: Select all
!window = 12 'set window size
!step = 4 'set step size
!length = @obsrange ' get size of workfile
equation eq1 'declare equation for estimation
series pr2hat 'point estimates
series pr2hat_se ' forecast std.err.
'NOTE: catching the end point
%trend = @getnextname("_trend")
series {%trend} = @trend
!end = @last({%trend}) 'last element of trend = 215
'move sample !step obs at a time
for !i = 1 to !length-!window+1-!step step !step
' set sample for estimation period
smpl 1994m01+!i-1 1994m01+!i+!window-2
' estimate equation
eq1.ls pr2 c dc dcg gdp lvix vix ov std_res p_c
' reset sample to forecast period
if !end < !i+!window+2 then 'check whether the forecast end point is greater than the workfile end point
exitloop
endif
smpl 1994m01+!i+!window-1 1994m01+!i+!window+2
' make forecasts in temporarpr2 series first
eq1.forecast(f=na) tmp_pr2hat tmp_se
' coppr2 data in current forecast sample
pr2hat = tmp_pr2hat
pr2hat_se = tmp_se
next
smpl @all
' construct forecast confidence bounds
' approximate 95% interval assuming normal distribution
series pr2hat_upp = pr2hat + 2.0*pr2hat_se
series pr2hat_low = pr2hat - 2.0*pr2hat_se
d(noerr) {%trend}
Re: panel data and rolling window
thank you so much for the tip, it really helped the work :)
Who is online
Users browsing this forum: No registered users and 2 guests
