[EMAIL PROTECTED]: > 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 ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.