Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: row number corresponding to a column maximum


From   Gabi Huiber <ghuiber@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: row number corresponding to a column maximum
Date   Tue, 28 Jul 2009 19:47:59 -0400

Glenn is right, of course. And his one-liner is much nicer than my
concoction, with one change: in my notation, the i and j should be
swapped in the formula he proposes.

Example of usage:
-----------------------
drop _all
use http://www.stata-press.com/data/r10/physed
set varabbrev on
cluster averagelink flex speed strength, name(avglnk)
cluster stop avglnk, matrix(a)
mata
A=st_matrix("a")
st_numscalar("maxneighbor",sort(A,2)[rows(A),1])
end
di maxneighbor
----------------------

Thank you,

Gabi

On Tue, Jul 28, 2009 at 7:03 PM, Glenn
Goldsmith<glenn.goldsmith@gmail.com> wrote:
> <>
>
> Kit wrote of Gabi's previous solution:
>
>> I can't see how that can work with colmax(A)[1,j] being hardcoded to look at only the first row of A.
>
> I wondered about this as well at first, but the parentheses mean that
> it's hardcoded to look at the first (and only) row of the rowvector
> returned by colmax()- rather than the first row of A, so it's not
> actually a problem.
>
> Best,
>
> Glenn.
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index