[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: RE: ineq & Herfendahl Index
Steven Fraser's problem can also be approached using standard
Stata commands (although I was interested to see a demonstration of -ineq-)
> Date: Thu, 13 Jun 2002 09:48:59 -0400
> From: "Fraser, Steven" <SFraser@coba.usf.edu>
> Subject: st: Tab and Matcell
> Dear Statalist:
> I am having a problem implementing matrix operations within the 'tab'
> command. Using a variation of the familiar car example, assume I have the
> following dataset:
> Manuf Model Class MPG
> ford explorer SUV 12
> ford expedition SUV 10
> ford focus compact 34
> dodge durango SUV 16
> gm tahoe SUV 15
> Assume I have hundreds of automobiles (cars, trucks, and SUVs).
> I am trying
> to develop a focus measure (a Herfandahl index) that captures the focus of
> the manufacturer.
bysort manuf class : gen i_2 = _N if _n == 1
replace i_2 = i^2
bysort manuf : gen n_2 = _N if _n == 1
replace n_2 = n^2
egen simpson = sum(i_2) , by(manuf)
replace simpson = simpson/n_2
li manuf simpson if simpson ~= .
by manuf : replace simpson = simpson
This longer approach has the (small) advantage over -ineq-
that the index is added to the existing data base, not to the collapsed
version, so can be compared at once with any other variables of interest.
Wolfson Institute of Preventive Medicine
London EC1M 6BQ
(020) (+44) 7882 6298
fax 7882 6270
* For searches and help try: