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

st: -modes- and -extremes- package updated on SSC


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: -modes- and -extremes- package updated on SSC
Date   Wed, 14 May 2003 14:42:36 +0100

Yesterday, Sylvain Friederich posted a problem 
on Statalist. As a result of musing on that, I have updated the 
-modes- and -extremes- packages, which, thanks 
to Kit Baum, are now available in revised form on SSC. Both 
packages require Stata 8. -extremes- was born under 
Stata 8. A Stata 6 version of -modes- is 
still accessible from STB files (-search modes-). 

-extremes- by default did, and does, this: 

. extremes mpg

  +------------+
  | obs:   mpg |
  |------------|
  |  26.    12 |
  |  27.    12 |
  |  11.    14 |
  |  12.    14 |
  |  28.    14 |
  +------------+

  +------------+
  |  68.    31 |
  |  43.    34 |
  |  57.    35 |
  |  66.    35 |
  |  71.    41 |
  +------------+

note: 6 values of 14

Now there is a new -frequencies- option which 
shows not the # extreme values, but the # 
extreme classes, in both tails (one tail 
only is optional): 

. extremes mpg, frequencies

  +-------------+
  | freq:   mpg |
  |-------------|
  |     2    12 |
  |     6    14 |
  |     2    15 |
  |     4    16 |
  |     4    17 |
  +-------------+

  +-------------+
  |     2    30 |
  |     1    31 |
  |     1    34 |
  |     2    35 |
  |     1    41 |
  +-------------+

In other words, think of a variable treated 
discretely: you see the frequencies of the 
leftmost and rightmost bars of the 
corresponding discrete histogram. 

The -modes- program gives the -modes- package 
its name. -modes- now has a new option to 
specify the number of modes: 

. modes mpg, nmodes(5)

----------------------
Mileage   |
(mpg)     |      Freq.
----------+-----------
       14 |          6
       18 |          9
       19 |          8
       21 |          5
       22 |          5
       25 |          5
----------------------

Note that here 5 is treated as 
a request, not an instruction, 
given the possibility of ties. 

The -modes- package also 
includes a new -rare- command, 
which by default shows singletons: 

. rare mpg

----------------------
Mileage   |
(mpg)     |      Freq.
----------+-----------
       29 |          1
       31 |          1
       34 |          1
       41 |          1
----------------------

The need for -rare- is perhaps 
rare; nevertheless this was part of 
Sylvain's problem and others may find 
it useful. In British, and perhaps 
in other forms of English, we talk 
of searching for a needle in a haystack, 
and, if you face a variant on that, -rare- 
may come in handy. 

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