' set window size 
!window = 500
' set step size
!step = 1
' get size of workfile
!length = @obsrange
'calculate number of rolls
!nrolls = @floor((!length-!window)/!step)
'matrix to store coefficient estimates
matrix(!nrolls,!nrolls)  matg1
' 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 @first+!i+!window-1
' estimate cointegration test
group01.coint(d,4,save=matg1) 
'saving trace statistics
series traceg1=matg1(1,3)
next


