Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Advice on ranking observations


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Advice on ranking observations
Date   Mon, 2 Sep 2002 14:54:16 +0100

PAULINE KNIGHT

> I am using stata 5.0, and my manual does not provide the solution to
the
> following problem, and I cannot find it anywhere else. I hope
someone will
> be able to help. I need to estimate this expression urgently
>        R i (yij) - Rni (yij)
> where Ri (yij) is the ranking of the jth member of group i within
group i,
> and Rni (yij) is the ranking that the jth member of group i would
obtain
> were it ranked in the population of members other than group i.

> I used the 'egen' command with 'rank(exp)' to obtain Ri (yij), but I
cannot identify the
> correct command to obtain the Rni (yij).

I am not clear about the second rank, but one interpretation of
this is as the difference between the within-group
rank and the overall rank.

In Stata 5.0, -egen, rank()- did not include a -by()- option.

For overall rank,

. egen rank = rank(mpg)

For within-group rank,

* Stata 5.0 code, I hope
. gen wrank = .
. for 1 2 3 4 5 : egen wrank@ = rank(mpg) if rep78 == @
. for 1 2 3 4 5 : replace wrank = wrank@ if rep78 == @


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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index