Page 1 of 1

How to compare two vectors?

Posted: Tue Aug 21, 2012 8:48 pm
by nick3000kimo
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

How to compare two vectors?

Posted: Tue Aug 21, 2012 9:39 pm
by EViews Gareth
You'll have to write a loop to go through the elements one at a time.

Re: How to compare two vectors?

Posted: Tue Aug 21, 2012 9:56 pm
by nick3000kimo
Hello:

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

Re: How to compare two vectors?

Posted: Wed Aug 22, 2012 7:47 am
by EViews Gareth

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