How to compare two vectors?

For questions regarding programming in the EViews programming language.

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

nick3000kimo
Posts: 2
Joined: Tue Aug 21, 2012 8:38 pm

How to compare two vectors?

Postby nick3000kimo » Tue Aug 21, 2012 8:48 pm

Hello,

I have already working for several hours to run if statement on Eviews 6.
My program is as follow, however, vector cc don't have any signal. Pls someone kindly tell me which line should be corrected. Many many thanks.

vector aa = @columnextract(mvmatrix1,1)
vector bb = @columnextract(mvmatrix1,2)
vector(@obs(aa)) cc
if aa>bb then
vector cc = "Buy"
elseif aa<bb then
vector bb = "Sell"
endif
endif

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

How to compare two vectors?

Postby EViews Gareth » Tue Aug 21, 2012 9:39 pm

You'll have to write a loop to go through the elements one at a time.

nick3000kimo
Posts: 2
Joined: Tue Aug 21, 2012 8:38 pm

Re: How to compare two vectors?

Postby nick3000kimo » Tue Aug 21, 2012 9:56 pm

Hello:

Could you please kindly provide a example? Sorry, I don't get it.
Many thanks.

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

Re: How to compare two vectors?

Postby EViews Gareth » Wed Aug 22, 2012 7:47 am

Code: Select all

vector aa = @columnextract(mvmatrix1,1) vector bb = @columnextract(mvmatrix1,2) vector(@obs(aa)) cc for !i=1 to @rows(cc) if aa(!i)>bb(!) then cc(!i) = 1 endif if aa(!i)<bb(!i) then cc(!i) = 0 endif next


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest