Sangeeta Goyal
>
> I need to bootstrap kernel density estimates for a single
> variable and
> calculate and save their first and second derivatives in
> order to count the
> number of turning points. Any help will be welcome.
>
Working backwards, if the primary interest
is in # of turning points, then you don't
need first and second derivatives. A naive but
direct approach should suffice.
A minimum is less than its neighbours and
a maximum is more than its neighbours,
so (e.g. for minima) a first stab would be, given
the correct sort order
count if density < density[_n-1] & density < density[_n+1]
The first wrinkle is to make sure you omit
boundary points, as no point precedes the first
or follows the last.
A second wrinkle might be to worry about equality
with neighbours, i.e. check "<=" as well as "<".
Nick
[email protected]
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/