Announcement

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

  • Gini Coefficient

    Hi Statlist members,


    I want to calculate Gini coefficient and create variable called "gini" for each group of employees for each year



    G = 1 + (1/n) - [ 2 / n^2 . TCmean)] [ TC1 + 2 TC2 + .....nTCn)


    Where,
    n = number of employees each year

    TC = total compensation for each employee for each year , TC1
    , TC2 ...TCn is the compensation paid to each of the employees in decreasing
    order of size,

    TCmean = is their mean total compensation




    My data looks like,


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input double YEAR str8 firmID double TC str6 employee_ID float n
    2009 "00036020"  181.876 "36416" 5
    2009 "00036020"  359.117 "36415" 5
    2009 "00036020"  216.779 "36418" 5
    2009 "00036020"  220.486 "36417" 5
    2009 "00036020"  208.597 "36419" 5
    2010 "00036020"  289.613 "36418" 5
    2010 "00036020"  284.973 "36417" 5
    2010 "00036020"  369.796 "36415" 5
    2010 "00036020"   181.21 "36416" 5
    2010 "00036020"  277.519 "36419" 5
    2011 "00036020"   447.51 "36415" 4
    2011 "00036020"  182.568 "36416" 4
    2011 "00036020"  202.549 "36418" 4
    2011 "00036020"  188.492 "36417" 4
    2012 "00036020"  436.021 "36417" 6
    2012 "00036020"        . "47457" 6
    2012 "00036020"  496.209 "36419" 6
    2012 "00036020"  397.747 "36416" 6
    2012 "00036020"  990.066 "36415" 6
    2012 "00036020"  461.337 "36418" 6
    2013 "00036020"  440.407 "36417" 7
    2013 "00036020"  465.542 "36418" 7
    2013 "00036020" 1124.996 "36415" 7
    2013 "00036020"  440.649 "36419" 7
    2013 "00036020"        . "47457" 7
    2013 "00036020"        . "49230" 7
    2013 "00036020"  403.883 "36416" 7
    2014 "00036020"  712.042 "36417" 7
    2014 "00036020" 2358.784 "36415" 7
    2014 "00036020"  255.489 "36418" 7
    2014 "00036020"  576.187 "36416" 7
    2014 "00036020"  618.137 "47457" 7
    2014 "00036020"  727.938 "36419" 7
    2014 "00036020"        . "49230" 7
    2015 "00036020"        . "51051" 7
    2015 "00036020"        . "55068" 7
    2015 "00036020"  707.183 "36417" 7
    2015 "00036020"  708.011 "36419" 7
    2015 "00036020"  580.486 "36416" 7
    2015 "00036020"  579.174 "49230" 7
    2015 "00036020" 3505.532 "36415" 7
    2016 "00036020"  658.928 "36416" 8
    2016 "00036020"        . "47457" 8
    2016 "00036020"  891.171 "36419" 8
    2016 "00036020"  467.546 "51051" 8
    2016 "00036020"  697.613 "49230" 8
    2016 "00036020"   881.83 "36417" 8
    2016 "00036020" 4492.198 "36415" 8
    2016 "00036020"        . "55068" 8
    2017 "00036020"        . "58258" 9
    2017 "00036020"  424.985 "36416" 9
    2017 "00036020"  991.155 "49230" 9
    2017 "00036020" 1455.461 "51051" 9
    2017 "00036020"  4532.55 "36415" 9
    2017 "00036020"  881.621 "55068" 9
    2017 "00036020"  890.197 "36417" 9
    2017 "00036020" 1097.299 "36419" 9
    2017 "00036020"        . "47457" 9
    2018 "00036020"  984.931 "47457" 6
    2018 "00036020" 1283.692 "55068" 6
    2018 "00036020" 4320.379 "36415" 6
    2018 "00036020"        . "58258" 6
    2018 "00036020" 1392.604 "36419" 6
    2018 "00036020" 2196.599 "51051" 6
    2019 "00036020" 2036.539 "36419" 5
    2019 "00036020" 5382.645 "36415" 5
    2019 "00036020" 3227.718 "51051" 5
    2019 "00036020" 1591.217 "47457" 5
    2019 "00036020" 1620.309 "58258" 5
    2020 "00036020"        . "61481" 6
    2020 "00036020" 1036.374 "58258" 6
    2020 "00036020" 2387.673 "51051" 6
    2020 "00036020"  807.416 "47457" 6
    2020 "00036020" 2336.581 "36415" 6
    2020 "00036020"  961.326 "36419" 6
    2021 "00036020" 1086.224 "58258" 6
    2021 "00036020" 2912.109 "51051" 6
    2021 "00036020"  906.761 "47457" 6
    2021 "00036020" 1646.275 "36415" 6
    2021 "00036020"  913.071 "36419" 6
    2021 "00036020"  771.947 "61481" 6
    2009 "00036110" 3055.124 "09252" 5
    2009 "00036110" 1641.556 "36199" 5
    2009 "00036110" 6435.641 "09249" 5
    2009 "00036110" 1244.039 "23781" 5
    2009 "00036110" 1770.594 "33979" 5
    2010 "00036110" 1314.079 "36199" 5
    2010 "00036110" 1578.104 "33979" 5
    2010 "00036110" 5237.743 "09249" 5
    2010 "00036110" 1596.902 "41787" 5
    2010 "00036110" 2554.467 "09252" 5
    2011 "00036110" 1081.963 "36199" 5
    2011 "00036110" 2781.156 "09252" 5
    2011 "00036110" 1727.069 "41787" 5
    2011 "00036110"   5786.4 "09249" 5
    2011 "00036110" 1696.431 "33979" 5
    2012 "00036110" 1131.176 "44858" 5
    2012 "00036110"  841.204 "19999" 5
    2012 "00036110" 2068.554 "09252" 5
    2012 "00036110" 4182.832 "09249" 5
    end

    I tried many codes but ends with errors , and I used - ineqdeco - package but I do not how to apply it to my data

    Any suggestions ?

  • #2
    Code:
    . ineqdeco TC, by(YEAR)
    See also
    Code:
    . ineqdecgini TC, by(YEAR)  // -ssc d ineqdecgini-
    If this does not produce what you want, please be more precise

    Comment


    • #3
      Thanks professor for your response, but I need to generate a variable called "gini coefficient " for each group , precisely I want to follow Kale perspective , I attached a photo below from this article

      Kale, J.R., Reis, E. and Venkateswaran, A., 2009. Rankā€order tournaments and incentive alignment: The effect on firm performance. The Journal of Finance, 64(3), pp.1479-1512.

      Click image for larger version

Name:	Gini coefficient.PNG
Views:	1
Size:	47.8 KB
ID:	1707151


      Any help ?




      Comment


      • #4

        Stephen Jenkins is the expert here, but that formula is just one of several for the same beast. There isn't obviously a different perspective in what you cite: the formula and the code are indifferent to whether it is compensation of CEOs or any other positive quantities.

        A toy example with incomes 3, 2, 1 can be used to get the Gini coefficient by hand, which can then be checked using ineqdeco. In both cases I get 2/9 = 0.222 to 3 dp.
        Last edited by Nick Cox; 25 Mar 2023, 12:53.

        Comment


        • #5
          Shlomo Yitzhaki once wrote an article called "More Than a Dozen Alternative Ways of Spelling Gini". Spelling = calculating. In short: Nick Cox is right. (PS Donaldson and Weymark would be amused to see themselves described as macroeconomists.)

          #3:
          I need to generate a variable called "gini coefficient " for each group
          But you haven't told us how you define "group"! I guessed "YEAR". Define your group variable and proceed as suggested
          Last edited by Stephen Jenkins; 27 Mar 2023, 04:52.

          Comment


          • #6
            Many thanks Nick Cox and Stephen Jenkins , it works perfectly with me

            Comment

            Working...
            X