0

I've been working on detecting peaks within a data set of thousands of y~x relationships. Thanks to this post, I've been using loess and rollapply to detect peaks by comparing the local maximum to the smooth. Since, I've been working to optimise the span and w thresholds for loess and rollapply functions, respectively.

However, I have realised that several of my relationships have a peak at the beginning or the end on the x-axis, which are of my interest. But these peaks are not being identified. For now, I've tried to add fake variables outside of my x variable range to imitate a peak. For example, if my x values range from -50 to 160, I created x values of -100 and 210 and assigned a 0 y value to them.

This helped me to identify some of the relationships that have a peak at the beginning or the end. As you can see here:

enter image description here

However, for some it does not work.

enter image description here enter image description here

Despite the fact that I feel uncomfortable adding 'fake' values to the relationship, the smoothing shifts the location of the peak frequently and more importantly, I cannot find a solution that allows to detect these beginning or end peaks. Does anyone know how to work out a solution that works in R?

Syscall
  • 19,327
  • 10
  • 37
  • 52
neko
  • 48
  • 6
  • 2
    https://stackoverflow.com/q/6836409/10488504 - Finding local maxima and minima – GKi Dec 10 '19 at 18:14
  • thanks, I checked and tried the first answer but it's the same issue. It does not detect maxima if they are at the beginning or the end. – neko Dec 11 '19 at 19:39
  • EDIT: I'm trying @Tommy's answer and it seems more promising! – neko Dec 11 '19 at 19:48

0 Answers0