Row index of the n-highest value

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason

Laurel
Posts: 19
Joined: Mon May 04, 2020 2:39 pm

Row index of the n-highest value

Postby Laurel » Mon May 11, 2020 6:04 pm

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

Postby EViews Matt » Tue May 12, 2020 11:26 am

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",

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
The index matrix is "tmp1" in this example. It's first column would match the results of @rimax.


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 1 guest