pdf - Finding The Max Value from Plotted Density Function (Kernel Density Estimation) in R -


i have data i'm assuming comes distribution , i'm trying estimate distribution. right i'm using package kernsmooth in r gaussian kernel , using package's dpik() function automatically select bandwidth. (i assume uses amise or sort, please let me know if there better auto-bandwidth selection process) i'm interested in, though, finding x-value corresponds highest peak in distribution...this seems simple thing me , put off trivial earlier on frustration, i'm hitting snags. bkde() function in kernsmooth passes set of (x,y) coordinates map out distribution algorithm has estimated. know linear search through data find max y-value , grab corresponding x-value but, writing function may called in automated process, feel inefficient. inefficient since bkde() gives lot of values.

my other idea attempt fit curve , take derivative , set equal 0 sounds may inefficient well. maybe density() better function use here?

please let me know if there efficient way this...i plan little bit of inference on distributions find. such finding cutoff points chop off percentage of tail on either side (i.e. confidence intervals) , finding expected value. vague plan use monte carlo techniques or attempt draw distribution idea areas bootstrapping techniques. on methods of these appreciated.

using:

> require(kernsmooth) loading required package: kernsmooth kernsmooth 2.23 loaded copyright m. p. wand 1997-2009 > mod <- bkde(faithful$waiting) > str(mod) list of 2  $ x: num [1:401] 22.7 23 23.2 23.4 23.7 ...  $ y: num [1:401] 3.46e-08 1.17e-07 1.40e-07 1.68e-07 2.00e-07 ... 

is not efficient enough?

> which(mod$y == max(mod$y)) [1] 245 

density() similar, returns 512 values of density evaluate @ 512 regular intervals of x.

in both functions number of points returned can controlled. see argument gridsize in bkde() , n in density(). of course, precision of approach depend on density of points @ kde estimated won;t want set low.

my gut tells me may spend awful lot more time thinking , implementing more efficient approach spend going above simple solution.


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -