Statalist


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

RE: st: bottom to top or reverse cumulative distribution in table command?


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: bottom to top or reverse cumulative distribution in table command?
Date   Fri, 22 Jan 2010 14:26:24 -0000

Thanks again to Kit, a version with the extra -lt- option is now on SSC. 
Please install or re-install using -ssc- or -adoupdate- if interested. 

The nub of the matter is best shown by an example:

. sysuse auto 

. groups rep78, show(F f Rf) lt

  +---------------------------+
  | rep78   # <   Freq.   # > |
  |---------------------------|
  |     1     0       2    67 |
  |     2     2       8    59 |
  |     3    10      30    29 |
  |     4    40      18    11 |
  |     5    58      11     0 |
  +---------------------------+

. groups rep78, show(F f Rf) ge

  +-----------------------------+
  | rep78   # <=   Freq.   # >= |
  |-----------------------------|
  |     1      2       2     69 |
  |     2     10       8     67 |
  |     3     40      30     59 |
  |     4     58      18     29 |
  |     5     69      11     11 |
  +-----------------------------+

Nick 
[email protected] 

Nick Cox

Thanks to Kit Baum, a revised version of -groups- with an extra -ge- option has been placed on SSC. I believe that option suits Stefan's problem. 

Stata 8 is required. 

For an overview without installation:

. ssc type groups.hlp

For installation or re-installation, use -ssc- or -adoupdate-. 

As someone, some day, may want cumulatives to be "less than" rather than "less than or equal to" I will shortly add an -lt- option. 

Past Fortran (or FORTRAN) users may enjoy a brief moment of nostalgia. 

Nick 
[email protected] 

Nick Cox

I'll look at -groups- to see if this functionality can be added. 

[email protected]

Thanks to Martin, Maarten and Nick for your help!

There are many ways to calculate reverse cumulative distributions in a do file and I already have used that. What I was looking for was a quick and easy solution. I often have people on the phone asking for results and it occurred to me that I couldn't produce this kind of data on the fly (calculation in the head is one option but may be error-prone while talking on the phone). 

- "cumul, equal" works, but requires some additional programming.

- "groups, show(rvpercent)" is very flexible but - as far as I see  - not exactly what I wanted. Options like RVpercent, rpercent or Rpercent produce reverse cumulative distributions of the type "percentage of cases bigger than x" , not "bigger than or equal to x". It works but for "equal or bigger" one has to pick the result from the previous line.

- reversecum works fine. It's a bit slow (compared to the tabulate-command) with big datasets because of the use of preserve, contract and restore, but produces what I was looking for. 

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index