per                 package:GenKern                 R Documentation

_L_o_c_a_t_e _v_a_l_u_e _f_o_r _i_t_h _p_e_r_c_e_n_t_a_g_e _p_o_i_n_t _i_n _a _b_i_n_n_e_d _d_i_s_t_r_i_b_u_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     Calculates the value for the ith point in a binned distribution

_U_s_a_g_e:

     per(den, vals, point, na.rm=FALSE, neg.rm=FALSE)

_A_r_g_u_m_e_n_t_s:

     den: vector of frequency or density values

    vals: vector of values corresponding to the centres of the bins in
          'den', or the bin break points

   point: percentage point of the distribution ie: 0.50 is median

   na.rm: behaviour for NA's in the vector of density values: 'FALSE'
          (default) per() will fail with warning if NA's are detected,
          'TRUE' per() will assume that these values are really zeros

  neg.rm: per() will also fail if any member of the density vector is
          negative (which can happen occasionally from density
          functions based on FFT), set this to 'TRUE' to treat these
          values as zeros

_V_a_l_u_e:

     returns a value: 

       x: value of 'vals' corresponding to the 'point' position

_A_c_k_n_o_w_l_e_d_g_e_m_e_n_t_s:

     Written in collaboration with A.M.Pollard
     <a.m.pollard@bradford.ac.uk> with the financial support of the
     Natural Environment Research Council (NERC) grant GR3/11395

_N_o_t_e:

     Not restricted to uniform bin widths but due to linear
     interpolation gets less accurate as bin widths deviate from
     uniformity. The vectors must be in  ascending order of bin centres
     bin break points. The density can be a frequency in that it
     doesn't have to sum to unity.

     Out of character for the rest of the GenKern package this function
     does assume proper bins rather than ordinates, although if a
     density estimate has been generated using 'KernSec' then the
     ordinate vector can be used as a first order approximation to bin
     centres.

_A_u_t_h_o_r(_s):

     David Lucy <dlucy@maths.ed.ac.uk> 
      Robert Aykroyd <robert@amsta.leeds.ac.uk><URL:
     http://www.amsta.leeds.ac.uk/~robert/>

_S_e_e _A_l_s_o:

     'KernSur' 'per'  'density' 'hist' 'bkde' 'bkde2D' 'dpik'

_E_x_a_m_p_l_e_s:

     # make up some x-y data
     x <- seq(1,100)
     y <- dnorm(x, mean=40, sd=10)
     plot(x,y)                   
     # mark the median, 0.1 and 0.9 positions with vertical lines
     abline(v=per(y,x,0.5))
     abline(v=per(y,x,0.9))
     abline(v=per(y,x,0.1)) 
     # for a bimodal distribution which doesn't sum to one
     x <- c(1:5) 
     y <- c(2,3,4,3,4)
     per(y,x,0.5) # should return 3.25
     # change the previous example to bin extremes
     x <- c(1:6)
     per(y,x,0.5) # should return 3.75

