Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • return list in "ineqdeco" command (user-wrriten)

    Hi, I am suffering from a problem.
    I want get the results when I run "ineqdeco" command, but I can't.

    For example, when I run the code below,
    Code:
    sysuse auto
    ineqdeco mpg
    
    return list
    the result is
    Code:
    scalars:
                      r(N) =  0.
    (Of course, there is no problem in "ineqdeco mpg" command. I just omitted the calculation results for simplisity)

    In this case, how can I get the results?
    Thank you for your time spending to read this question.

  • #2
    Try typing

    ereturn list

    if this is an estimation command, this is where it saves results.

    Comment


    • #3
      Joro Kolev Thank you for response. But, I have already tried the "ereturn list" command. But, it does not work

      Comment


      • #4
        I installed the command, and I am not able to replicate your problem on Stata 15.1:

        Code:
        . sysuse auto
        (1978 Automobile Data)
        
        . ineqdeco mpg
         
        Percentile ratios
        
        ----------------------------------------------------------
          All obs |    p90/p10     p90/p50     p10/p50     p75/p25
        ----------+-----------------------------------------------
                  |      2.071       1.450       0.700       1.389
        ----------------------------------------------------------
          
        Generalized Entropy indices GE(a), where a = income difference
         sensitivity parameter, and Gini coefficient
        
        ----------------------------------------------------------------------
          All obs |     GE(-1)       GE(0)       GE(1)       GE(2)        Gini
        ----------+-----------------------------------------------------------
                  |    0.03449     0.03404     0.03465     0.03640     0.14717
        ----------------------------------------------------------------------
           
        Atkinson indices, A(e), where e > 0 is the inequality aversion parameter
        
        ----------------------------------------------
          All obs |     A(0.5)        A(1)        A(2)
        ----------+-----------------------------------
                  |    0.01703     0.03347     0.06452
        ----------------------------------------------
        
        . return list
        
        scalars:
                         r(a2) =  .0645209684845633
                         r(a1) =  .0334716177071454
                      r(ahalf) =  .0170342179260823
                        r(ge2) =  .0363994176608519
                        r(ge1) =  .0346528408807701
                        r(ge0) =  .0340446147092067
                       r(gem1) =  .034485523625282
                       r(gini) =  .1471738235697626
                     r(p75p50) =  1.25
                     r(p25p50) =  .9
                     r(p10p50) =  .7
                     r(p90p50) =  1.45
                     r(p75p25) =  1.388888888888889
                     r(p90p10) =  2.071428571428572
                        r(p95) =  34
                        r(p90) =  29
                        r(p75) =  25
                        r(p50) =  20
                        r(p25) =  18
                        r(p10) =  14
                         r(p5) =  14
                        r(max) =  41
                        r(min) =  12
                          r(N) =  74
                       r(sumw) =  74
                         r(sd) =  5.785503209735141
                        r(Var) =  33.47204738985561
                       r(mean) =  21.2972972972973
        
        .

        Comment


        • #5
          Joro Kolev I think, I have to try update my stata! Thank you for your effort!

          Comment


          • #6
            adoupdate ineqdeco, ssc update
            adoupdate ineqdec0, ssc update

            Comment


            • #7
              Stephen Jenkins Oh! Thank you! the command works now! I will try to update the command from next time on!

              Comment


              • #8
                HELLO
                i have income variable, id variable and year from 1985 to 2011. i would like to calculate the Gini coefficient by year
                i used the command
                ineqdeco income , by (year)
                gen gini=.
                replace gini=r(gini)
                the result display 1 Gini coefficient for all years. i was wondering i could get the Gini coefficients of each year stored in the data
                thanks

                Comment


                • #9
                  You get only one Gini because Stata uses the value from the last bygroup value. Try code analogous to this:
                  Code:
                  sysuse auto, clear
                  levelsof rep78, local(gp)
                  ge gini = .
                  foreach g of local gp {
                       display " "
                      display "*** rep78 = `g' ******
                      ineqdeco mpg if rep78 == `g'
                      replace gini = r(gini) if  rep78 == `g'
                  }
                  ta rep78, su(gini)    // check worked ok
                  "rep78" is analogous to your "year" variable, and "mpg" like your "income".

                  Welcome to Statalist. Please take a few minutes to read the Forum FAQ from top to bottom in order to learn how to post more effectively. E.g. please learn to use CODE delimiters. Also, it's a good idea to search the forum for previous posts on a topic. This one has come up lots of times. There are multiple ways of achieving the same result.

                  Comment


                  • #10
                    im trying to calcualte the gini coefficeint of the 4 incomes variables by years using sta 16 . here is the example of my data
                    Code:
                    * Example generated by -dataex-. To install: ssc install dataex
                    clear
                    input long IDENT byte PROV long(WAGSAL TOTERN TOTINC INCFTX) byte SEX float year
                    1 10  41840  41840  42631 31903 1 1988
                    1 10  40000  40000  40788 28448 1 1989
                    1 10  55000  55000  55786 38786 1 1990
                    1 10  41073  41073  42019 32387 2 1992
                    1 10  25724  25724  25814 20896 2 1993
                    1 10   6500   6500   7807  7807 2 1994
                    1 10   7034   7034   7243  6597 1 1995
                    1 10  20000  20000  20872 15872 2 1996
                    1 35   3200   3200   4300  4300 2 2000
                    1 59  49000  49000  49000 40650 1 2002
                    1 59  23000  23000  35925 32425 1 2005
                    1 35  34000  34000  34000 29000 2 2006
                    1 35  18000  18000  18300 16840 1 2007
                    1 35  80000  80000 101475 80355 2 2008
                    1 35  85000  85000  85000 70550 1 2009
                    2 10   1500   1500   5500  5475 1 1986
                    2 10  11653  11653  17842 15271 2 1989
                    2 10   8788   8788   8788  8184 2 1990
                    2 10   8000   8000   8514  8104 2 1991
                    2 10  33327  33327  33455 26455 2 1994
                    2 46  62500  62500  62825 49315 1 2002
                    2 35  35000  35000  35000 29920 1 2004
                    2 24  24000  24000  24000 21130 2 2006
                    2 10  12500  12500  29425 25735 1 2007
                    3 10   3172   3172   9406  8828 2 1986
                    3 10  36624  36624  36624 27215 1 1987
                    3 10  24000  24000  24000 19300 1 1989
                    3 10  72895  72895  72895 49815 1 1990
                    3 10  31471  31471  32257 27411 1 1991
                    3 10  15000  15000  17605 14105 2 1994
                    3 10  10379  10379  19105 16554 1 1995
                    3 10  35000  35000  35132 28020 1 1996
                    3 48  17500  17500  17825 16895 2 2004
                    3 13   2500   2500  10150 10150 1 2005
                    3 48  35000  35000  39775 37045 2 2006
                    3 35   5250   5250  42400 37080 2 2009
                    3 59  23000  23000  40650 39260 2 2010
                    4 10  34164  34164  39239 31261 2 1986
                    4 10   4885   4885   9287  8428 2 1987
                    4 10  10887  10887  12710 11213 2 1988
                    4 10  31000  31000  31386 24586 2 1989
                    4 10   8000   8000  16608 14106 1 1990
                    4 10  12111  12111  17662 15097 1 1991
                    4 10  44108  44108  46709 31209 1 1992
                    4 10  13468  13468  14537 12744 2 1993
                    4 10  31200  31200  31340 25530 1 1995
                    4 10  21660  21660  28918 25418 1 1996
                    4 24   9500   9500  11500 11480 2 1999
                    4 13   5750   5750   9000  9000 2 2000
                    4 35  41000  41000  41175 35985 2 2006
                    4 46    450    450  28200 13370 2 2011
                    5 10  16760  16760  21072 18432 1 1985
                    5 10  80000  80000  82112 57220 1 1990
                    5 10  37000  37000  37324 29374 2 1991
                    5 10  49504  49504  50131 37394 1 1993
                    5 10  41403  41403  41537 31087 1 1995
                    5 10  36435  36435  36547 28389 1 1996
                    5 35   7750   7750   7950  7950 2 2003
                    5 59  18000  18000  39125 29055 1 2004
                    5 46   3200   3200   9150  9150 1 2007
                    5 35  57500  57500  57725 53725 1 2008
                    6 10  29172  36963  37947 28149 1 1987
                    6 10  32552  34552  34552 26574 1 1988
                    6 10   6916   6916   7199  7199 2 1989
                    6 10   9386   9386  17233 14752 2 1990
                    6 10   4160   4160   9160  9160 1 1994
                    6 10   3600   3600   9688  9269 2 1995
                    6 10   1908   1908   4519  4519 2 1996
                    6 10  57530  57530  56232 43629 1 1997
                    6 12  11000  18000  18325 15715 1 1998
                    6 35  35000  35000  35000 28640 2 2000
                    6 24  65000  65000  65050 50800 2 2006
                    6 24   1100   1100   3050  3050 1 2008
                    6 35 120000 120000 122825 89605 2 2009
                    6 13   8750   8750  16575 16575 2 2010
                    7 10  33550  33550  33925 28513 2 1986
                    7 10   3808   3808   3908  3908 1 1990
                    7 10   1680   1680   3188  3188 2 1991
                    7 10  43004  43004  43004 32938 1 1994
                    7 10  15000  15000  15894 12694 2 1995
                    7 10   9000   9000  13000 11459 1 1996
                    7 10  17250  17250  29140 25460 1 1997
                    7 35  19000  19000  19250 16670 1 1998
                    7 35  18000  18000  24575 21475 1 2005
                    7 35   9000   9000  36750 33460 1 2007
                    7 24  22000  22000  22000 19480 2 2008
                    8 10   6692   6692   6937  6693 1 1987
                    8 10   3182   3182   9215  9215 1 1988
                    8 10  20488  20488  23374 19481 1 1989
                    8 10   3432   3432   8997  8997 1 1990
                    8 10  21950  21950  60506 49176 2 1991
                    8 10  14970  14970  14970 12758 2 1992
                    8 10  27778  27778  27778 22557 1 1995
                    8 10    752    752   5904  5904 2 1996
                    8 24   6500   6500   6500  6500 1 1998
                    8 12  13500  13500  13500 12100 2 1999
                    8 35  29000  29000  31950 29480 1 2000
                    8 48  18000  18000  18900 16920 2 2002
                    8 48  57500  57500  57500 48090 2 2007
                    9 10    600    600    600   600 1 1985
                    end
                    label values PROV GEOCODE
                    label def GEOCODE 10 "NEWFOUNDLAND", modify
                    label def GEOCODE 12 "NOVA SCOTIA", modify
                    label def GEOCODE 13 "NEW BRUNSWICK", modify
                    label def GEOCODE 24 "QUEBEC", modify
                    label def GEOCODE 35 "ONTARIO", modify
                    label def GEOCODE 46 "MANITOBA", modify
                    label def GEOCODE 48 "ALBERTA", modify
                    label def GEOCODE 59 "BRITISH COLUMBIA", modify
                    label values SEX SEX
                    label def SEX 1 "MALE", modify
                    label def SEX 2 "FEMALE", modify
                    here are the code i typed for calculate the ginicoeffient and store it on another file
                    Code:
                     tsset IDENT year
                    
                    quiet foreach var in WAGSAL TOTERN TOTINC INCFTX 
                    {
                    tempname f 
                    postfile `f' str20 varname time c_gini ///
                            using "tempresult_`var'.dta", replace every(1)
                    
                        gen F_`var'=(`var'>0) if `var'~=.
                    
                    levelsof year , local(gp)
                    
                    foreach g of local gp {
                                noisily di "gini: `var':`g'"
                                
                                local c_gini=.
                                capture ineqdec0 `var'  if `var'~=. & year==`g'
                                local c_gini=r(gini)
                        
                                post `f' ("`var'") (`g') (`c_gini') 
                        }
                    }
                        
                    postclose `f'
                    the result i get is:
                    Code:
                     tsset IDENT year
                           panel variable:  IDENT (unbalanced)
                            time variable:  year, 1985 to 2011, but with gaps
                                    delta:  1 unit
                    
                    . 
                    . quiet foreach var in WAGSAL TOTERN TOTINC INCFTX 
                    { required
                    r(100);
                    
                    end of do-file
                    
                    r(100);
                    can anyone tell me what to change for the code to work?

                    Comment


                    • #11
                      the Stata error message tells you - the curly brace needs to be on the same line as the -foreach-; I did not examine the rest of your code

                      Comment


                      • #12
                        *-----------------------------------------*
                        *cap6-gini-simple - Gasparini et al - 2013 - Pobreza y desigualdad en América Latina conceptos. pg. 438
                        summ ipcm [iw=facpob] if ipcm>0
                        return list
                        *poblacion de referencia
                        local obs = `r(sum_w)'
                        *media ingreso
                        local media=`r(mean)'
                        sort ipcm
                        gen aux =sum(facpob) if facpob>0
                        gen i=(2*aux-facpob+1)/2
                        gen aux2=ipcm*(`obs'-i+1)
                        summ aux2 [iw=facpob]
                        local gini = 1 + (1/`obs') -(2/(`media'*`obs'^2))*`r(sum)'
                        display "gini = `gini'"
                        *-----------------------------------------*

                        Comment

                        Working...
                        X