Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# Re: st: How to code |x_i-x_j| in stata?

 From Stas Kolenikov <[email protected]> To "[email protected]" <[email protected]> Subject Re: st: How to code |x_i-x_j| in stata? Date Thu, 10 Oct 2013 08:39:02 -0500

```This seems like a standard definition of the Gini index to me, and
there's a huge number of different user-contributed modules to compute
this (that may differ in some small sample details like n*(n-1) in
place of your n^2). -findit inequality- to get the full list. I use
-ineqdec0- by Stephen Jenkins.

-- Stas Kolenikov, PhD, PStat (ASA, SSC)
-- Senior Survey Statistician, Abt SRBI
-- Opinions stated in this email are mine only, and do not reflect the
position of my employer
-- http://stas.kolenikov.name

On Wed, Oct 9, 2013 at 10:09 PM, LI Mengjia <[email protected]> wrote:
> Dear statalist,
>
> I'm trying to calculate a "locational Gini coefficient" (rg) by using the formula in a reference paper in the following:
>
> rg=(sum|x_i-x_j|)/(2*n^2*u)
>
> where n is the total number of industries in an area, i and j are just two industries in n industries, x is the market share of any industry, and u is the mean of x.
>
> I have not idea how to put x_i-x_j into stata.
>
> Thanks and best regards,
> Amy
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/
```