Page 1 of 1

Ranking in panel data

Posted: Thu Apr 07, 2011 1:43 am
by thierrydb
I'm relatively new to EViews.
I have a panel containing a numerical data for each (Country x Date).
I would like to create a series that would contain, for each (Country x Date) pair the country's rank compared to other countries at the specified date.

How can I do this?

TDB

Re: Ranking in panel data

Posted: Thu Apr 07, 2011 7:58 am
by EViews Gareth

Code: Select all

series temp = @obsid !timepers = @max(temp) for !i=1 to !timepers smpl @first @first+!i-1 series ranks = @ranks(Y) next
where Y is the series you're ranking. I use the temp series just as a way to find out how many years there are. If you already know that, you can remove the first two lines and simply run the for loop from !i=1 to T, where T is your number of years.

Re: Ranking in panel data

Posted: Thu Apr 07, 2011 8:58 am
by EViews Gareth
Slight typo. Should be:

Code: Select all

series temp = @obsid !timepers = @max(temp) for !i=1 to !timepers smpl @first+!i-1 @first+!i-1 series ranks = @ranks(Y) next

Re: Ranking in panel data

Posted: Thu Apr 07, 2011 2:22 pm
by EViews Gareth
This version is robust to unbalanced panels:

Code: Select all

series temp = @trendc !time = @max(temp) for !i=0 to !time smpl if @trendc = !i series ranks = @ranks(Y) next smpl @all