Indices for Minimum of an Array

Use this forum to post questions about syntax problems or general programming issues. Questions on implementing a particular aspect of econometrics should go in "Econometrics Issues" below.
Ken-Cogger
Posts: 13
Joined: Wed Feb 15, 2012 7:58 pm

Indices for Minimum of an Array

Unread post by Ken-Cogger »

I have an array A(625,625) with minimum value returned by %minvalue(A).
Is there a simple way of returning the indices for this value?
%minindex(A) does not work even though its argument is said to be an array.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Indices for Minimum of an Array

Unread post by TomDoan »

You have to vec and unvec it:

compute ix=%maxindex(%vec(a))
compute col=%block(ix,625)
compute row=%clock(ix,625)
Ken-Cogger
Posts: 13
Joined: Wed Feb 15, 2012 7:58 pm

Re: Indices for Minimum of an Array

Unread post by Ken-Cogger »

What if array A is packed/lower triangular?
Thanks,
Ken.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Indices for Minimum of an Array

Unread post by TomDoan »

Use %SYMMCOL and %SYMMROW instead:

compute ix=%maxindex(%vec(a))
compute col=%symmcol(ix)
compute row=%symmrow(ix)
Post Reply