I want to partition a data series using kernel density. Here is my plan:
- Using kernel density function (like density()) with variant window width to calculate the density of this series.
- On every kernel curve with different window width, I find all the turning points (including minimal and maximal) to partition the data.
So, I need to know where those turning points are in the original data series. I read some information like https://stats.stackexchange.com/questions/30750/finding-local-extrema-of-a-density-function-using-splines. But I do not really understand the method. In that method, d$x[tp$tppos] looks not the original index. So how can I find the positions of all the turning points in the original data based on kernel density curve?
Another related question is: how to find all the minimal/maximal points?
A sample of data series is:
a <- c(21.11606, 15.22204, 16.27281, 15.22204, 15.22204, 21.11606, 19.32840, 15.22204, 20.25594, 15.22204, 14.28352, 15.22195, 19.32840, 19.32840, 15.22204, 14.28352, 21.11606, 21.19069, 15.22204, 25.26564, 15.22204, 19.32840, 21.11606, 15.22204, 15.22204, 19.32840, 15.22204, 19.32840, 15.22204, 15.22204, 21.13656, 15.22204, 15.22204, 19.32840, 15.22204, 17.98954, 15.22204, 15.22204, 15.22204, 15.22204, 15.22204, 19.32840, 15.22204, 14.28352, 15.22204, 19.32840, 15.22204, 19.32840, 25.42281, 21.19069)