I have a loop rolling regression programming using window 60 and step 1. The result is in matrix, and i need the result in series. First the matrix is (5,132), but i transpose it to (132,5). I wonder if i can change the matrix to series in eviews using MTOS. I've tried using the programming below, but when i run the program, it say Error in Sample: Illegal date S1 in "SMPL S1 @FIRST+59 @LAST", or "error the sample is not define in MTOS" or r1(my matrix) is not the same length with MTOS. I think i have a problem in defining the sample because the first observation length decrease from 192 to 132 when i used rolling regression with window 60.
Does anyone know how to change my matrix into series, so i have 5 series contain of 132 coloumn?
Thanks before.
Code: Select all
cd "c:\Users\Dhitya\Desktop\Program\dataset"
%filenames = @wdir("c:\Users\Dhitya\Desktop\Program\dataset")
for !k=1 to @wcount(%filenames)
%file = @word(%filenames, !k)
wfopen %file
import c:\Users\Dhitya\Desktop\Program\dataset\index\Indeks_2002.csv
import c:\Users\Dhitya\Desktop\Program\dataset\index\FF3_2002.csv
!window = 60
!step = 1
!length = @obsrange
equation eq1
!nrolls = @round((!length-!window)/!step)
matrix(5,!nrolls) coefmat!k
!j=0
for !i = 1 to !length-!window+1-!step step !step
!j=!j+1
smpl @first+!i-1 @first+!i+!window-2
genr return=(((close-close(-1))/close(-1))*100)-rf
equation eq1.ls return c indeks mkt_rf smb hml
colplace(coefmat!k, eq1.@coefs,!j)
matrix(!nrolls,5) r1
matrix r1=@transpose (coefmat!k)
series col1
series col2
series col3
series col4
series col5
group g1 col1 col2 col3 col4 col5
smpl s1 @first+59 @last
mtos(r1, g1, s1)
next
next