I can gain the minimum of a matrix via @min, and I want to know the location of this minimum in the matrix?
Thanks!
how to know the location of the minimum of a matrix?
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
-
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?
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?
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.
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.
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))+1Who is online
Users browsing this forum: No registered users and 2 guests
