Constracting two matrices with odd and even rows

For requesting general information about EViews, sharing your own tips and tricks, and information on EViews training or guides.

Moderators: EViews Gareth, EViews Moderator

RDS
Posts: 86
Joined: Thu Feb 17, 2011 9:50 am

Constracting two matrices with odd and even rows

Postby RDS » Wed Oct 23, 2013 7:37 am

I have a matrix with 100 rows and 100 column: M(100,100).
I need to construct two matrices one with the odd rows and with the even rows: M_odd(50,50 and M_even(50,50)

I have extracted the raws using the following loop
for !i =1 to 100
rowvector r!i = @rowextract(M,!i)
next

How can I construct the two matrices with a loop in order to avoid to following manual approach?
EVEN rows
rowplace(M_even,r1,1)
rowplace(M_even,r3,2)
etc...

ODD rows
rowplace(M_odd,r2,1)
rowplace(M_odd,r4,2)
etc...

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

Re: Constracting two matrices with odd and even rows

Postby EViews Gareth » Wed Oct 23, 2013 8:07 am

Code: Select all

create u 10 matrix(100,100) m rnd(m) vector(50) v_odd vector(50) v_even for !i=1 to 50 v_odd(!i) = !i*2-1 v_even(!i) = !i*2 next matrix m_odd = m.@row(v_odd) matrix m_even = m.@row(v_even)

RDS
Posts: 86
Joined: Thu Feb 17, 2011 9:50 am

Re: Constracting two matrices with odd and even rows

Postby RDS » Wed Oct 23, 2013 8:30 am

I get the following error message

non numeric argment v_odd in "matrix m_odd = m.@row(v_odd)"

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

Re: Constracting two matrices with odd and even rows

Postby EViews Gareth » Wed Oct 23, 2013 8:37 am

Which version of EViews?

RDS
Posts: 86
Joined: Thu Feb 17, 2011 9:50 am

Re: Constracting two matrices with odd and even rows

Postby RDS » Wed Oct 23, 2013 8:38 am

Eviews 7.2

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

Re: Constracting two matrices with odd and even rows

Postby EViews Gareth » Wed Oct 23, 2013 8:43 am

You'll need EViews 8.

RDS
Posts: 86
Joined: Thu Feb 17, 2011 9:50 am

Re: Constracting two matrices with odd and even rows

Postby RDS » Wed Oct 23, 2013 9:02 am

do you have another suggestion which runs in Eviews 7.2?

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

Re: Constracting two matrices with odd and even rows

Postby EViews Gareth » Wed Oct 23, 2013 9:08 am

You'll have to do the rowplace in a loop.


Return to “General Information and Tips and Tricks”

Who is online

Users browsing this forum: No registered users and 2 guests