Row index of the n-highest value
Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason
Row index of the n-highest value
How do I find the row index of the n-highest value in a group similar to @rimax (n = 2nd, 3rd,...etc.)? Thanks.
-
EViews Matt
- EViews Developer
- Posts: 583
- Joined: Thu Apr 25, 2013 7:48 pm
Re: Row index of the n-highest value
Hello,
You can construct a matrix where the n-th column holds the indices of the n-th largest value in each row. You could then utilize the column of interest. For example, for a group named "g",
The index matrix is "tmp1" in this example. It's first column would match the results of @rimax.
You can construct a matrix where the n-th column holds the indices of the n-th largest value in each row. You could then utilize the column of interest. For example, for a group named "g",
Code: Select all
matrix tmp1 = @transpose(@colcumsum(@ones(@columns(g), @rows(g))))
matrix tmp2 = @rowranks(@convert(g), "d")
for !i = 1 to @rows(tmp1)
rowplace(tmp1, @rapplyranks(@rowextract(tmp1, !i), @rowextract(tmp2,!i)), !i)
next
Who is online
Users browsing this forum: No registered users and 2 guests
