how to know the location of the minimum of a matrix?

For questions regarding programming in the EViews programming language.

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

tony
Posts: 59
Joined: Wed Jan 07, 2009 7:59 am

how to know the location of the minimum of a matrix?

Postby tony » Thu Apr 19, 2012 1:40 am

I can gain the minimum of a matrix via @min, and I want to know the location of this minimum in the matrix?
Thanks!

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

Re: how to know the location of the minimum of a matrix?

Postby EViews Gareth » Thu Apr 19, 2012 7:41 am

There's nothing built in for that.

EViews Glenn
EViews Developer
Posts: 2682
Joined: Wed Oct 15, 2008 9:17 am

Re: how to know the location of the minimum of a matrix?

Postby EViews Glenn » Thu Apr 19, 2012 9:19 am

As an aside, the reason it doesn't work is that the index functions return a single element, not a pair.

Having said that, I think the following works. Take the matrix and vec it. Then do the arithmetic to find the relevant indices.

Code: Select all

scalar iid = @imin(@vec(mat01))-1 scalar cid = @floor(iid/@rows(mat01))+1 scalar rid = @mod(iid, @rows(mat01))+1
I usually do this stuff in base-0 so you should do some testing to make sure I've gotten the arithmetic part right. I've done a bit of testing and it looks okay, but no guarantees, especially since I haven't had my caffeine yet this morning.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests