[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Measure of Variability in a Nominal Variable

From   Maarten buis <>
Subject   Re: st: Measure of Variability in a Nominal Variable
Date   Mon, 3 Mar 2008 21:30:47 +0000 (GMT)

--- Kevin Daley <> wrote:
>    I would like to ask if anyone can identify and/or tell me how to
> run a certain descriptive statistic in Stata.  I am working with a
> nominal variable and would like to provide some indication of the
> variability within the sample along this variable.  I would like to
> use a statistic discussed by Agresti in his categorical data analysis
> book that gives the probability that two randomly selected
> independent observations in a given dataset will end up in different
> categories of the given variable.  The statistic has a minimum value
> of 0 and a maximum value of J-1.  Can anyone tell me what this
> descriptive statistic is called?  More importantly, can anyone tell
> me the order needed to run it in Stata? Thank you very much, Kevin. 

If it is a probability than the maximum is 1. In that case you could
compute it as follows:

*---------- begin example -------------
sysuse auto, clear
contract rep78 , percent(p) nomiss
gen double psq = (p/100)^2
sum psq, meanonly
di 1-r(sum)
*--------- end example -----------------
(For more on how to use examples I sent to the Statalist, see )

Given your description of the maximum I suspect this is not what you
are after. Maybe you are looking for the entropy?

Hope this helps,

Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

Sent from Yahoo! Mail.
A Smarter Inbox.
*   For searches and help try:

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