

'-------------------------------------------------------------------------------------
'run rolling regression


' set window size
!window = 104
 
' set step size
!step = 1
 
' 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(2,!nrolls)  coefmat ' where 2 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

   'set sample to estimation period
   smpl @first+!i-1 @first+!i+!window-2

   'estimate equation
   eq1.ls dlog(ars) c dlog(pall)

   'store coefficients
   colplace(coefmat, eq1.@coefs, !j)


next



matrix coefmat_transpose = @transpose(coefmat)
matrix coefmat_column1 =  coefmat_transpose
matrix coefmat_column1 = @subextract(coefmat_transpose, 1,2)
mtos(coefmat_column1, g1)






