Matrix to Series (Eviews 7)

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

mike_d
Posts: 17
Joined: Thu Feb 09, 2012 7:52 am

Matrix to Series (Eviews 7)

Postby mike_d » Mon Feb 20, 2012 1:16 pm

Hi, I am trying to look at some statistics of a common sample of a few variables. What I have been trying to do is to first group the two variables of interest, then create a matrix that contains only common observations and finally convert back to a group in order to run a couple tests. I have been using the 'stom' and 'mtos' command but get a sample error. See below.

group gg s3 s9
stom(gg, mat)
mtos(mat, test_group)


The common sample contains 1645 observations, I also tried to enter the "smpl" command before mtos however this returned errors as well. Any direction would be greatly appreciated.

Thanks

Mike

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13585
Joined: Tue Sep 16, 2008 5:38 pm

Re: Matrix to Series (Eviews 7)

Postby EViews Gareth » Mon Feb 20, 2012 2:19 pm

Nothing wrong with the code per se. Don't quite follow what you're trying to do though.

mike_d
Posts: 17
Joined: Thu Feb 09, 2012 7:52 am

Re: Matrix to Series (Eviews 7)

Postby mike_d » Mon Feb 20, 2012 2:45 pm

What I am trying to do is to deal with a problem I am having when running a cointegration test on pairs of variables. I am looping through many files, I run all tests on the open page 'i', copy output tables to results page, close the page 'i', move to next page 'i'. I was trying to look at the frequency tables of the two variables to be tested to determine if there are only a couple different values for either series (this is highly possible with my dataset), which can cause the error 'matrix near singular.' I have decided to try and approach this differently. I wrote a loop that checks the frequency table ensuring that no variable accounts for more than 50% of the observations. I used a counter, if the counter is less then 1 then the test is run, otherwise a blank table is created (I need tables for coint_test9 through coint_test14 for later on). However the blank tables for some reason are only being created on the first loop. I can paste my entire program if it helps, but basically this procedure loops through 246 files and I obtain the desired result for the first one only. Here is the portion of code I am referring to. Thanks.


scalar counter = 0
group g1 s3
'''johansen cointegration test
for !j = 9 to 14
!old_count = @errorcount
for !check = 9 to 20 step 1
if freq_s!j(!check,1) <> "Total" and freq_s!j(!check,3) > "50" then
counter = counter + 1
endif
next !check
if counter < 1 then
g1.add s!j
freeze(coint_test!j) g1.coint(s)
g1.drop s!j
endif
!new_count = @errorcount
if !old_count < !new_count then
table(16,10) coint_test!j
endif
counter = 0


next !j

mike_d
Posts: 17
Joined: Thu Feb 09, 2012 7:52 am

Re: Matrix to Series (Eviews 7)

Postby mike_d » Mon Feb 20, 2012 3:11 pm

Sorry for wasting your time, I realized a much easier way to do this simply using @errorcount function.




setmaxerrs 6

for !j = 9 to 14

!old_count = @errorcount
g1.add s!j
freeze(coint_test!j) g1.coint(s)
g1.drop s!j

!new_count = @errorcount

if !new_count > !old_count then
table(16,8) coint_test!j
endif

next !j

clearerrs

banhong86
Posts: 2
Joined: Mon Mar 11, 2013 4:05 pm

Re: Matrix to Series (Eviews 7)

Postby banhong86 » Wed May 01, 2013 10:00 pm

Hi Gareth, I have just started using EViews. Below are the codes from me to gather two vectors data into a matrix. I wanted to add up both the r2s and covariance from the same row, thus I opted to use @rsum, how it failed. Could you please give me some advice on this? Is there a way to add up the row in matrix or column in matrix? Thank you for your time.

matrix(10,2) m5
colplace(m5,r2s,1)
colplace(m5,covariance,2)
group g1
mtos(m5,g1)
series sum = @rsum(g1)
show sum

Regards,
Teh

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13585
Joined: Tue Sep 16, 2008 5:38 pm

Re: Matrix to Series (Eviews 7)

Postby EViews Gareth » Thu May 02, 2013 8:13 am

Don't declare the group first:

Code: Select all

matrix(10,2) m5 colplace(m5,r2s,1) colplace(m5,covariance,2) mtos(m5,g1) series sum = @rsum(g1) show sum


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest