Announcement

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

  • Creating a variable that calculates percentage place in a wealth distribution

    Dear all,

    I am trying to calculate the place of an individual in a wealth distribution. I have looked at the egen commands but I cannot find anything that suits this purpose. My goal is to have for an individual the percentage place in a wealth distriubtion. For example, panel_id =101 with X amount of wealth places in the wealth distribution at 85.5%. He thus belongs to the top 15 percent. I know how to calculate the overall shares of decile groups using the pshare command, but now I want to calculate it per individual. I have panel data. I would like to caculate it per year. Anyone who knows how to do this? My ultimate goal is to see whether receiving inheritance increases your place in the wealth distriubtion.

    Thank you in advance.

    Best,

    Timo

  • #2
    Code:
    // create some example data
    clear
    set seed 1234567
    set obs 100
    gen id = _n
    gen wealth = rnormal(100, 10)
    expand 5
    bys id : gen wave = _n
    replace wealth = wealth + rnormal(0,20)
    
    
    // create the variable you want (well a proportion, not percentage)
    bys wave: cumul wealth, gen(prop) equal
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      https://www.stata.com/support/faqs/s...ing-positions/ is an FAQ that seems relevant here.

      Comment


      • #4
        Both answers are very helpful. Replacing 'wave' by 'year' in the code of Maarten Buis did the job for my data. The link by Nick Cox gave further insight in the different ways to do it (see final paragraph). Maybe a final question: what is the method used when using 'cumul' of Maarten Buis? In the link of Nick Cox it is shown that there are different formulas to calculate percentile ranks. What is the formula used by 'cumul' (with and without 'equal')? In the help file of 'cumul' I do not find an explanation.

        Thank you very much already for the very helpful information.

        Comment


        • #5
          There are many different ways to calculate percentile ranks, plotting positions, and quantile summaries, but -- setting aside ties -- there are most four different ways to cumulate frequencies or probabilities, depending on choice of < <= > or >= as comparator. In my experience <= and > are the most common choices.

          There is not much obscurity about what cumul can do. I was going to refer you to https://www.stata.com/manuals/rcumul.pdf for formulas -- but despite writing the vignette on Fourier therein I hadn't noticed until now that there aren't any formulas. So, what cumul does by default is to count values <= this value and calculate the corresponding probabilities as running from 1/n to n/n for sample size n. That is fine for many purposes but treats tails asymmetrically.

          Code:
          sysuse auto, clear
          cumul price, gen(cupr_price)
          cumul price, gen(cufr_price) freq 
          sort price
          list *price if inrange(_n, 1, 5) | inrange(_n, _N-4, _N)
          
               +------------------------------+
               |  price   cupr_p~e   cufr_p~e |
               |------------------------------|
            1. |  3,291   .0135135          1 |
            2. |  3,299    .027027          2 |
            3. |  3,667   .0405405          3 |
            4. |  3,748   .0540541          4 |
            5. |  3,798   .0675676          5 |
               |------------------------------|
           70. | 12,990   .9459459         70 |
           71. | 13,466   .9594595         71 |
           72. | 13,594    .972973         72 |
           73. | 14,500   .9864865         73 |
           74. | 15,906          1         74 |
               +------------------------------+
          The help for distplot (Stata Journal) expands upon these tiny issues.


          Comment


          • #6
            Thank you very much for the explanantion Nick Cox! Excellent help.

            Comment

            Working...
            X