Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: Inverse Cummulative Variable


From   Nick Cox <n.j.cox@durham.ac.uk>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Inverse Cummulative Variable
Date   Mon, 12 Mar 2012 15:30:10 +0000

Here's a way of doing it with ranks: 

. sysuse auto, clear 
(1978 Automobile Data)

. gen work = -mpg

. egen work2 = rank(work), unique

. egen cufreq = max(work2), by(work)

. tabdisp mpg, c(cufreq)

----------------------
Mileage   |
(mpg)     |     cufreq
----------+-----------
       12 |         74
       14 |         72
       15 |         66
       16 |         64
       17 |         60
       18 |         56
       19 |         47
       20 |         39
       21 |         36
       22 |         31
       23 |         26
       24 |         23
       25 |         19
       26 |         14
       28 |         11
       29 |          8
       30 |          7
       31 |          5
       34 |          4
       35 |          3
       41 |          1
----------------------

If you were happy with a tabulation alone, -groups- (SSC) offers another way to do this. 

. groups mpg, show(rF) ge sep(0)

  +------------+
  | mpg   # >= |
  |------------|
  |  12     74 |
  |  14     72 |
  |  15     66 |
  |  16     64 |
  |  17     60 |
  |  18     56 |
  |  19     47 |
  |  20     39 |
  |  21     36 |
  |  22     31 |
  |  23     26 |
  |  24     23 |
  |  25     19 |
  |  26     14 |
  |  28     11 |
  |  29      8 |
  |  30      7 |
  |  31      5 |
  |  34      4 |
  |  35      3 |
  |  41      1 |
  +------------+


Nick 
n.j.cox@durham.ac.uk 


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox
Sent: 12 March 2012 14:33
To: 'statalist@hsphsun2.harvard.edu'
Subject: RE: st: Inverse Cummulative Variable

That's clearly right in principle. In practice, -cumul- is I think easier for what was asked for here.

Nick 
n.j.cox@durham.ac.uk 

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of David Hoaglin

For the number of firms that have at least as many employees (rather
than the percentage of firms), it should be possible to work with
ranks.

David Hoaglin

On Mon, Mar 12, 2012 at 4:04 AM, Nick Cox <njcoxstata@gmail.com> wrote:
> Survivor, survival or reliability function I have often seen for the
> complementary probability. Is it used also for the corresponding
> complementary frequency, which is being sought here?
>

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index