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

st: Re: user ado/by prefix, inequality measures


From   Christopher Baum <[email protected]>
To   [email protected]
Subject   st: Re: user ado/by prefix, inequality measures
Date   Sun, 18 May 2003 09:56:58 -0400

On Sunday, May 18, 2003, at 02:33 AM, Taeho wrote:

I want to get "inequal" values such as coefficient of variation and Gini
coefficient for multiple units such as towns, cities, etc in a dataset
which has house selling prices over 1000 cities and towns.

Stata ado files don't allow "by" options. Please let me know the easiest
way to get the values for multiple units. I am a STATA bigger having
limited knowledge in programming.

Thanks
It is NOT true that user-written files do not allow by _prefixes_, which is the usual way to 'loop' a command over a by-group. I have taken the liberty of hacking Rich Goldstein's _rspread_ (a blast from the version 3.0 past, published in STB-23) to make it 'byable', in the Stata parlance (see [p] byable). I believe it calculates all the stats that are mentioned. It only prints out the results for each by-group (and having a byable routine generate new variables is slightly harder) but the easiest way to return a volume of stats such as this is in a Stata matrix (which can always be unwound into variables). I have not made that change yet. I have also disabled the graph option in my version.

I believe the routine is working properly (or at least replicating Rich's results, for the cases for which I have tried it). You can validate his against mine by running rspread with an 'if' clause, which should match the equivalent by-group. The new routine, rspread2, is written for Stata 7. Caveat executor; since Rich lives around the corner, perhaps we'll get together for a beer and clean this routine up, if there is interest in bringing it fully up to date.

To get the new ado-file,

copy http://fmwww.bc.edu/ec-p/baum/cert/rspread2.ado rspread2.ado

Also get the rspread package from ssc, since it contains some necessary auxiliary routines and the help file.

E.g.

. use http://fmwww.bc.edu/ec-p/data/hayashi/griliches76.dta

. bys s year: rspread2 lw

________________________________________________________________________ _______
-> s = 9, year = 66

Measures of Absolute and Relative Dispersion (or Inequality):

| Mean Dev. about Max.
variable| Mean Median MeanDif CV CD Gini SEMean % Dev.
-------- |---------------------------------------------------------------------
lw | .32 .32 .46 0.0752 0.0626 0.0443 .13 13.17%

________________________________________________________________________ _______
-> s = 9, year = 67

Measures of Absolute and Relative Dispersion (or Inequality):

| Mean Dev. about Max.
variable| Mean Median MeanDif CV CD Gini SEMean % Dev.
-------- |---------------------------------------------------------------------
lw | .32 .32 .63 0.0869 0.0614 0.0614 .32 6.14%

...

Thanks
Kit

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