Announcement

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

  • Gini coefficient

    Hello
    How do I calculate the Gini coefficient with the equivalent scale method using these data for Iranian provinces?
    Thank you for your help
    copy starting from the next line -----------------------
    [CODE]
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str10 FamilyCode str2 provincecode byte Familysize long Householdcost byte(Numberadults Numberchildren)
    "1000001172" "00" 4 78334098 4 0
    "1000001177" "00" 6 124493597 6 0
    "1000001180" "00" 4 115916220 3 1
    "1000001181" "00" 4 63545000 3 1
    "1000001184" "00" 4 103888600 2 2
    "1000002116" "00" 4 115661600 2 2
    "1000002119" "00" 5 156830000 2 3
    "1000002124" "00" 4 994439280 4 0
    "1000002127" "00" 2 150594000 2 0
    "1000002130" "00" 5 146479600 4 1
    "1000003143" "00" 5 121195000 4 1
    "1000003145" "00" 1 42448000 1 0
    "1000003150" "00" 2 101412000 2 0
    "1000003153" "00" 2 96551000 1 1
    "1000003156" "00" 2 61212000 2 0
    "1000004005" "00" 3 131909000 2 1
    "1000004009" "00" 4 107020000 3 1
    "1000004010" "00" 1 40432000 1 0
    "1000004014" "00" 2 37930000 2 0
    "1000004016" "00" 5 191457000 2 3
    "1000005098" "00" 2 108519943 2 0
    "1000005101" "00" 2 160819200 2 0
    "1000005106" "00" 1 21633000 1 0
    "1000005109" "00" 4 94584517 3 1
    "1000005112" "00" 4 33786952 4 0
    "1000006006" "00" 4 183120000 2 2
    "1000006007" "00" 3 114319000 3 0
    "1000006010" "00" 2 227814000 2 0
    "1000006013" "00" 4 251007000 4 0
    "1000006018" "00" 2 294332000 2 0
    "1000007005" "00" 4 238293000 4 0
    "1000007009" "00" 2 74866000 2 0
    "1000007010" "00" 3 206883500 2 1
    "1000007013" "00" 4 168588000 4 0
    "1000007018" "00" 4 361011000 2 2
    "1000008155" "00" 4 334840000 3 1
    "1000008159" "00" 1 67788000 1 0
    "1000008162" "00" 3 151027000 2 1
    "1000008165" "00" 4 126243000 4 0
    "1000008168" "00" 1 89873360 1 0
    "1000009004" "00" 4 95095000 3 1
    "1000009009" "00" 3 136062400 3 0
    "1000009010" "00" 2 105246510 2 0
    "1000009015" "00" 3 57519600 3 0
    "1000009016" "00" 5 145923778 5 0
    "1000010152" "00" 3 115182000 2 1
    "1000010156" "00" 3 178105000 2 1
    "1000010159" "00" 3 292254000 2 1
    "1000010162" "00" 5 240781000 4 1
    "1000010163" "00" 1 86730000 1 0

  • #2
    Please re-read the Forum FAQ.especially the sections about how to pose clear questions. Thank you for trying to use -dataex- but as you can see, you did not use it successfully. If you wish to get answers, I suggest that you re-post with the sample data properly formatted, an explanation of the relevant variables, and a better-posed question

    Comment


    • #3

      Hello
      These are household cost data in the provinces of Iran
      Family Code: represents the address of each household
      province code: represents the code of each province
      Family size: Indicates the size of each household or the number of people in each household
      Household cost: Indicates the cost of each household that is used instead of household income
      Number children: The number of children per household
      Number adults: Indicates the number of adults in each household
      I use this information to calculate the Gini coefficient for the provinces of Iran
      Of course, I want to get per capita income with the equivalent scale method
      Thank you for guidance on how to calculate the Gini coefficient
      .................................................. .................................................. ..............................

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input str10 FamilyCode str2 provincecode byte Familysize long Householdcost byte(Numberadults Numberchildren)
      "1000001172" "00" 4  78334098 4 0
      "1000001177" "00" 6 124493597 6 0
      "1000001180" "00" 4 115916220 3 1
      "1000001181" "00" 4  63545000 3 1
      "1000001184" "00" 4 103888600 2 2
      "1000002116" "00" 4 115661600 2 2
      "1000002119" "00" 5 156830000 2 3
      "1000002124" "00" 4 994439280 4 0
      "1000002127" "00" 2 150594000 2 0
      "1000002130" "00" 5 146479600 4 1
      "1000003143" "00" 5 121195000 4 1
      "1000003145" "00" 1  42448000 1 0
      "1000003150" "00" 2 101412000 2 0
      "1000003153" "00" 2  96551000 1 1
      "1000003156" "00" 2  61212000 2 0
      "1000004005" "00" 3 131909000 2 1
      "1000004009" "00" 4 107020000 3 1
      "1000004010" "00" 1  40432000 1 0
      "1000004014" "00" 2  37930000 2 0
      "1000004016" "00" 5 191457000 2 3
      end

      Comment


      • #4
        Hello
        Please guide me
        I can calculate with Excel, but the size of the data is very high and it takes a lot of time
        Unfortunately, I'm not really dominant and I do not know what instructions I need to enter to calculate the Gini coefficient and per capita income.
        Thank you for your advice

        Comment


        • #5
          Code:
          
          . clear all
          
          . input str10 FamilyCode str2 provincecode byte Familysize long Householdcost byte(Numberadults Numberchildren)
          
               FamilyCode  provinc~e  Famil~ze  Householdc~t  Number~s  Number~n
            1. "1000001172" "00" 4  78334098 4 0
            2. "1000001177" "00" 6 124493597 6 0
            3. "1000001180" "00" 4 115916220 3 1
            4. "1000001181" "00" 4  63545000 3 1
            5. "1000001184" "00" 4 103888600 2 2
            6. "1000002116" "00" 4 115661600 2 2
            7. "1000002119" "00" 5 156830000 2 3
            8. "1000002124" "00" 4 994439280 4 0
            9. "1000002127" "00" 2 150594000 2 0
           10. "1000002130" "00" 5 146479600 4 1
           11. "1000003143" "00" 5 121195000 4 1
           12. "1000003145" "00" 1  42448000 1 0
           13. "1000003150" "00" 2 101412000 2 0
           14. "1000003153" "00" 2  96551000 1 1
           15. "1000003156" "00" 2  61212000 2 0
           16. "1000004005" "00" 3 131909000 2 1
           17. "1000004009" "00" 4 107020000 3 1
           18. "1000004010" "00" 1  40432000 1 0
           19. "1000004014" "00" 2  37930000 2 0
           20. "1000004016" "00" 5 191457000 2 3
           21. end
          
          . 
          . ge exp_pc = Householdcost/Familysize
          
          . label var exp_pc "HH expenditure per capita"
          
          . 
          . ge exp_oecd = Householdcost/(1 + 0.6*Numberadults + 0.3*Numberchildren)
          
          . label var exp_oecd "HH expenditure, equivalised with modified-OECD scale"
          
          . 
          . ineqdeco exp_pc
           
          Percentile ratios
          
          ----------------------------------------------------------
            All obs |    p90/p10     p90/p50     p10/p50     p75/p25
          ----------+-----------------------------------------------
                    |      3.269       2.103       0.644       1.721
          ----------------------------------------------------------
            
          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.22786     0.24779     0.33735     0.60090     0.37783
          ----------------------------------------------------------------------
             
          Atkinson indices, A(e), where e > 0 is the inequality aversion parameter
          
          ----------------------------------------------
            All obs |     A(0.5)        A(1)        A(2)
          ----------+-----------------------------------
                    |    0.13518     0.21948     0.31305
          ----------------------------------------------
          
          . ineqdeco exp_oecd
           
          Percentile ratios
          
          ----------------------------------------------------------
            All obs |    p90/p10     p90/p50     p10/p50     p75/p25
          ----------+-----------------------------------------------
                    |      2.991       1.748       0.584       1.892
          ----------------------------------------------------------
            
          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.23110     0.25111     0.34679     0.63514     0.37746
          ----------------------------------------------------------------------
             
          Atkinson indices, A(e), where e > 0 is the inequality aversion parameter
          
          ----------------------------------------------
            All obs |     A(0.5)        A(1)        A(2)
          ----------+-----------------------------------
                    |    0.13762     0.22206     0.31610
          ----------------------------------------------
          
          . 
          end of do-file

          Comment


          • #6
            Dear Professor Stephen Jenkins

            Thank you very much

            Comment


            • #7
              PS typo alert: the generation of "exp_oecd" should use (Numberadults-1) in the calculation rather than Numberadults. Your data set (household budget survey?) probably has sample weights supplied; in which case you should use them with -ineqdeco-

              Comment


              • #8
                Another possibility (if Fereshte wants Gini coefficients with confidence limits) might be to use the SSC package scsomersd, which requires the SSC packages somersd and expgen in order to work. The online help for scsomersd contains an example of the calculation of a Gini index, with confidence limits.
                I hope this helps.
                Best wishes
                Roger

                Comment


                • #9
                  There are many ways to skin a cat (as the weird English phrase goes). For another package providing estimates of the Gini, with SEs (and CIs), also with svy capability, see svylorenz on SSC

                  Try this

                  Code:
                  clear all
                  
                  input str10 FamilyCode str2 provincecode byte Familysize long Householdcost byte(Numberadults Numberchildren)
                  
                  "1000001172" "00" 4  78334098 4 0
                  "1000001177" "00" 6 124493597 6 0
                  "1000001180" "00" 4 115916220 3 1
                  "1000001181" "00" 4  63545000 3 1
                  "1000001184" "00" 4 103888600 2 2
                  "1000002116" "00" 4 115661600 2 2
                  "1000002119" "00" 5 156830000 2 3
                  "1000002124" "00" 4 994439280 4 0
                  "1000002127" "00" 2 150594000 2 0
                  "1000002130" "00" 5 146479600 4 1
                  "1000003143" "00" 5 121195000 4 1
                  "1000003145" "00" 1  42448000 1 0
                  "1000003150" "00" 2 101412000 2 0
                  "1000003153" "00" 2  96551000 1 1
                  "1000003156" "00" 2  61212000 2 0
                  "1000004005" "00" 3 131909000 2 1
                  "1000004009" "00" 4 107020000 3 1
                  "1000004010" "00" 1  40432000 1 0
                  "1000004014" "00" 2  37930000 2 0
                  "1000004016" "00" 5 191457000 2 3
                  end
                  
                  ge exp_pc = Householdcost/Familysize
                  label var exp_pc "HH expenditure per capita"
                  ge exp_oecd = Householdcost/(1 + 0.6*(Numberadults-1) + 0.3*Numberchildren)
                  label var exp_oecd "HH expenditure, equivalised with modified-OECD scale"
                   
                  ineqdeco exp_pc
                  ineqdeco exp_oecd
                  
                  svyset, srs // modify this if you have survey design information
                  
                  svylorenz exp_pc, ngp(2)  // set # groups to 2 in order to reduce amount of output shown
                  svylorenz exp_oecd, ngp(2)
                  producing

                  Code:
                  . clear all
                  
                  . 
                  . input str10 FamilyCode str2 provincecode byte Familysize long Householdcost byte(Numberadults Numberchildren)
                  
                       FamilyCode  provinc~e  Famil~ze  Householdc~t  Number~s  Number~n
                    1. 
                  . "1000001172" "00" 4  78334098 4 0
                    2. "1000001177" "00" 6 124493597 6 0
                    3. "1000001180" "00" 4 115916220 3 1
                    4. "1000001181" "00" 4  63545000 3 1
                    5. "1000001184" "00" 4 103888600 2 2
                    6. "1000002116" "00" 4 115661600 2 2
                    7. "1000002119" "00" 5 156830000 2 3
                    8. "1000002124" "00" 4 994439280 4 0
                    9. "1000002127" "00" 2 150594000 2 0
                   10. "1000002130" "00" 5 146479600 4 1
                   11. "1000003143" "00" 5 121195000 4 1
                   12. "1000003145" "00" 1  42448000 1 0
                   13. "1000003150" "00" 2 101412000 2 0
                   14. "1000003153" "00" 2  96551000 1 1
                   15. "1000003156" "00" 2  61212000 2 0
                   16. "1000004005" "00" 3 131909000 2 1
                   17. "1000004009" "00" 4 107020000 3 1
                   18. "1000004010" "00" 1  40432000 1 0
                   19. "1000004014" "00" 2  37930000 2 0
                   20. "1000004016" "00" 5 191457000 2 3
                   21. end
                  
                  . 
                  . ge exp_pc = Householdcost/Familysize
                  
                  . label var exp_pc "HH expenditure per capita"
                  
                  . ge exp_oecd = Householdcost/(1 + 0.6*(Numberadults-1) + 0.3*Numberchildren)
                  
                  . label var exp_oecd "HH expenditure, equivalised with modified-OECD scale"
                  
                  .  
                  . ineqdeco exp_pc
                   
                  Percentile ratios
                  
                  ----------------------------------------------------------
                    All obs |    p90/p10     p90/p50     p10/p50     p75/p25
                  ----------+-----------------------------------------------
                            |      3.269       2.103       0.644       1.721
                  ----------------------------------------------------------
                    
                  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.22786     0.24779     0.33735     0.60090     0.37783
                  ----------------------------------------------------------------------
                     
                  Atkinson indices, A(e), where e > 0 is the inequality aversion parameter
                  
                  ----------------------------------------------
                    All obs |     A(0.5)        A(1)        A(2)
                  ----------+-----------------------------------
                            |    0.13518     0.21948     0.31305
                  ----------------------------------------------
                  
                  . ineqdeco exp_oecd
                   
                  Percentile ratios
                  
                  ----------------------------------------------------------
                    All obs |    p90/p10     p90/p50     p10/p50     p75/p25
                  ----------+-----------------------------------------------
                            |      3.197       1.824       0.571       1.717
                  ----------------------------------------------------------
                    
                  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.21809     0.23535     0.31857     0.56301     0.36674
                  ----------------------------------------------------------------------
                     
                  Atkinson indices, A(e), where e > 0 is the inequality aversion parameter
                  
                  ----------------------------------------------
                    All obs |     A(0.5)        A(1)        A(2)
                  ----------+-----------------------------------
                            |    0.12827     0.20970     0.30371
                  ----------------------------------------------
                  
                  . 
                  . svyset, srs // modify this if you have survey design information
                  
                        pweight: <none>
                            VCE: linearized
                    Single unit: missing
                       Strata 1: <one>
                           SU 1: <observations>
                          FPC 1: <zero>
                  
                  . 
                  . svylorenz exp_pc, ngp(2)  // set # groups to reduce amount of output shown
                  
                  
                  Quantile group shares, cumulative shares (Lorenz ordinates), 
                  generalized Lorenz ordinates, and Gini
                   
                  Number of strata =          1               Number of obs    =           20
                  Number of PSUs   =         20               Population size  =        20.00
                                                              Design df        =           19
                   
                  ---------------------------------------------------------------------------
                    Group  |             Linearized
                    share  |   Estimate   Std. Err.     z      P>|z|     [95% Conf. Interval]
                  ---------+-----------------------------------------------------------------
                      1    |   0.269121   0.064130    4.196    0.000       .143428    .394813
                      2    |   0.730879   0.064130   11.397    0.000       .605187    .856572
                  ---------+-----------------------------------------------------------------
                    Cumul. |
                    share  |
                      1    |   0.269121   0.064130    4.196    0.000       .143428    .394813
                      2    |   1.000000
                  ---------+-----------------------------------------------------------------
                    Gen.   |
                    Lorenz |
                      1    |  1.197e+07   9.65e+05   12.407    0.000     1.008e+07  1.386e+07
                      2    |  4.447e+07   1.12e+07    3.976    0.000     2.255e+07  6.639e+07
                  ---------+-----------------------------------------------------------------
                    Gini   |  0.3778348  .10148273    3.723    0.000      .1789323   .5767373
                  ---------------------------------------------------------------------------
                  
                  . svylorenz exp_oecd, ngp(2)
                  
                  
                  Quantile group shares, cumulative shares (Lorenz ordinates), 
                  generalized Lorenz ordinates, and Gini
                   
                  Number of strata =          1               Number of obs    =           20
                  Number of PSUs   =         20               Population size  =        20.00
                                                              Design df        =           19
                   
                  ---------------------------------------------------------------------------
                    Group  |             Linearized
                    share  |   Estimate   Std. Err.     z      P>|z|     [95% Conf. Interval]
                  ---------+-----------------------------------------------------------------
                      1    |   0.275027   0.062715    4.385    0.000       .152109    .397945
                      2    |   0.724973   0.062715   11.560    0.000       .602055    .847891
                  ---------+-----------------------------------------------------------------
                    Cumul. |
                    share  |
                      1    |   0.275027   0.062715    4.385    0.000       .152109    .397945
                      2    |   1.000000
                  ---------+-----------------------------------------------------------------
                    Gen.   |
                    Lorenz |
                      1    |  1.788e+07   1.73e+06   10.312    0.000     1.448e+07  2.128e+07
                      2    |  6.502e+07   1.58e+07    4.108    0.000     3.400e+07  9.604e+07
                  ---------+-----------------------------------------------------------------
                    Gini   |  0.3667425  .10161267    3.609    0.000      .1675853   .5658997
                  ---------------------------------------------------------------------------

                  Comment


                  • #10
                    Hello
                    Dear professors Roger Newson and Stephen Jenkins
                    Thank you very much

                    Professor Stephen Jenkins
                    I'm sorry for taking your time a lot
                    I use household budget survey data that has the following weights
                    I did not know that these weights are needed for calculation

                    I don't understand your response from the "svyset, srs // modify this if you have survey design information"
                    I have no problem till this part , but it gives me an error from this stage.
                    svyset, srs // modify this if you have survey design information
                    option / not allowed
                    r(198);

                    These are the previous data with each family's weight

                    Code:
                    * Example generated by -dataex-. To install: ssc install dataex
                    clear
                    input str10 FamilyCode str2 province byte Familysize long Householdcost byte(Numberadults Numberchildren) double weight
                    "1000001172" "00" 4  78334098 4 0 730.040555625913
                    "1000001177" "00" 6 124493597 6 0 730.040555625913
                    "1000001180" "00" 4 115916220 3 1 730.040555625913
                    "1000001181" "00" 4  63545000 3 1 730.040555625913
                    "1000001184" "00" 4 103888600 2 2 730.040555625913
                    "1000002116" "00" 4 115661600 2 2 563.627484410407
                    "1000002119" "00" 5 156830000 2 3 563.627484410407
                    "1000002124" "00" 4 994439280 4 0 563.627484410407
                    "1000002127" "00" 2 150594000 2 0 563.627484410407
                    "1000002130" "00" 5 146479600 4 1 563.627484410407
                    "1000003143" "00" 5 121195000 4 1 365.020277812956
                    "1000003145" "00" 1  42448000 1 0 365.020277812956
                    "1000003150" "00" 2 101412000 2 0 365.020277812956
                    "1000003153" "00" 2  96551000 1 1 365.020277812956
                    "1000003156" "00" 2  61212000 2 0 365.020277812956
                    "1000004005" "00" 3 131909000 2 1 365.020277812956
                    "1000004009" "00" 4 107020000 3 1 365.020277812956
                    "1000004010" "00" 1  40432000 1 0 365.020277812956
                    "1000004014" "00" 2  37930000 2 0 365.020277812956
                    "1000004016" "00" 5 191457000 2 3 365.020277812956
                    end
                    Thank you for your help

                    Comment


                    • #11
                      Try the following. Ensure that you copy all of ithe text between the CODE delimiters into the do-file editor and run the whole file. [I suspect you were trying to run code interactively, line by line; if so, that could be the explanation for the error with the commenting "//" that you report

                      Code:
                      clear
                      input str10 FamilyCode str2 province byte Familysize long Householdcost byte(Numberadults Numberchildren) double weight 
                      "1000001172" "00" 4  78334098 4 0 730.040555625913
                      "1000001177" "00" 6 124493597 6 0 730.040555625913
                      "1000001180" "00" 4 115916220 3 1 730.040555625913
                      "1000001181" "00" 4  63545000 3 1 730.040555625913
                      "1000001184" "00" 4 103888600 2 2 730.040555625913
                      "1000002116" "00" 4 115661600 2 2 563.627484410407
                      "1000002119" "00" 5 156830000 2 3 563.627484410407
                      "1000002124" "00" 4 994439280 4 0 563.627484410407
                      "1000002127" "00" 2 150594000 2 0 563.627484410407
                      "1000002130" "00" 5 146479600 4 1 563.627484410407
                      "1000003143" "00" 5 121195000 4 1 365.020277812956
                      "1000003145" "00" 1  42448000 1 0 365.020277812956
                      "1000003150" "00" 2 101412000 2 0 365.020277812956
                      "1000003153" "00" 2  96551000 1 1 365.020277812956
                      "1000003156" "00" 2  61212000 2 0 365.020277812956
                      "1000004005" "00" 3 131909000 2 1 365.020277812956
                      "1000004009" "00" 4 107020000 3 1 365.020277812956
                      "1000004010" "00" 1  40432000 1 0 365.020277812956
                      "1000004014" "00" 2  37930000 2 0 365.020277812956
                      "1000004016" "00" 5 191457000 2 3 365.020277812956
                      end
                      
                      ge exp_pc = Householdcost/Familysize
                      label var exp_pc "HH expenditure per capita"
                      ge exp_oecd = Householdcost/(1 + 0.6*(Numberadults-1) + 0.3*Numberchildren)
                      label var exp_oecd "HH expenditure, equivalised with modified-OECD scale"
                      
                      ineqdeco exp_pc [w = weight]
                      ineqdeco exp_oecd [w = weight]
                      
                      svyset [pw = weight]
                      svylorenz exp_pc, ng(2)
                      svylorenz exp_oecd, ng(2)

                      Comment


                      • #12
                        Thank you very much

                        My problem is now resolved

                        I wish you good health

                        Comment


                        • #13
                          Hello
                          Excuse me, How can I calculate Till and Zenga indexes and Palma ratio(of top decile incomes and bottom 40% incomes) using these data and stata?

                          Comment


                          • #14
                            Hello
                            Please help me
                            I have to calculate these Index for 10 years and 31 provinces of Iran, which requires a lot of time with Excel and unfortunately I'm not dominant to stata .
                            Please help me if possible
                            Thank you

                            Comment


                            • #15
                              Till and Zenga indices are rare -- hardly used in most analyses. I also don't know of Stata programs (ado-files) that calculate them. Frankly, I would focus less on calculating a large number of arcane indices and more on information such as Lorenz curves. The Palma ratio is the ratio of (1) the share of total income held by the richest 10% (richest decile group) to (2) the share of total income held by the poorest 40%. You can get estimates of those income shares from my sumdist on SSC.
                              To repeat calculations, for each combination of year and province, I suggest you first create a new group variable using egen's group , and then use e.g. statsby to do all the by-group calculations.
                              Before posting again, I strongly recommend that you invest time in learning more Stata (e.g. read the User Manual U), and read in great detail the help-files for the commands cited. And do some calculations yourself to explore and understand.

                              Comment

                              Working...
                              X