Ranking in panel data

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

thierrydb
Posts: 3
Joined: Thu Apr 07, 2011 12:51 am

Ranking in panel data

Postby thierrydb » Thu Apr 07, 2011 1:43 am

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

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: Ranking in panel data

Postby EViews Gareth » Thu Apr 07, 2011 7:58 am

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.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: Ranking in panel data

Postby EViews Gareth » Thu Apr 07, 2011 8:58 am

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

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: Ranking in panel data

Postby EViews Gareth » Thu Apr 07, 2011 2:22 pm

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


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests