Rolling regression

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

rashid02
Posts: 6
Joined: Sat Oct 17, 2009 10:09 pm

Rolling regression

Postby rashid02 » Sat May 12, 2012 4:27 pm

Hi
I am using the following program taken from this forum to do rolling regression of monthly stocks returns on market index. Each stock has monthly returns data and market return as well (see attached file). The estimation window moves forward one month at a time.
!iwindow = 30
!istep = 1
!length = @obsrange
equation eq1
!nrolls = @round((!length-!iwindow)/!istep)
matrix(2,!nrolls) coefmat
!j=0
for !i = !iwindow to !length
!j=!j+1
smpl @first+!i-1 @first+!i-1+!iwindow
eq1.ls sr2 c mrp
Colplace(coefmat,eq1.@coefs,!j)
next
I want to get log of the sum squared residuals after each estimation window. At the end of program I do not know how can I get a table for all these SSR . I would appreciate your help. thanks
Attachments
eviews1.wf1
(13.96 KiB) Downloaded 524 times

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13586
Joined: Tue Sep 16, 2008 5:38 pm

Re: Rolling regression

Postby EViews Gareth » Sat May 12, 2012 8:11 pm

Create a vector the same size as the number of estimations you'll be doing, then store the @ssr data member of the equation into that vector, in the same way you're storing the coefficients.

rashid02
Posts: 6
Joined: Sat Oct 17, 2009 10:09 pm

Re: Rolling regression

Postby rashid02 » Sun May 13, 2012 5:38 pm

Is the following syntax correct for getting SSR after each regression, where number of obs are 30 months data points and rolling window length 1. I would appreciate your reply thanks
matrix output_ssr{!iwindow}=output{!iwindow}.@ssr

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13586
Joined: Tue Sep 16, 2008 5:38 pm

Rolling regression

Postby EViews Gareth » Sun May 13, 2012 6:08 pm

You need equation.@ssr

rashid02
Posts: 6
Joined: Sat Oct 17, 2009 10:09 pm

Re: Rolling regression

Postby rashid02 » Mon May 14, 2012 4:46 pm

Hi Gareth

Many thanks for your prompt reply. Unfortunately my lack of programming skills, is this equation.@ssr be placed at the end of program?

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13586
Joined: Tue Sep 16, 2008 5:38 pm

Re: Rolling regression

Postby EViews Gareth » Mon May 14, 2012 9:44 pm

It is probably better for you to read through the programming guide, and more of example programs and get an understanding of how what you currently have works, so that you can extend it more easily.

pgupta
Posts: 7
Joined: Mon Apr 01, 2013 10:50 pm

Re: Rolling regression

Postby pgupta » Wed Jun 19, 2013 12:58 pm

Hi,

I am using Rolling Regression technique using the following program. Please find attached the EViews workfile. However, after running this program, the estimated coefficients are not getting reflected in the "coefmat". Did i made an error in the program below. Kindly help me on this. Thank you so much!

!iwindow = 100
!istep = 1
!length = @obsrange
equation eq1
!nrolls = @round((!length-!iwindow)/!istep)
matrix(4,!nrolls) coefmat
!j=0
for !i = !iwindow to !length
!j=!j+1
smpl @first+!i-1 @first+!i-1+!iwindow
eq1.ls y c x1 x2 x3
Colplace(coefmat,eq1.@coefs,!j)
next
show coefmat
Attachments
workfile.wf1
(54.74 KiB) Downloaded 484 times
Last edited by pgupta on Wed Jun 19, 2013 1:02 pm, edited 1 time in total.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13586
Joined: Tue Sep 16, 2008 5:38 pm

Re: Rolling regression

Postby EViews Gareth » Wed Jun 19, 2013 12:59 pm

I just ran that program on that workfile, and coefmat was filled in.

pgupta
Posts: 7
Joined: Mon Apr 01, 2013 10:50 pm

Re: Rolling regression

Postby pgupta » Wed Jun 19, 2013 1:05 pm

Thank you so much for such a quick reply. I ran it again. Same problem. Can this be something with the version? I am using EViews 7. Thanks again.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13586
Joined: Tue Sep 16, 2008 5:38 pm

Re: Rolling regression

Postby EViews Gareth » Wed Jun 19, 2013 1:24 pm


pgupta
Posts: 7
Joined: Mon Apr 01, 2013 10:50 pm

Re: Rolling regression

Postby pgupta » Wed Jun 19, 2013 1:38 pm

Thank you again. I tried it again and it worked!!! :) :)
I just wanted to ask one more question please. Is there any way to check for autocorrelation in all the regressions(141 in this case) run under Rolling Regression program?


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests