Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: Percentiles: Identify of smallest observation closetto percentile value


From   Rod Hunter <[email protected]>
To   [email protected]
Subject   Re: st: RE: Percentiles: Identify of smallest observation closetto percentile value
Date   Tue, 04 Feb 2003 06:33:58 +1100

Thanks Nick and Ronnie.
I still don't appear to be out of the woods.

1.
I applied Nick's procedure to my example:
. centile var1 , c(75)
--------------------------------------------------------------------
-- Binom. Interp. --
Variable Obs Percentile Centile [95% Conf. Interval]

var1 4 75 9.75 7.45 10*

* Lower (upper) confidence limit held at minimum (maximum) of sample
-----------------------------------------------------------
. ret li
------------------------------------------------
scalars:
r(n_cent) = 1
r(N) = 4
r(ub_1) = 10
r(lb_1) = 7.450000000008672
r(c_1) = 9.75
macros:
r(centiles) : "75"
-------------------------------------------------
. list var1 if var1 == `r(c_1)'
-----------------------------------------------
var1
.
-----------------------------------------------
This does not give me the identity nor value of the largest observation within the percentage of the observations included by the 75th percentile.

2.
I tried Ronnie's approach:

. sum var1, d
-------------------------------------------
var1
Percentiles Smallest
1% 7 7
5% 7 8
10% 7 9 Obs 4
25% 7.5 10 Sum of Wgt. 4

50% 8.5 Mean 8.5
Largest Std. Dev. 1.290994
75% 9.5 7
90% 10 8 Variance 1.666667
95% 10 9 Skewness 0
99% 10 10 Kurtosis 1.64
---------------------------------------------------
. local macro*
. list var1 if var1 == `p75'
-------------------------------------------------
var1
-------------------------------------------------

3.
This is what I have been using:

. _pctile var1,p(75)
. gen var1_p75=r(r1)
. tabstat var1 if var1==var1_p75, stat(max)
-------------------------------------
no observations
-------------------------------------
alternatively:
. list var1 if var1==var1_p75
---------------------------------------
var1
---------------------------------------

Any further suggestions?

Regards,

Rod Hunter






Nick Cox wrote:

Rod Hunter

A simple eg. will suffice.

Obs. Var1
----------
1     	10
2	9
3	8
4	7
-----------

I would like Stata to tell me the value of the observation
that is at or
 below the 75th percentile point, and to yield the identity (or
identities) of the observation(s).

I'll change your example. I don't know about "below". ~ 75% are
below; do you what them all?

. use auto
. centile rep78 , c(75)

                                                       -- Binom.
Interp. --
    Variable |     Obs  Percentile      Centile        [95% Conf.
Interval]
-------------+--------------------------------------------------------
-----
       rep78 |      69         75             4               4
5

. ret li

scalars:
            r(n_cent) =  1
                 r(N) =  69
              r(ub_1) =  5
              r(lb_1) =  4
               r(c_1) =  4

macros:
          r(centiles) : "75"

. list rep78 if rep78 == `r(c_1)'

     +-------+
     | rep78 |
     |-------|
  5. |     4 |
 15. |     4 |
 24. |     4 |
 29. |     4 |
 30. |     4 |
     |-------|
 33. |     4 |
 35. |     4 |
 38. |     4 |
 47. |     4 |
 55. |     4 |
     |-------|
 56. |     4 |
 58. |     4 |
 59. |     4 |
 62. |     4 |
 63. |     4 |
     |-------|
 70. |     4 |
 72. |     4 |
 73. |     4 |
     +-------+
Nick
[email protected]

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/




*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index