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

st: RE: More Tab and Matrix


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: More Tab and Matrix
Date   Thu, 13 Jun 2002 19:59:21 +0100

Fraser, Steven

> > Thx to M. Perticara and N. Cox.  I reviewed the -ineq- as suggested, and
> > as part time stata user, I might not have the background to adequately
> > understand what was implemented so I thought I would give it
> another try.
> > I am trying to calculate a focus index (I'm not sure the Simpson was the
> > same).  In any event, it is a simple measure.  If I assume a car
> > manufacture makes 3 cars in 3 separate classes, they would have a focus
> > measure of 1/3. (1^2 + 1^2 + 1^2)/3^2 = 3/9. On the other hand, if one
> > manufacturer makes 3 cars all in one class, the focus measure would be
> > (1+1+1)^2/3^2 = 9/9 or 1.00.
> >
> > If I drop all observations except for one manufacturer, the
> following code
> > works fine:
> >
> > /*  This sequence calculates the focus variables */
> > tab class, matcell(classmat)
> > mat nummat=catmat'*catmat
> > gen numerator=nummat[1,1]
> > gen denominator=(_N)^2
> > gen focus=numerator/denominator
> > list focus
> >
> > My problem is I have many 'manufacturers'.  When I try to implement this
> > code with the "by:" syntax, I continue to have difficulties.  I
> would like
> > to keep the data in this format/shape because I have generated several
> > other variables by 'manufacturer'.
> >
> > Any thoughts or suggestions are greatly appreciated.  Thx again - SF
> >

This looks like Simpson = Herfindahl to me, as said earlier.
Orris C. Herfindahl (1918-72) proposed the same index
as E.H. Simpson (b.1922). Simpson had really got the index from
codebreaker and pioneer computer scientist Alan Turing, but couldn't
say that without breaking national security. At least that is
the story told by I.J. Good, and it is a Good story. But Gini used
the same idea decades earlier. (This is the same Simpson for whom
Simpson's paradox is named, although it is really Yule's paradox.)

Anyway, that wasn't your question.

You don't show us your code, but I guess the key problem is
that the -matrix- command can't be
used under by: in the way that you want.

Let's suppose that your key variables are -manufacturer- and -class-.

Try two commands in succession (-save- your data if necessary):

contract manufacturer class, nomiss
ineq _freq, by(manufacturer) gensim(focus)

I think that is what you want.

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