Solved – Partition a zigzag-shaped time series

time series

I have a time series that zigzags up and down in cycles. I want to find a simple algorithm to partition it into segments of up sequences and down sequences.

It should be robust to noise so that a small kink shouldn't partition a sequence needlessly. Is there a name for such a technique?

EDIT: several of you have brought up seasonality. This is something I'm not literated in. Surely its something for me to learn. In this case I'm only want to find the points when direction change. I'm not sure if there considered any seasonality, in the sense of regular recurrence, in the data.

Best Answer

There is a function borrowed from the TA community, called a ZigZag indicator (which can be adjusted for noise thresholds). It is available in the TTR package of R.

zigzag

zigzagR

It might be possible to do the transformation(s) using classical time-series decomposition methods, but I don't know of a simple way to adjust the noise thresholding as in the zig-zag function.

Related Question