Learn R Programming

![downloads](http://cranlogs.r-pkg.org:443/badges/Rlibeemd

Rlibeemd

An R interface for libeemd C library for ensemble empirical mode decomposition (EEMD) and its complete variant (CEEMDAN). These methods decompose possibly nonlinear and/or nonstationary time series data into a finite amount of components (called IMFs, insintric mode functions) separated by instantaneous frequencies. This decomposition provides a powerful method to look into the different processes behind a given time series, and provides a way to separate short time-scale events from a general trend.

If you use Rlibeemd/libeemd for scientific work please cite Luukko, P.J.J., Helske, J., Räsänen, E., Comput. Stat. 31, 545 (2016) (also on arXiv). This article also describes in detail what libeemd actually computes. You should definitely read it if you are unsure about what EMD, EEMD and CEEMDAN are.

OpenMP parallel computing support

Current CRAN policies do not allow the use of SHLIB_OPENMP_CFLAGS combined with linking with C++. Therefore the CRAN version does not use OpenMP at all anymore (OpenMP flags have been removed from Makevars), but the the version on GitHub version does. So if you want to use parallel version of the Rlibeemd, please install the package via

install.packages('Rlibeemd', repos = 'https://helske.r-universe.dev')

Example

Here a CEEMDAN decomposition is performed for the UK gas consumption series (length n = 108). By default, ceemdan extracts [log_2(n)] components, so here we get five IMFs and the residual.

library("Rlibeemd")
data(UKgas, package = "datasets")
imfs <- ceemdan(UKgas, ensemble_size = 1000)
plot(imfs, main = "Five IMFs and residual extracted by CEEMDAN algorithm")

The residual components shows smooth trend whereas the first IMF contains clear multiplicative trend. The remaining IMFs are bit more complex, and one could argue that they are partly seasonal, trend or just some irregularity i.e. noise.

Let us compare the decomposition with basic structural time series model fit from StructTS (for smoothing of more complex state space models, one could use KFAS)

bsm <- tsSmooth(StructTS(UKgas))
plot(bsm[, c(1, 3)], main = "Local linear trend and seasonal components by StructTS")

StructTS decomposes the data for three components, where one of the components is (possibly time varying) slope, which has no direct effect to overall signal (it is the slope of the level component).

ts.plot(cbind(UKgas, imfs[, ncol(imfs)], rowSums(imfs[, 5:6]), bsm[,"level"]), col = 1:4,
  main = "Quarterly UK gas consumption", ylab = "Million therms")
legend("topleft", c("Observations", "Residual", "Last IMF + residual", "Trend from BSM"),
  col = 1:4, lty = 1)

The IMF_5 + residual is quite close to the trend obtained by structural time series model of StructTS.

Copy Link

Version

Install

install.packages('Rlibeemd')

Monthly Downloads

573

Version

1.4.4

License

GPL-3

Maintainer

Jouni Helske

Last Published

April 9th, 2025

Functions in Rlibeemd (1.4.4)

nIMFs

Number of IMFs
ceemdan

CEEMDAN decomposition
ECG

Electrocardiogram Data Example ECG data from MIT-BIH Normal Sinus Rhythm Database, ECG1 of record 16265, first 2049 observations (0 to 16 seconds with sampling interval of 0.0078125 seconds)
bemd

Bivariate EMD decomposition
Rlibeemd

Rlibeemd: Ensemble empirical mode decomposition (EEMD) and its complete variant (CEEMDAN)
extrema

Local Extrema of Time Series
emd

EMD decomposition
eemd

EEMD Decomposition
float

Float Data The data are a position record from an acoustically tracked subsurface oceanographic float, used as an example data in Rilling et al (2007).