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

st: More Tab and Matrix


From   "Fraser, Steven" <SFraser@coba.usf.edu>
To   "Statalist (E-mail)" <statalist@hsphsun2.harvard.edu>
Subject   st: More Tab and Matrix
Date   Thu, 13 Jun 2002 14:06:54 -0400

> 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
> 
> Steve Fraser
> Univ of South Florida
> 
*
*   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