Skip to content

Finding percentile of a value from an empirical distribution

4 messages · michael.weylandt at gmail.com (R. Michael Weylandt, Jorge I Velez, Robert A'gata

#
Hello,

I am not sure how to do this in R. Any suggestion would be
appreciated. I have a vector of values from where I build an empirical
CDF. For example:
0%     5%    10%    15%    20%    25%    30%    35%    40%    45%
  50%    55%
  1.00   5.00  10.00  16.00  20.00  25.00  31.00  36.00  41.00  45.55
50.00  56.00
   60%    65%    70%    75%    80%    85%    90%    95%   100%
 60.00  65.00  70.00  74.00  80.00  85.00  91.00  95.05 100.00

I would like to write a function that takes in a number z and vector x
(i.e. the raw vector).It returns percentile of z wrt x. E.g.
Should return something around 0.708 or 0.709. I am wondering if there
is any pre-packaged functions that do this in R? If not, how can I
write such a function. Any suggestion would be appreciated.

Robert
Look at ?ecdf 

Michael
On Jan 10, 2012, at 11:52 PM, "Robert A'gata" <rhelpacc at gmail.com> wrote:

            
#
Thank you. That's easier than I thought.

On Wed, Jan 11, 2012 at 12:06 AM, Jorge I Velez
<jorgeivanvelez at gmail.com> wrote: