Announcement

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

  • How to create bottom 26% of the population

    Hi,

    I have been using thus far xtile quin=mpce[aw=weight], n(5) to create bottom 20% of the population. How can we create the bottom 26% or bottom 33%?

    Any help is appreciated


  • #2

    The help for xtile tells you about other commands in the same territory. So for example you can get estimates of the 26th and 33rd percentiles.

    .
    Code:
     sysuse auto, clear
    (1978 Automobile Data)
    
    . _pctile mpg, p(26 33)
    
    . ret li
    
    scalars:
                     r(r1) =  18
                     r(r2) =  18
    
    . quantile mpg, yline(18)
    The example is instructive. The graph shows that ties can mean that returning the same result for different percentiles can be entirely reasonable.

    See also the pctile() function of egen.
    Click image for larger version

Name:	problemquantiles.png
Views:	1
Size:	30.9 KB
ID:	1574405



    Last edited by Nick Cox; 26 Sep 2020, 05:09.

    Comment


    • #3
      Thank you ever so much. Just to clarify-- with r(r1)=18, any observation for mpg less than equal to 18 shall be my target group for bottom 26%?

      Comment


      • #4
        Indeed. Also 18 is reported as every percentile from 25 to 36. Your own data may be less awkward. .

        Code:
        sysuse auto, clear
        numlist "1/99"
        _pctile mpg , p(`r(numlist)')
        forval j = 1/99 {
            di `j' "{col 7}" r(r`j')
        }
        
        
        1     12
        2     12
        3     14
        4     14
        5     14
        6     14
        7     14
        8     14
        9     14
        10    14
        11    15
        12    15
        13    15
        14    16
        15    16
        16    16
        17    16
        18    16
        19    17
        20    17
        21    17
        22    17
        23    17
        24    17
        25    18
        26    18
        27    18
        28    18
        29    18
        30    18
        31    18
        32    18
        33    18
        34    18
        35    18
        36    18
        37    19
        38    19
        39    19
        40    19
        41    19
        42    19
        43    19
        44    19
        45    19
        46    19
        47    19
        48    20
        49    20
        50    20
        51    20
        52    21
        53    21
        54    21
        55    21
        56    21
        57    21
        58    21
        59    22
        60    22
        61    22
        62    22
        63    22
        64    22
        65    23
        66    23
        67    23
        68    23
        69    24
        70    24
        71    24
        72    24
        73    24
        74    24
        75    25
        76    25
        77    25
        78    25
        79    25
        80    25
        81    25
        82    26
        83    26
        84    26
        85    26
        86    28
        87    28
        88    28
        89    28
        90    29
        91    30
        92    30
        93    30
        94    31
        95    34
        96    35
        97    35
        98    35
        99    41

        Comment

        Working...
        X