extrema: Local Extrema of Time Series

View source: R/extrema.R

extremaR Documentation

Local Extrema of Time Series

Description

Find the local minima and maxima from input data. This includes the artificial extrema added to the ends of the data as specified in the original EEMD article [1]. In the case of flat regions at the extrema, the center point of the flat region will be considered the extremal point [2].

Usage

extrema(input)

Arguments

input

Numeric vector or time series object.

Value

a list with matrices minima and maxima which give time points and values of local minima and maxima of input where time points are transformed to match the sampling times of input.

References

  1. Z. Wu and N. Huang, "Ensemble Empirical Mode Decomposition: A Noise-Assisted Data Analysis Method", Advances in Adaptive Data Analysis, Vol. 1 (2009) 1–41.

  2. P. Luukko, J. Helske and E. Räsänen, "Introducing libeemd: A program package for performing the ensemble empirical mode decomposition", Computational Statistics (2015).

Examples

ext <- extrema(UKgas)
plot(UKgas, ylim = range(ext$maxima[, 2], ext$minima[, 2]))
points(ext$maxima, col = 2, pch = 19)
points(ext$minima, col = 2, pch = 19)

# Artificial extremas obtained by extrapolating last two extrema
# Beginning of the series
lines(ext$minima[1:3, ], col = 4) 
# This is discarded as it produces smaller extrema than the last observation:
b <- lm(c(ext$maxima[2:3, 2]) ~ ext$maxima[2:3, 1])$coef[2]
points(x = ext$maxima[1, 1], y = ext$maxima[2, 2] - b, col = 4,pch = 19) 
lines(x = ext$maxima[1:3, 1], y = c(ext$maxima[2, 2] - b, ext$maxima[2:3, 2]), col = 4)
# End of the series
# These produce more extreme values than the last observation which is thus disregarded
lines(ext$minima[27:29, ],col = 4) 
lines(ext$maxima[26:28, ],col = 4) 


Rlibeemd documentation built on Sept. 8, 2023, 5:55 p.m.

Related to extrema in Rlibeemd...