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

Re: st: how to get a scalar value of the ... mode


From   Roger Newson <roger.newson@kcl.ac.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: how to get a scalar value of the ... mode
Date   Fri, 16 Aug 2002 14:08:56 +0100

At 15:29 16/08/02 +0300, Tarmo Räty wrote:
Recently Roger adviced us on how to get a scalar value of the column sum
by

summ x
scal sidney=r(sum)

Works OK, for the most of the statistics, but I need the mode. After
short look on manuals, no funtion returns r(mode). Currently I'm using
egen and picking an observation from the created variable, but there
must be an easy way.
One fundamental problem here is that the mode is not necessarily unique, as many discrete values of a variable can have an equal frequency, and that frequency may be the highest frequency. You would have to specify which mode to use in such cases.

If, in Web-aware Stata, you type

findit modes

then you will find (among other things) that Nick Cox has written a program -modes-, which outputs the whole set of modes to the stata log, and that Nick Cox and Fred Wolfe have written a program -tomode-, which can generate a new variable containing a mode of an existing variable. There are options for choosing which mode out of several.

I hope this helps.

Roger


--
Roger Newson
Lecturer in Medical Statistics
Department of Public Health Sciences
King's College London
5th Floor, Capital House
42 Weston Street
London SE1 3QD
United Kingdom

Tel: 020 7848 6648 International +44 20 7848 6648
Fax: 020 7848 6620 International +44 20 7848 6620
or 020 7848 6605 International +44 20 7848 6605
Email: roger.newson@kcl.ac.uk

Opinions expressed are those of the author, not the institution.

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