Jeffrey_Bromaghin at fws.gov
2008-Jul-25 19:23 UTC
[R] Percentile Estimation From Kernel Density Estimate
Has anyone developed a defensible method of estimating percentiles from a univariate kernel density estimate? I am working on a problem in which the density estimate is of interest, but I would also like to estimate the value of the variable for which the distribution was, say, 0.20. I spent some time searching the archives and found some message from 2006 that implied such a method was not available at that time. Thanks! ******************************************* Jeffrey F. Bromaghin, PhD. U. S. Fish and Wildlife Service Fisheries and Ecological Services 1011 E. Tudor Road, Mail Stop 331 Anchorage, Alaska 99503 jeffrey_bromaghin at fws.gov PHONE: 907-786-3559 FAX: 907-786-3350
Karl Ove Hufthammer
2008-Jul-28 09:18 UTC
[R] Percentile Estimation From Kernel Density Estimate
Jeffrey_Bromaghin at fws.gov:> Has anyone developed a defensible method of estimating percentiles from a > univariate kernel density estimate? ?I am working on a problem in which > the density estimate is of interest, but I would also like to estimate the > value of the variable for which the distribution was, say, 0.20. ?I spent > some time searching the archives and found some message from 2006 that > implied such a method was not available at that time.You could always use simple numerical integration do this. Something like x = rnorm(1000) d = density(x, n=10^4) w = d$x[2] - d$x[1] s = cumsum( w*d$y ) # Probably better to use 'integrate' with 'approxfun'. d$x[ which(s >= .2)[1] ] But it's certainly not very 'defensible' (I won't defend it!), and you would likely get a better (and defensible) answer with quantile(x,.2) Compare this with the 'real' value qnorm(.2) -- Karl Ove Hufthammer