Announcement

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

  • #16
    Dear Stephen Jenkins, thank you very much for your elaboration.

    Comment


    • #17
      Ben's -pshare- with the step option provides results matching those of -sumdist- (and -svylorenz-).
      ... as long as there are no ties. Option -step- only omits interpolation of flat regions, ties will still be broken.

      Comment


      • #18
        Originally posted by Chen Samulsion View Post
        Follow #13: I found that -sumdist- & -pshare- had crossed at least 6 years ago https://www.statalist.org/forums/for...ist-and-pshare
        BTW, could the -sumdist- add another column to display mean of variable in each decile group? Thus we can avoid to execute xtile and tabstat to get the mean of each decile group. Although with the option qgp(newvarname), we can create a new variable (say qgpvar) that identifies the quantile group membership of each observation, and run tabstat variable, by(qgpvar) to get what I want.
        You could use option -average- in pshare. Example:

        Code:
        . sysuse nlsw88
        . pshare wage, n(10) average
        
        Percentile shares (average)              Number of obs = 2,246
        
        --------------------------------------------------------------
                wage | Coefficient  Std. err.     [95% conf. interval]
        -------------+------------------------------------------------
                0-10 |   2.661352   .0466623      2.569846    2.752858
               10-20 |   3.566543   .0581448       3.45252    3.680567
               20-30 |   4.306469   .0591152      4.190542    4.422395
               30-40 |   5.042257     .07195      4.901162    5.183353
               40-50 |   5.858092   .0849103      5.691581    6.024603
               50-60 |   6.783161   .1042711      6.578683    6.987639
               60-70 |   7.957788   .1317386      7.699445     8.21613
               70-80 |   9.500946   .1409769      9.224487    9.777405
               80-90 |    11.3826   .1721119      11.04509    11.72012
              90-100 |   20.61028   .7789552      19.08273    22.13783
        --------------------------------------------------------------
        This gives you the average of the running variable within each decile group. If you are interested in the averages of different variables, you can use option -pvar()- to specify the running variable. Example (note that the estimation sample changes because -tenure- has additional missing values; for reasons of consistency you may want to exclude these observations also from the above command):

        Code:
        . pshare tenure, n(10) average pvar(wage)
        
        Percentile shares (average)              Number of obs = 2,231
        
        --------------------------------------------------------------
              tenure | Coefficient  Std. err.     [95% conf. interval]
        -------------+------------------------------------------------
                0-10 |   2.746612   .2253933       2.30461    3.188615
               10-20 |   3.397478   .2678284      2.872259    3.922697
               20-30 |   4.008159     .29548      3.428714    4.587603
               30-40 |   5.321381     .33153      4.671241     5.97152
               40-50 |   5.188225   .3270064      4.546957    5.829494
               50-60 |   7.141261   .3634414      6.428542     7.85398
               60-70 |   7.397206   .3920051      6.628473    8.165939
               70-80 |   8.358247   .4231387       7.52846    9.188034
               80-90 |   8.538137   .4036212      7.746624    9.329649
              90-100 |   7.681794   .4063035      6.885022    8.478567
        --------------------------------------------------------------
        (percentile groups with respect to wage)
        This also works with multiple outcome variables:

        Code:
        . pshare tenure ttl_exp, n(10) average pvar(wage)
        
        Percentile shares (average)              Number of obs = 2,231
        
        --------------------------------------------------------------
                     | Coefficient  Std. err.     [95% conf. interval]
        -------------+------------------------------------------------
        tenure       |
                0-10 |   2.746612   .2253933       2.30461    3.188615
               10-20 |   3.397478   .2678284      2.872259    3.922697
               20-30 |   4.008159     .29548      3.428714    4.587603
               30-40 |   5.321381     .33153      4.671241     5.97152
               40-50 |   5.188225   .3270064      4.546957    5.829494
               50-60 |   7.141261   .3634414      6.428542     7.85398
               60-70 |   7.397206   .3920051      6.628473    8.165939
               70-80 |   8.358247   .4231387       7.52846    9.188034
               80-90 |   8.538137   .4036212      7.746624    9.329649
              90-100 |   7.681794   .4063035      6.885022    8.478567
        -------------+------------------------------------------------
        ttl_exp      |
                0-10 |   8.975308   .3307737      8.326651    9.623964
               10-20 |   10.37355   .2991184      9.786972    10.96013
               20-30 |   10.63966   .3020635      10.04731    11.23202
               30-40 |   12.17331   .2859634      11.61253     12.7341
               40-50 |   11.77993   .2975009      11.19652    12.36334
               50-60 |   13.52641   .2726825      12.99167    14.06115
               60-70 |   13.81569   .2976969      13.23189    14.39948
               70-80 |   14.43039   .2667726      13.90724    14.95354
               80-90 |   14.98143   .2448512      14.50127    15.46159
              90-100 |   14.85282   .2347553      14.39246    15.31318
        --------------------------------------------------------------
        (percentile groups with respect to wage)
        Equivalent commands in -dstat- are:

        Code:
        . dstat share wage, n(10) average
        . dstat share tenure, n(10) average by(wage)
        . dstat share tenure ttl_exp, n(10) average by(wage)
        ben

        Comment


        • #19
          Thank you very much professor ben!

          Comment

          Working...
          X