[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Optimizing an ineqdeco loop

From   "Victor Bennett" <>
Subject   st: Optimizing an ineqdeco loop
Date   Wed, 10 Dec 2008 13:28:27 -0800

Hi folks,
Does anyone have suggestions on how to speed up a loop that calculates
many many gini coefficients with ineqdeco?

I'm building a data set for doing some comparison of price variation
using Gini coefficients from ineqdeco.  Each observation is a sale of
an item at a particular store.  Each item can be sold at multiple
stores, and each store sells multiple items.

I would like to store the Gini for each store x product combination.
If egen did this, the easy way would be egen gini=gini(price),
by(store product).

The way I'm doing it right now is:

gen gini = .
levels storeid,local(stores)
foreach store of local stores {
	levels prodid if storeid==`store', local(prodInStore)
	foreach prod of local prodInStore {
  		ineqdeco price if prodid == `prod'&storeid==`store'
  		replace gini = $S_gini if prodid == `prod'&storeid==`store'

It seems like there is a way to do this with bygroup() on ineqdeco,
but I can't figure out how to extract and store the coefficients.
Also, its not clear that it would be any faster.  Would it?

Is there an alternate library that will calculate gini without
calculating the other dispersion measures?

Thanks for your help!
*   For searches and help try:

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