Announcement

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

  • Error in computing Gini coefficients with 0 as listed values

    Hi

    I am trying to write a code for calculating the gini coefficients. Here is the code.

    ginidesc income, by(regionid)

    I am getting error when there are lot of values with income=0. I get an error that

    Warning: income has 35 values = 0.Used in calculations
    no observations
    r(2000);

    When i drop the 0 i get a gini coefficient(.73). I used an online calculator and it was giving a different gini(after including 0 values)(.81).

    Can someone address this problem so that i can calculate gini with 0's included?

  • #2
    Originally posted by Veeresh Thummadi View Post
    ... I used an online calculator and it was giving a different gini(after including 0 values)(.81).

    Can someone address this problem so that i can calculate gini with 0's included?
    That might involve changing online calculator. What online calculator are you talking about? URL=?

    Sergiy

    Comment


    • #3
      Actually after reading more carefully I think zeroes are not a problem. The program issues this message as a warning only, and it states that it "Used in calculations" those zeroes. So if you drop them, you make your data different from what you supply to the online calculator.

      The problem is more likely for one of the regions. Make sure you have observations for each value of regionid. Perhaps start with computing the coefficient nationwide.

      Wikipedia page has an example of Gini coefficient computed that you can use as a benchmark to validate each calculator (in Stata and online) and a reference to another (or same??) online calculator.

      Best, Sergiy Radyakin

      Comment


      • #4
        Veeresh: I think you're claiming more than the evidence allows.

        As you reported, ginidesc (SSC; please do report provenance) will include 0s; it just warned you that it was doing so, but it's willing to go along with you. Sure, it threw you out and it didn't throw you out when you dropped your 0s, but until we know why you were thrown out the conclusion isn't clear. The error reported is of no observations, which probably means some quite different problem. Ideally you can show us your data.

        It's not my program, and I've not studied it.

        But I wouldn't trust an on-line calculator whose code I couldn't see, while it's my strong impression that user-written commands in Stata in this field are of high quality.

        Comment


        • #5
          Try ineqdeco and ineqdec0 from SSC and report back what answers you get. One throws out zeros and the other doesn't.

          Comment


          • #6
            Thanks Stephen I used inedec0 and it worked great. Much regards!! Thanks a lot for helping me out.

            Comment


            • #7
              Is there a way i can just get the overall Gini coefficient only . Because i am calculating gini coefficients for 300 countries and it is tedious to go to every table and copy the number. Is there an easier way to do this? Thanks again!

              Comment


              • #8
                You haven't told us how your data are organised, but I'm guessing you have the data for all countries in one file, with country identifier regionid. In this case, note that my programs save the Gini in r(gini). So, look at using the built-in statsby command and running it using the quietly prefix. I can't be more specific with an example at present as don't have access to Stata right now.

                Comment


                • #9
                  Here's an example of use, which you can adapt to suit, e.g. using statsby options and, of course, using the variable names relevant to your situation:
                  Code:
                  . sysuse auto, clear
                  (1978 Automobile Data)
                  
                  . quietly: statsby gini = r(gini), by(foreign): ineqdec0 mpg
                  
                  . list
                  
                       +---------------------+
                       |  foreign       gini |
                       |---------------------|
                    1. | Domestic   .1301388 |
                    2. |  Foreign   .1433695 |
                       +---------------------+

                  Comment


                  • #10
                    Thanks Stephen. I have data in a different format shown below.

                    regionid income1 familycome income2 income3 ........(like 300 income variables from different sources)
                    100 20 4 3333 444445
                    2034 4490 3344 4487 49700


                    I am trying to tabulate something like this in the end:

                    gini
                    income1 .023
                    familyincome .87
                    income2 .87
                    ...

                    Much Regards

                    Comment


                    • #11
                      I am now very confused about what your dataset contains (or whether there there are multiple datasets). Your earlier post referred to 300 countries, now you refer to 300 income variables (for each country?). Is the extract in your most recent message for one country (which contains multiple regions), or what? Please formulate clear questions, as the Forum FAQ recommends, and also -- as the FAQ recommends -- report code and data extracts within CODE delimiters to assist legibility (as I did in my last post).
                      I have a gut feeling that you actually have grouped data, and not unit record data. That is, within each country, you know the mean income for each region (and for each of various kinds of income source); and you don't have income data for each household (family, or individual). Be aware that, if the situation is as I conjecture, you should not be using any of the programs on SSC cited so far -- they assume you have unit record data. For estimation of inequality indices using grouped data, see Cowell and Mehta, Review of Economic Studies, 1982, and references cited therein.

                      Comment


                      • #12
                        I tried to calculate group inequality in consumption expenditure among the social groups using ineqdesco or ginidisc (i.e. ginidisc MPCE [aw=wight], by (social_group)) in stata version 13. But I am shown unrecognized command. My data is recorded against the social groups which are to be adjusted by weight given in the data set. please tell me how to address the problem

                        Comment


                        • #13
                          Rupan: welcome to Statalist. You don't describe your problem sufficiently clearly for readers -- well, me at least -- to be able to comment. Please re-read the FAQ (black bar at top of the webpage), especially the sections on how to post effectively

                          Comment


                          • #14
                            Thank you sir for your advice. I am using stata version 13. I want to measure decomposition of inequality in consumption expenditure by social groups (Gini= between+within+overlap).
                            I gave command ginidesc MPCE [aw=weight], by(Social group). Earlier stata showed me unrecognized command as I did not install ssc ginidesc program. Now I have installed it and gave same command. Again, it shows me- may not use noninteger frequency weights r(401);.
                            My data is per capita consumption expenditure of households where households are classified in to five social groups. Again there is weight against each household which must be used while calculating. please advice me what I have to do to get result.
                            However, if weight is not written in the command i.e. ginidesc MPCE, by(Social group) then it gives following result.

                            Pyatt's Inequality decomposition
                            Desig and Grupos Indice Part.
                            DESCOMP.
                            Between 0.088 30.281
                            Overlap 0.141 48.476
                            Within 0.062 21.243
                            TOTAL Gini 0.291 100.00

                            Comment

                            Working...
                            X