Nick,
Thanks. I have been trying to use the -sort(,)- function but I don't think
it will do what I want.
I have found a partial solution: -y = x[r,1]- will permute vector x
according to vector r (see [M-1] p. 52)
. mata
------------------------------------------------- mata (type end to exit)
--: x = (6,9,2,4,7)'
: t = (1, -1,-2,2,0)'
: r = (2, 4, 5, 1, 3)'
: y = x[r,1]
: y
1
+-----+
1 | 9 |
2 | 4 |
3 | 7 |
4 | 6 |
5 | 2 |
+-----+
My new question is how to turn the vector t into the rank order vector r?
Scott
> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of Nick Cox
> Sent: Thursday, May 19, 2005 11:40 AM
> To: [email protected]
> Subject: st: RE: Sort each column of a matrix to have the same rank order
> as another matrix
>
> Is the Mata function -sort(,)- the answer here?
>
> Nick
> [email protected]
>
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/