Extensions

MFDFA as seen since its development a set of enhancements. In particular the usage of Empirical Mode Decomposition as a source of detrending, instead of polynomial fittings, which allows for a more precise removal of known trends in the timeseries.

Employing Empirical Mode Decompositions for detrending

Empirical Mode Decomposition (EMD), or maybe more correctly described, the Hilbert─Huang transform is a transformation analogous to a Fourier or Hilbert transform that decomposes a one-dimensional timeseries or signal into its Intrinsic Mode Functions (IMFs). For our purposes, we simply want to employ EMD to detrend a timeseries.

Warning

To use this feature, you need to first install PyEMD (EMD-signal) with

pip install EMD-signal

Understanding MFDFA’s EMD detrender

Take a timeseries y and extract the Intrinsic Mode Functions (IMFs)

# Import
from MFDFA import IMFs

# Extract the IMFs simply by employing
IMF = IMFs(y)

From here one obtains a (..., y.size). Best now to study the different IMFs is to plot them and the timeseries y

# Import
import matplotlib.pyplot as plt

# Plot the timeseries and the IMFs 6,7, and 8
plt.plot(X, color='black')
plt.plot(np.sum(IMF[[6,7,8],:], axis=0).T)

Using MFDFA with EMD

To now perform the multifractal detrended fluctuation analysis, simply insert the IMFs desired to be subtracted from the timeseries. This will also for order = 0, not to do any polynomial detrending.

# Select a band of lags, which usually ranges from
# very small segments of data, to very long ones, as
lag = np.logspace(0.7, 4, 30).astype(int)

# Obtain the (MF)DFA by declaring the IMFs to subtract
# in a list in the dictionary of the extensions
lag, dfa = MFDFA(y, lag = lag, extensions = {"EMD": [6,7,8]})

Extended Detrended Fluctuation Analysis

In the publication Detrended fluctuation analysis of cerebrovascular responses to abrupt changes in peripheral arterial pressure in rats. the authors introduce a new metric similar to the conventional Detrended Fluctuation Analysis (DFA) which they denote Extended Detrended Fluctuation Analysis (eDFA), which relies on extracting the difference of the minima and maxima for each segmentation of the data, granting a new power-law exponent to study, i.e., as in eq. (5) in the paper

\[\mathrm{d}F (n) = \mathrm{max}[F(n)] - \mathrm{min}[F(n)],\]

which in turn results in

\[\mathrm{d}F(n) \sim n^\beta.\]

Using MFDFA’s eDFA extension

To obtain the eDFA, simply set the extension to True and add a new output function, here denoted edfa

# Select a band of lags, which usually ranges from
# very small segments of data, to very long ones, as
lag = np.logspace(0.7, 4, 30).astype(int)

# Obtain the (MF)DFA by declaring the IMFs to subtract
# in a list in the dictionary of the extensions
lag, dfa, edfa = MFDFA(y, lag = lag, extensions = {'eDFA': True})

Moving window for segmentation

For short timeseries the segmentation of the data—especially for large lags—results in bad statistics, e.g. if a timeseries has 2048 datapoints and one wishes to study the flucutation analysis up to a lag of 512, only 4 segmentations of the data are possible for the lag 512. Instead one can use an moving window over the timeseries to obtain better statistics at large lags.

Using MFDFA’s window extension

To utilise a moving window one has to declare the moving windows step-size, i.e., the number of data points the window will move over the data. Say we wish to increase the statistics of the aforementioned example to include a moving window moving 32 steps (so one has 64 segments at a lag of 512)

# Select a band of lags, which usually ranges from
# very small segments of data, to very long ones, as
lag = np.logspace(0.7, 4, 30).astype(int)

# Obtain the (MF)DFA by declaring the IMFs to subtract
# in a list in the dictionary of the extensions
lag, dfa, edfa = MFDFA(y, lag = lag, extensions = {'window': 32})