Page **9** of **9**

### Re: Basic Rolling Regression

Posted: **Mon Apr 24, 2017 2:08 am**

by **The Yoyo**

Alice Thai wrote:Dear The Yoyo, thank you so much, I am making progress on this, I have successfully created the rolling window. However, another problem arises since the result only displays around 250 observations (I have attached an image for the issue, I think this could be my data is pooled panel data so the program can only run smoothly for the 170 observations of the first country.). In addition, I want to estimate the change of the coefficients over the time series, so is there any way to display the year on the x-axis instead of the observations? Thank you for your help.

I think this has to do with the fact that it is panel data. To see this, remove the CX=F and WGT=CXSUR options in the Least Squares estimation. It would result in a Sample Range error. I'd assume this is caused by stepping to the next cross-section, at which point the sample will have an end date which is earlier than the start date.

I never worked with panel data regressions, so I have no clue how to solve this. Perhaps someone else does?

### Re: Basic Rolling Regression

Posted: **Tue Apr 25, 2017 1:18 am**

by **Alice Thai**

The Yoyo wrote:Alice Thai wrote:Dear The Yoyo, thank you so much, I am making progress on this, I have successfully created the rolling window. However, another problem arises since the result only displays around 250 observations (I have attached an image for the issue, I think this could be my data is pooled panel data so the program can only run smoothly for the 170 observations of the first country.). In addition, I want to estimate the change of the coefficients over the time series, so is there any way to display the year on the x-axis instead of the observations? Thank you for your help.

I think this has to do with the fact that it is panel data. To see this, remove the CX=F and WGT=CXSUR options in the Least Squares estimation. It would result in a Sample Range error. I'd assume this is caused by stepping to the next cross-section, at which point the sample will have an end date which is earlier than the start date.

I never worked with panel data regressions, so I have no clue how to solve this. Perhaps someone else does?

Thank you The Yoyo for your help. I hope somebody in the forum can give some advice for this problem soon.

### Re: Basic Rolling Regression

Posted: **Thu Dec 21, 2017 1:09 pm**

by **deepika@econdse.org**

Hi

thank you to the entire team for such a wonderful forum. i am doing a 3-period ahead forecast for my series using arima model. my problem is that the program that i run do not give me the same series as the one i would obtain if i would do the entire exercise manually in eviews. can u help??

my estimation period is 1984:m1 1996m1 and i want to obtain 3 period ahead forecast from 1996:m4 to 2017:m2. my program is as follows

series y=cpii

'run rolling regression

' set window size

!window = 145

' set step size

!step = 1

' get size of workfile

!length = @obsrange

' declare equation for estimation

equation eq2

'calculate number of rolls

!nrolls = @floor((!length-!window)/!step)

'matrix to store coefficient estimates

matrix(3,!nrolls) coefmat ' where 2 is the number of coefficients

'series to store forecast estimates

series fcast

'redundant series for 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))

%last = @otod(@dtoo(%start)+!i+!window-2)

smpl {%first} {%last}

' estimate equation - where the equation is y=c(1) + c(2)*x1

eq2.ls(arma=gls, optmethod=gauss-newton) d(y) c ar(1) ma(1)

' store coefficients

colplace(coefmat,eq2.@coef,!j)

' 1-period-ahead forecast

%3pers = @otod(@dtoo(%start)+!i+!window-1) 'start point

%3pere = @otod(@dtoo(%start)+!i+!window+1) 'end point

if @dtoo(%end) < @dtoo(%3pere) then 'check whether the forecast end point is greater than the workfile end point

exitloop

endif

' set smpl for forecasting period

smpl {%3pers} {%3pere}

' forecast with command *forecast* (see also *fit*)

eq2.forecast(f=na) yf

' set sampl to obtain the 4th period observation

smpl {%3pere} {%3pere}

' store forecasts

fcast = yf

next

smpl @all

show coefmat

show fcast.line

d(noerr) yf

where am i going wrong?? can't just figure out

deepika

### Re: Basic Rolling Regression

Posted: **Thu Dec 21, 2017 2:07 pm**

by **EViews Gareth**

Nothing looks particularly wrong.

### Re: Basic Rolling Regression

Posted: **Thu Dec 21, 2017 5:43 pm**

by **deepika@econdse.org**

Thanks for a quick reply. but then why am i not getting the same values as with manually obtaining the recursive forecasts. if the algorithms are the same then same software should be giving similar values. Or do u suggest that i should do this exercise maually?

i am using eviews 9

Thanks

Deepika

### Re: Basic Rolling Regression

Posted: **Thu Dec 21, 2017 6:23 pm**

by **EViews Gareth**

Hard to say. Perhaps you're doing something wrong.

### Re: Basic Rolling Regression

Posted: **Thu Dec 21, 2017 6:34 pm**

by **deepika@econdse.org**

sorry to ask again but could you help me in identifying the problem. i am also attaching my workfile and my program. in the workfile the subworkfile named recursiveestimation is used.

thanks

Deepika

### Re: Basic Rolling Regression

Posted: **Thu Dec 21, 2017 6:45 pm**

by **EViews Gareth**

Having the program and data doesn't help identify what you're doing wrong when you do it manually.

But if I take your equation eq2 and estimate it until 2016m11, then forecast it 3 month (2016m12 2017m2), the compare the forecasted value for 2017m2 with the one generated by the program, they are identical. Which would suggest the program is doing what you want it to.

### Re: Basic Rolling Regression

Posted: **Thu Dec 21, 2017 7:09 pm**

by **deepika@econdse.org**

Shouldnt the eq2 stop estimating at 2016m111` but it stops estimating at 2016m12. i think something is wrong there

Deepika

### Re: Basic Rolling Regression

Posted: **Thu Dec 21, 2017 7:14 pm**

by **deepika@econdse.org**

Also could you pls tell me how you did it manually so that i can check whether i am doing some mistake while doing it manually

Thanks for all the help

Deepika

### Re: Basic Rolling Regression

Posted: **Thu Dec 21, 2017 7:27 pm**

by **EViews Gareth**

Open the equation. Hit the Estimate button. Change the sample so that the end point is 2016m11.

Then hit the forecast button. Set the forecast to 2016m12 to 2017m2.

### Re: Basic Rolling Regression

Posted: **Thu Dec 21, 2017 7:35 pm**

by **deepika@econdse.org**

The manual procedure that i am following is right according to what you have suggested. But if i see the coefficient matrix i m getting 252nd equation which is not desired as it is doing estimation upto 2016m12 whereas the loop should exit after 251th equation only. am i right??

Deepika

### Re: Basic Rolling Regression

Posted: **Thu Dec 21, 2017 7:57 pm**

by **deepika@econdse.org**

sorry for troubling but one more question. for a 6-period ahead forecast how will the program change?

will it be

' 6-period-ahead forecast

%6pers = @otod(@dtoo(%start)+!i+!window-1) 'start point

%6pere = @otod(@dtoo(%start)+!i+!window+4) 'end point

if @dtoo(%end) < @dtoo(%6pere) then 'check whether the forecast end point is greater than the workfile end point

exitloop

endif

' set smpl for forecasting period

smpl {%6pers} {%6pere}

' forecast with command *forecast* (see also *fit*)

eq2.forecast(f=na) yf

' set sampl to obtain the 4th period observation

smpl {%6pere} {%6pere}

or something else?

Deepika

### Re: Basic Rolling Regression

Posted: **Wed Dec 27, 2017 6:35 am**

by **deepika@econdse.org**

Hi

i am trying to do 3 month ahead forecast using single exponential forecast by writing a program. but somehow it seems to run into errors. can you please help on this

Regards

Deepika