Announcement

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

  • Concentration (using GINI coefficient)

    Dear all,

    I am trying to estimate indices of industrial concentration within manufacturing industries (isic) across countries. One of the coefficients, I am trying to estimate is the Gini coefficient by doing the command below in the data. However, for some reason, my original sample size (around 158000 observations) gets reduced to around 128,000. Any hint about how could I do it more efficiently?

    Code:
     * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int(country year) double HHI float total_output_per_worker str2 isic float l_output_per_worker str3 isiccomb byte sourcecode long(Establishments Employment) double(Wages OutputINDSTAT4 ValueAdded GrossFixed)
    4 1973 0         0 "15"         . "15" 3   .  4321       .        . . .
    4 1974 0         0 "15"         . "15" 3   .  4845       .        . . .
    4 1975 0         0 "15"         . "15" 3   .  5103       .        . . .
    4 1976 0         0 "15"         . "15" 3   .  4540       .        . . .
    4 1977 0         0 "15"         . "15" 3   .  6309       .        . . .
    4 1978 0         0 "15"         . "15" 3   .  6413       .        . . .
    4 1979 0         0 "15"         . "15" 3   .  6006       .        . . .
    4 1980 0         0 "15"         . "15" 3   .  5672       .        . . .
    4 1981 0         0 "15"         . "15" 3   .  8481       .        . . .
    4 1982 0         0 "15"         . "15" 3  69  6866       .        . . .
    4 1983 0         0 "15"         . "15" 3  22  5080       .        . . .
    4 1984 0         0 "15"         . "15" 3  22  5187       .        . . .
    4 1985 0         0 "15"         . "15" 3  26  5446       .        . . .
    4 1986 0         0 "15"         . "15" 3  30  5556       .        . . .
    4 1987 0         0 "15"         . "15" 3  48  6177       .        . . .
    4 1988 0         0 "15"         . "15" 3  48  5950       .        . . .
    4 1990 0         0 "15"         . "15" 3   .     .       .        . . .
    4 1991 0         0 "15"         . "15" 3   .     .       .        . . .
    4 1998 0         0 "15"         . "15" 0   .     .       .        . . .
    4 1999 0         0 "15"         . "15" 0   .     .       .        . . .
    4 2001 0         0 "15"         . "15" 0   .     .       .        . . .
    4 2002 0 10217.693 "15"  8.747895 "15" 3  57  1398 1416229  8803794 . .
    4 2003 0 10445.018 "15"  7.318273 "15" 3  68  1986 1857237  2994088 . .
    4 2004 0   20834.7 "15"  8.145588 "15" 3  60  2170 2177016  7482447 . .
    4 2005 0  46658.26 "15"  8.626478 "15" 3 152  4376 4461093 24406704 . .
    4 2006 0 37563.043 "15"  8.591387 "15" 3 199  5278 5400385 28422446 . .
    4 2007 0  46911.16 "15"  8.826547 "15" 3 206  5300 6110242 36107429 . .
    4 2008 0  45425.82 "15"  8.789159 "15" 3 212  5431 6415492 35642064 . .
    4 2009 0  47342.36 "15" 9.0298605 "15" 3 199  5400 6824441 45082961 . .
    4 2010 0  56009.59 "15"  9.015374 "15" 3 195  4893 6952011 40262668 . .
    4 2011 0  57938.96 "15"  9.184711 "15" 3 197  4901 7171111 47769902 . .
    4 2012 0  55109.59 "15"  9.215193 "15" 3 192  4790 6604296 48133005 . .
    4 2013 0  51003.87 "15"  9.107686 "15" 3 189  4368 5679202 39418536 . .
    4 2014 0         0 "15"         . "15" 3   .     .       .        . . .
    4 2015 0         0 "15"         . "15" 5   .     .       . 37204964 . .
    4 2016 0         0 "15"         . "15" 3   .     .       .        . . .
    4 2017 0         0 "15"         . "15" 3   .     .       .        . . .
    4 2018 0         0 "15"         . "15" 3   .     .       . 45838668 . .
    4 2019 0         0 "15"         . "15" 3   .     .       . 64888180 . .
    4 1973 0         0 "16"         . "16" 3   .     0       .        . . .
    4 1974 0         0 "16"         . "16" 3   .     0       .        . . .
    4 1975 0         0 "16"         . "16" 3   .     0       .        . . .
    4 1976 0         0 "16"         . "16" 3   .     0       .        . . .
    4 1977 0         0 "16"         . "16" 3   .     0       .        . . .
    4 1978 0         0 "16"         . "16" 3   .     0       .        . . .
    4 1979 0         0 "16"         . "16" 3   .     0       .        . . .
    4 1980 0         0 "16"         . "16" 3   .     0       .        . . .
    4 1981 0         0 "16"         . "16" 3   0     0       .        . . .
    4 1982 0         0 "16"         . "16" 3   0     0       .        . . .
    4 1983 0         0 "16"         . "16" 3   0     0       .        . . .
    4 1984 0         0 "16"         . "16" 3   0     0       .        . . .
    4 1985 0         0 "16"         . "16" 3   0     0       .        . . .
    4 1986 0         0 "16"         . "16" 3   0     0       .        . . .
    4 1987 0         0 "16"         . "16" 3   0     0       .        . . .
    4 1988 0         0 "16"         . "16" 3   0     0       .        . . .
    4 1990 0         0 "16"         . "16" 3   .     .       .        . . .
    4 1991 0         0 "16"         . "16" 3   .     .       .        . . .
    4 1998 0         0 "16"         . "16" 0   .     .       .        . . .
    4 1999 0         0 "16"         . "16" 0   .     .       .        . . .
    4 2001 0         0 "16"         . "16" 0   .     .       .        . . .
    4 2002 0 10217.693 "16"         . "16" 0   .     .       .        . . .
    4 2003 0 10445.018 "16"         . "16" 0   .     .       .        . . .
    4 2004 0   20834.7 "16"         . "16" 0   .     .       .        . . .
    4 2005 0  46658.26 "16"         . "16" 0   .     .       .        . . .
    4 2006 0 37563.043 "16"         . "16" 0   .     .       .        . . .
    4 2007 0  46911.16 "16"         . "16" 0   .     .       .        . . .
    4 2008 0  45425.82 "16"         . "16" 0   .     .       .        . . .
    4 2009 0  47342.36 "16"         . "16" 0   .     .       .        . . .
    4 2010 0  56009.59 "16"         . "16" 0   .     .       .        . . .
    4 2011 0  57938.96 "16"         . "16" 0   .     .       .        . . .
    4 2012 0  55109.59 "16"         . "16" 0   .     .       .        . . .
    4 2013 0  51003.87 "16"         . "16" 0   .     .       .        . . .
    4 2014 0         0 "16"         . "16" 0   .     .       .        . . .
    4 2015 0         0 "16"         . "16" 0   .     .       .        . . .
    4 2016 0         0 "16"         . "16" 3   .     .       .        . . .
    4 2017 0         0 "16"         . "16" 3   .     .       .        . . .
    4 2018 0         0 "16"         . "16" 3   .     .       .    90174 . .
    4 2019 0         0 "16"         . "16" 3   .     .       .   125441 . .
    4 1973 0         0 "17"         . "17" 3   . 12555       .        . . .
    4 1974 0         0 "17"         . "17" 3   . 14243       .        . . .
    4 1975 0         0 "17"         . "17" 3   . 17202       .        . . .
    4 1976 0         0 "17"         . "17" 3   . 20520       .        . . .
    4 1977 0         0 "17"         . "17" 3   . 20540       .        . . .
    4 1978 0         0 "17"         . "17" 3   . 22889       .        . . .
    4 1979 0         0 "17"         . "17" 3   . 23733       .        . . .
    4 1980 0         0 "17"         . "17" 3   . 20438       .        . . .
    4 1981 0         0 "17"         . "17" 3  56 15068       .        . . .
    4 1982 0         0 "17"         . "17" 3  63 13387       .        . . .
    4 1983 0         0 "17"         . "17" 3  73 10067       .        . . .
    4 1984 0         0 "17"         . "17" 3  75 10208       .        . . .
    4 1985 0         0 "17"         . "17" 3  78 10468       .        . . .
    4 1986 0         0 "17"         . "17" 3  59 11716       .        . . .
    4 1987 0         0 "17"         . "17" 3  71 12060       .        . . .
    4 1988 0         0 "17"         . "17" 3  72 11497       .        . . .
    4 1990 0         0 "17"         . "17" 3   .     .       .        . . .
    4 1991 0         0 "17"         . "17" 3   .     .       .        . . .
    4 1998 0         0 "17"         . "17" 0   .     .       .        . . .
    4 1999 0         0 "17"         . "17" 0   .     .       .        . . .
    4 2001 0         0 "17"         . "17" 0   .     .       .        . . .
    4 2002 0 10217.693 "17"  7.574063 "17" 3  11   830  937303  1616039 . .
    end

    //Command to calculate Gini coefficient//

    gen gini = .
    qui ineqdeco OutputINDSTAT4
    replace gini = r(gini)
    end
    runby do_it, by(country year) verbose

  • #2
    You have missing values for OutputINDSTAT4; they will be omitted from the calculation of the gini coefficient.
    Code:
    count if !missing(OutputINDSTAT4)
    will tell you how many observations have non-missing values.

    Comment


    • #3
      Originally posted by William Lisowski View Post
      You have missing values for OutputINDSTAT4; they will be omitted from the calculation of the gini coefficient.
      Code:
      count if !missing(OutputINDSTAT4)
      will tell you how many observations have non-missing values.
      Thank you! That's what I suspected. Other than that, is the way I am calculating Gini coefficients correct? Any alternative way?

      Comment


      • #4
        The code you use will calculate Gini coefficients separately for each group of observations identified by the same year and country. In that sense it is correct.

        Whether that is a correct approach to the analysis of your data within the context of assessing an index of industrial concentration is beyond my knowledge and experience to evaluate.

        Comment


        • #5
          Thank you!

          Comment


          • #6
            E no caso de salvar os coeficientes do Gini?

            egen gini_grupo = group(f_setor municipio)
            ineqdeco remmedia, bygroup(gini_grupo)

            g gini = 0 + r(gini_k)


            Estou tentando armazenar os valores em uma variavel, porem, apenas cria-se missings

            Comment

            Working...
            X