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

st: Final Tab and Matrix


From   "Fraser, Steven" <[email protected]>
To   "Statalist (E-mail)" <[email protected]>
Subject   st: Final Tab and Matrix
Date   Fri, 14 Jun 2002 10:48:45 -0400

Special thanks to N Cox, N Winter, and P Seed.  
In sum, the following three approaches are essentially equivalent:

N Cox (Version 1)

bysort manuf class: gen _freq= _N*(_n==1)
ineq _freq, by(manuf) gensim(focus)

N Cox (Version 2)

bysort manuf class: gen _freq=_N*(_n==1)
by manuf: gen _totfreq = _N
by manuf: gen focus = sum((_freq/_totfreq)^2)
by manuf: replace focus = focus[_N]

P Seed

bysort manuf class: gen i_2 = _N if _n==1
replace i_2 = i_2^2
bysort manuf: gen n_2=_N if _n==1
replace n_2 = n_2^2
egen simpson = sum(i_2), by(manuf)
replace simpson = simpson/n_2
li manuf simpson if simpson ~=.
by manuf: replace simpson = simpson[1]

I want to thank the statalist for the help.  For those who might not be
aware of how easy it is to update Stata so that many of the recommendations
from folks on the Statlist can be implemented, do not fear.  As suggested by
N. Winter, a simple 'update query' and follow directions takes care of it
all.  Thanks again!

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