[R] Finding local minima and maxima
Sean Davis
sdavis2 at mail.nih.gov
Wed Jun 15 16:09:33 CEST 2005
Thanks, Uwe.
Actually, I didn't mean to make this complicated--simple vector x and
values at x in a vector y. Just wanted to determine the local minima
and maxima of y[x], but y is not continuous (but is a "smooth" function
of x). I will probably use hist or density to do it and then look at
these curves or cuts.
Sean
On Jun 15, 2005, at 8:16 AM, Uwe Ligges wrote:
> Sean Davis wrote:
>
>> I have data in the form of (x,y) pairs and would like to find local
>> minima and maxima (typically the zeros of the 2nd derivative) of the
>> y values. I looked at numericDeriv, but I don't have an "expression"
>> per se. I looked at optim, also, but it looks like it will find only
>> one "global" max or min. I can code up my own piecewise derivatives,
>> but wondered if there is an existing function to do this.
>
> If you don't have derivatives, and you don't have an expression, and
> you don't have a criteria how to minimize, please tell me of any known
> method that can handle your problem well enough.
>
> You could look whether y[i-1] <y[i] and y[i+1]<y[i] if y is ordered
> according to x, if this most trivial and very non-robust method fits
> to your definition...
>
> Uwe Ligges
>
>
>> Thanks,
>> Sean
>> ______________________________________________
>> R-help at stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide!
>> http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list