[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: return the maximum and corresponding value...
Le Wang said
I have a question regarding Mata. Suppose I have an imaginary matrix
with two columns as follows,
I want Mata to return the maximum values of column 1 (x) AND its
corresonding values in column 2 (y), in this example, 2.9479707 and
0.15. I understand I can use -rowmax- to find the maximum, but I am
not quite sure how to find the corresponding value.
The good news: there is a function undocumented in the manual to
The bad news: it does not appear to work.
This workaround does:
real scalar lewang(real matrix a)
real vector i
Now all this horsing around should be unnecessary, for you should
just be able to call
But that yields
<istmt>: 3499 ii not found
minindex() doesn't seem to work either, even on the examples in the
: v = (3,1,5,7,6)
: minindex(v, 1, i, w)
<istmt>: 3499 i not found
Looks like a bug to me.
Kit Baum, Boston College Economics
An Introduction to Modern Econometrics Using Stata:
* For searches and help try: