Rolling Regression
Posted: Wed Nov 30, 2011 2:45 am
I am working on my dissertation. I have eleven years monthly data on 300 stocks and the market index. I have already calculated the log returns for the stocks and market in excel and have imported the data into excel file. I need to estimate a rolling regression of each stock where the moving window is 36 that is the estimated coefficient needs to be based on last 36 months observations and then continue to drop the first month i.e. month 1 and add the next month i.e. month 37. I need to estimate the regression using GMM estimation. The model is given by sr c mrp ar(1) @ c sr(-1) mrp(-1). So far I have done the following:
!iwindow = 36
!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 2000m7 2000m7+!i+!i-2
eq1.gmm(options) sr2 c mrp ar(1) @ sr2(-1) mrp(-1)
Colplace(coefmat,eq1.@coefs,!j)
next
I am particularly worried about whether the moving window declaration above is correct as i am unsure of it. further when I run the program I get this message:
Matrix size mismatch in "Colplace(coefmat,eq1.@coefs,1)". The attached file contains data for analysis.
Further I need to know how to get access to the coefficients estimated above. Your help will be highly appreciated.
Regards
!iwindow = 36
!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 2000m7 2000m7+!i+!i-2
eq1.gmm(options) sr2 c mrp ar(1) @ sr2(-1) mrp(-1)
Colplace(coefmat,eq1.@coefs,!j)
next
I am particularly worried about whether the moving window declaration above is correct as i am unsure of it. further when I run the program I get this message:
Matrix size mismatch in "Colplace(coefmat,eq1.@coefs,1)". The attached file contains data for analysis.
Further I need to know how to get access to the coefficients estimated above. Your help will be highly appreciated.
Regards