Announcement

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

  • How to capture some of the inequality indices provided by "inequal" command

    I am using the following command to generate inequality indices for the variable "rendomdefpc" for each combination of 27 states (uf) and 5 years (ano):

    levelsof uf, local(ufs)

    foreach c of local ufs {
    levelsof ano if uf == `c', local(anos)
    foreach y of local anos {
    display `"uf == `c', ano == `y'"'
    inequal rendomdefpc [fw=pesopes] if uf == `c' & ano == `y'
    }

    }

    Among the indices that the results of the command "inequal" provide I'm only interested in the Gini coefficient, in the Theil mean log deviation measures and in the Theil entropy measure, and tried to use the following syntax to capture them:

    capture postutil clear
    postfile handle ufs ano gini theil_t theil_l using desiguald, replace

    levelsof uf, local(ufs)

    foreach c of local ufs {
    levelsof ano if uf == `c', local(anos)

    foreach y of local anos {
    display `"uf == `c', ano == `y'"'
    inequal rendomdefpc [fw=pesopes] if uf == `c' & ano == `y'
    post handle (`c') (`y') (`r(gini)') (`r(theil_t)') (`r(theil_l)')
    }
    }

    postclose handle
    The syntax did not work and Stata generated the following error message:

    invalid syntax
    post: above message Corresponds to 3 expression, variable gini
    I would once again be able to count on your help and solve this problem more.

    Thanks in advance

    Girlan

  • #2
    Most of my answer in http://www.statalist.org/forums/foru...nequal-with-by seems to apply, i.e.

    1. This appears to refer to inequal from STB-23.
    If so, inequal is not r-class and in fact leaves precisely no results in memory, so this will not work without rewriting the program

    2. If it is not you should please tell us exactly what inequal is (FAQ Advice #12, as before).

    .

    Comment


    • #3
      Nick,

      The inequal in question really is the STB-23.
      How do I then get to do what I want?

      Comment


      • #4
        Girlan: why not use -ineqdeco- or -ineqdec0-? They are on SSC. Think of new variable defining combinations of years and states (egen's group()), then use the by() option to these programs, and note that results are saved in r() macros -- see the help file. Or instead loop around combinations of years and states, calculate the indices, and pick up the values from r(), as before. You can of course accumulate results using -post-

        Comment


        • #5
          I'd follow Stephen's advice, because, as I already said, you'd need to rewrite inequal. I see no point in doing that myself or advising how to do it when, it seems, there are later programs to do what you want.

          Comment


          • #6
            I am trying to compute historical Gini coefficient of per capita income for each US state from 1996-2020 using the code below. But even though the code runs, it produces blanks.

            egen gini_state = inequal(ln_incomepercapita), by(state) index(gini)
            Would appreciate your help. I have attached the data.
            Ephraim
            Attached Files

            Comment

            Working...
            X