xdfa - a software package to compute Detrended Fluctuation Analysis (DFA) and related methods

Introduction

The purpose of this work is to introduce a new software named xdfa to compute Detrended Fluctuation Analysis (DFA) methods. The core of the package is written in C++ for performance reasons with interfaces available for python, octave and R.

In the context of complex systems the observable time series of several quantities are the result of many small part interactions and often exhibit long range dependency, also called long memory. A model for a long memory stochastic process is the fractional Brownian motion, where a single parameter H (Hurst exponent) controls persistence of the time series. The original work from Peng et al [1] has introduced DFA in order to estimate the Hurst exponent of a time series. This method is widely used in several scientific fields like econophysics, geophysics, biophysics and others.

In the basic DFA framework trends at all scales are removed and the corresponding residual are analyzed to determine the functional dependence on scale and from that determine the estimated Hurst exponent. The trends can be fitted using different shapes with one of the most used being polynomials. As a result we refer to these techniques as DFA-1, DFA-2, ldots DFA-n where n is the order of the polynomial trend being removed (incidentally although seldom referred as such DFA-0 corresponds to Fluctuation Analysis, where we simply remove the average of each window, the precursor of DFA).

Another method of the same family of DFA is Detrended Moving Average (DMA) [2] where a moving average acts as the detrended function in DFA. Just like in DFA it is possible to find further generalizations where instead of just taking the moving average we take the an average polynomial interpolation over a given interval.

In the Brownian motion a single exponent characterizes the whole distribution. In order to assess multifractility of the data it was developed another method called Multi-Fractal DFA (MF-DFA) [3] to evaluate a set of exponents H_{q} where H_{q} is the Hurst exponent of moment q and DFA corresponds to the particular case where q=2.

Another possible extension is to analyze the original time series using a rolling window approach, a method akin to moving averages. We take a fixed window length smaller than the original time series and then evaluate how does the Hurst exponent depends on the initial starting time [4].

All the previous methods consider a single time series. If we look into the formula of DFA as an analog of variance then a possible generalization is the analog of cross-correlation for two time series. This method was named Detrendred Cross-Correlation Analysis by Podobnik and Stanley [5] and abbreviated to DCCA or DXA, which considers the evolution of two time series in the same framework as DFA. Other methods take this analogy even further by taking a partial DXA, i.e. the DXA of two time series with a given time lag [6].

The main goal of the xdfa software package is to have the code that deals with all these different methods in a single place and with a common interface. An added benefit is the sharing of as much code as possible between the different implementations using tools like extensive unit testing to validate the different components. This ensures that the code is not only computationally efficient but also numerically stable.

Examples

In order to understand how to use xdfa there is a simple tutorial.

References

[1] Peng C-K, Buldyrev SV, Havlin S, Simons M, Stanley HE, Goldberger AL. Mosaic organization of DNA nucleotides. Phys Rev E; 49: Pages 1685-1689 (1994).
[2] Carbone A, Castelli G, Stanley HE. Time-dependent Hurst exponent in financial time series, Physica A: Statistical Mechanics and its Applications, Volume 344, Issues 1–2, Pages 267-271 (2004).
[3] Kantelhardt, JW, Zschiegner, SA, Koscielny-Bunde, E, Havlin, S, Bunde, A, Stanley, HE. Multifractal detrended fluctuation analysis of nonstationary time series, Physica A, 316, 1–4, Pages 87-114 (2002).
[4] Matos, JAO, Gama, SMA, Ruskin, HJ, Sharkasi, A, Crane, M. Time and scale Hurst exponent analysis for financial markets. Physica A, 387, 15, 3910-3915 (2008).
[5] Podobnik, B and Stanley, HE. Detrended Cross-Correlation Analysis: A New Method for Analyzing Two Nonstationary Time Series, Phys. Rev. Lett. 100, 8, pages 084102 (2008).
[6] Qian, X-Y, Liu, Y-M, Jiang, Z-Q, Podobnik, B, Zhou, W-X, Stanley, HE. Detrended partial cross-correlation analysis of two nonstationary time series influenced by common external forces, Phys. Rev. E 91, 6062816 (2015).