' run rolling pca

' set window size
!window = 10

' set step size
!step = 2

' get size of workfile
!length = @obsrange

' declare group for pca (2 in total)
group pca1 em vix

'calculate number of rolls
!nrolls = @round((!length-!window)/!step)

'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

' store first eigenvalue of PCA in PC1
pca1.makepcomp pc1
next


