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

Re: st: retaining results from -ineqdeco-


From   Jenkins S P <[email protected]>
To   [email protected]
Subject   Re: st: retaining results from -ineqdeco-
Date   Sat, 10 Jan 2004 18:42:00 +0000 (GMT)

On Sat, 10 Jan 2004, Radu Ban wrote:

> Dear listers,
>
> I need a bit of help with -ineqdeco- , the ado used
> for inequality measures and decomposition.
>
> I have a dataset that is organized like this (on a
> much larger scale)
... snip ...
> I want to run the -ineqdeco- separately for each
> village, with the decomposition
> being done by caste. And then I want to retain the
> results from -ineqdeco- in new
> variables. The variables that I want to create are:
>
> village_gini [= the gini for the village]
> caste_gini [=the gini for the caste in the village]
> village_within_a [= GE_W(a) for the village]
> village_between_a [= GE_B(a) for the village]
>
> I have tried looking for the saved results after a
> test decomposition for one village
> but I only found s(k) and s(varlist). Also, even if I
> restrict:
>
> ineqdeco hh_income if village == 1, by(caste)
>
> Stata still seems to look at all the villages because
> the maximum number of castes is
> displayed and the program takes much longer to run
> than if I keep only village 1, i.e.
>
> keep if village == 1
> ineqdeco hh_income, by(caste)

-ineqdeco- is a version 5 program, so saves results using global macros
that are referred to using "$" followed by a result identifier. The
identifiers are given in the help file. E.g. one refers to the Gini
coefficient as "$S_gini". These are for all the estimation sample, not for
each subgroup within the estimation sample. (The latter were not
programmed at the time, because their number was not predictable in
advance.)

You can get results of the sort you want quite easily using code similar
to the following (see FAQs at www.stata.com on related 'by group'
principles):

~~~~~~~~~~~
use  D:\Home\stephenj\MYProjects\STATAPRG\fit\ifs91new.dta, clear
ge vill = (region ==7)|(region==8)  // (Made-up variable) like village id
levels but, local(levels1)  // "but" is like caste
levels vill, local(levels2)
foreach v of local levels2 {
	ge vill`v'gini = .
	ineqdeco eybhc [aw=wgt] if vill == `v'  // "eybhc" is like income
	replace vill`v'gini = $S_gini
	foreach c of local levels1 {
		ge vill`v'_`c'gini = .
		ineqdeco eybhc [aw=wgt] if vill == `v' & but == `c'
		replace vill`v'_`c'gini = $S_gini
	}
}
egen tag = tag(vill but)
sort vill but
list vill but vill*gini if tag
~~~~~~~~~~~

This code puts the Gini estimates into new variables, and you can identify
which is which by name, and write them out to a separate file, or ...
whatever. Here the "vill" variable has 2 levels and "but" has 5, so the
-list- command will produce 10 lines of output.

Your original message appeared to ask for the Within-Group Gini and the
Between-Group Gini. Be aware that these are not well-defined concepts for
the Gini coefficient -- it is not subgroup-decomposable like members of
the Generalised Entropy family. (That is why the by() option of -ineqdeco-
and -ineqdec0- do not produce them.)

One day when I have time I will update these programs to a later version
of Stata, potentially adding some functionality where possible. But you
can do pretty much all that I can imagine that you might want to do
with the existing program

Good luck
Stephen Jenkins
(author of -ineqdeco-, -ineqdec0-, -povdeco-)


*
*   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