# Detrended fluctuation analysis

In stochastic processes, chaos theory and time series analysis, detrended fluctuation analysis (DFA) is a method for determining the statistical self-affinity of a signal. It is useful for analysing time series that appear to be long-memory processes (diverging correlation time, e.g. power-law decaying autocorrelation function) or 1/f noise.

The obtained exponent is similar to the Hurst exponent, except that DFA may also be applied to signals whose underlying statistics (such as mean and variance) or dynamics are non-stationary (changing with time). It is related to measures based upon spectral techniques such as autocorrelation and Fourier transform.

Peng et al. introduced DFA in 1994 in a paper that has been cited over 3,000 times as of 2022[1] and represents an extension of the (ordinary) fluctuation analysis (FA), which is affected by non-stationarities.

## Definition

### Algorithm

Given: a time series ${\displaystyle x_{1},x_{2},...,x_{N}}$.

Compute its average value ${\displaystyle \langle x\rangle ={\frac {1}{N}}\sum _{t=1}^{N}x_{t}}$.

Sum it into a process ${\displaystyle X_{t}=\sum _{i=1}^{t}(x_{i}-\langle x\rangle )}$. This is the cumulative sum, or profile, of the original time series. For example, the profile of an i.i.d. white noise is a standard random walk.

Select a set ${\displaystyle T=\{n_{1},...,n_{k}\}}$ of integers, such that ${\displaystyle n_{1}, the smallest ${\displaystyle n_{1}\approx 4}$, the largest ${\displaystyle n_{k}\approx N}$, and the sequence is roughly distributed evenly in log-scale: ${\displaystyle \log(n_{2})-\log(n_{1})\approx \log(n_{3})-\log(n_{2})\approx \cdots }$. In other words, it is approximately a geometric progression.[2]

For each ${\displaystyle n\in T}$, divide the sequence ${\displaystyle X_{t}}$ into consecutive segments of length ${\displaystyle n}$. Within each segment, compute the least squares straight-line fit (the local trend). Let ${\displaystyle Y_{1,n},Y_{2,n},...,Y_{N,n}}$ be the resulting piecewise-linear fit.

Compute the root-mean-square deviation from the local trend (local fluctuation):${\displaystyle F(n,i)={\sqrt {{\frac {1}{n}}\sum _{t=in+1}^{in+n}\left(X_{t}-Y_{t,n}\right)^{2}}}.}$And their root-mean-square is the total fluctuation:

${\displaystyle F(n)={\sqrt {{\frac {1}{N/n}}\sum _{i=1}^{N/n}F(n,i)^{2}}}.}$

(If ${\displaystyle N}$ is not divisible by ${\displaystyle n}$, then one can either discard the remainder of the sequence, or repeat the procedure on the reversed sequence, then take their root-mean-square.[3])

Make the log-log plot ${\displaystyle \log n-\log F(n)}$.[4][5]

### Interpretation

A straight line of slope ${\displaystyle \alpha }$ on the log-log plot indicates a statistical self-affinity of form ${\displaystyle F(n)\propto n^{\alpha }}$. Since ${\displaystyle F(n)}$ monotonically increases with ${\displaystyle n}$, we always have ${\displaystyle \alpha >0}$.

The scaling exponent ${\displaystyle \alpha }$ is a generalization of the Hurst exponent, with the precise value giving information about the series self-correlations:

• ${\displaystyle \alpha <1/2}$: anti-correlated
• ${\displaystyle \alpha \simeq 1/2}$: uncorrelated, white noise
• ${\displaystyle \alpha >1/2}$: correlated
• ${\displaystyle \alpha \simeq 1}$: 1/f-noise, pink noise
• ${\displaystyle \alpha >1}$: non-stationary, unbounded
• ${\displaystyle \alpha \simeq 3/2}$: Brownian noise

Because the expected displacement in an uncorrelated random walk of length N grows like ${\displaystyle {\sqrt {N}}}$, an exponent of ${\displaystyle {\tfrac {1}{2}}}$ would correspond to uncorrelated white noise. When the exponent is between 0 and 1, the result is fractional Gaussian noise.

### Pitfalls in interpretation

Though the DFA algorithm always produces a positive number ${\displaystyle \alpha }$ for any time series, it does not necessarily imply that the time series is self-similar. Self-similarity requires the log-log graph to be sufficiently linear over a wide range of ${\displaystyle n}$. Furthermore, a combination of techniques including maximum likelihood estimation (MLE), rather than least-squares has been shown to better approximate the scaling, or power-law, exponent.[6]

Also, there are many scaling exponent-like quantities that can be measured for a self-similar time series, including the divider dimension and Hurst exponent. Therefore, the DFA scaling exponent ${\displaystyle \alpha }$ is not a fractal dimension, and does not have certain desirable properties that the Hausdorff dimension has, though in certain special cases it is related to the box-counting dimension for the graph of a time series.

## Generalizations

The standard DFA algorithm given above removes a linear trend in each segment. If we remove a degree-n polynomial trend in each segment, it is called DFAn, or higher order DFA.[7]

Since ${\displaystyle X_{t}}$ is a cumulative sum of ${\displaystyle x_{t}-\langle x\rangle }$, a linear trend in ${\displaystyle X_{t}}$ is a constant trend in ${\displaystyle x_{t}-\langle x\rangle }$, which is a constant trend in ${\displaystyle x_{t}}$ (visible as short sections of "flat plateaus"). In this regard, DFA1 removes the mean from segments of the time series ${\displaystyle x_{t}}$ before quantifying the fluctuation.

Similarly, a degree n trend in ${\displaystyle X_{t}}$ is a degree (n-1) trend in ${\displaystyle x_{t}}$. For example, DFA1 removes linear trends from segments of the time series ${\displaystyle x_{t}}$ before quantifying the fluctuation, DFA1 removes parabolic trends from ${\displaystyle x_{t}}$, and so on.

The Hurst R/S analysis removes constant trends in the original sequence and thus, in its detrending it is equivalent to DFA1.

### Generalization to different moments (multifractal DFA)

DFA can be generalized by computing${\displaystyle F_{q}(n)=\left({\frac {1}{N/n}}\sum _{i=1}^{N/n}F(n,i)^{q}\right)^{1/q}.}$then making the log-log plot of ${\displaystyle \log n-\log F_{q}(n)}$, If there is a strong linearity in the plot of ${\displaystyle \log n-\log F_{q}(n)}$, then that slope is ${\displaystyle \alpha (q)}$.[8] DFA is the special case where ${\displaystyle q=2}$.

Multifractal systems scale as a function ${\displaystyle F_{q}(n)\propto n^{\alpha (q)}}$. Essentially, the scaling exponents need not be independent of the scale of the system. In particular, DFA measures the scaling-behavior of the second moment-fluctuations.

Kantelhardt et al. intended this scaling exponent as a generalization of the classical Hurst exponent. The classical Hurst exponent corresponds to ${\displaystyle H=\alpha (2)}$ for stationary cases, and ${\displaystyle H=\alpha (2)-1}$ for nonstationary cases.[8][9][10]

## Applications

The DFA method has been applied to many systems, e.g. DNA sequences,[11][12] neuronal oscillations,[10] speech pathology detection,[13] heartbeat fluctuation in different sleep stages,[14] and animal behavior pattern analysis.[15]

The effect of trends on DFA has been studied.[16]

## Relations to other methods, for specific types of signal

### For signals with power-law-decaying autocorrelation

In the case of power-law decaying auto-correlations, the correlation function decays with an exponent ${\displaystyle \gamma }$: ${\displaystyle C(L)\sim L^{-\gamma }\!\ }$. In addition the power spectrum decays as ${\displaystyle P(f)\sim f^{-\beta }\!\ }$. The three exponents are related by:[11]

• ${\displaystyle \gamma =2-2\alpha }$
• ${\displaystyle \beta =2\alpha -1}$ and
• ${\displaystyle \gamma =1-\beta }$.

The relations can be derived using the Wiener–Khinchin theorem. The relation of DFA to the power spectrum method has been well studied.[17]

Thus, ${\displaystyle \alpha }$ is tied to the slope of the power spectrum ${\displaystyle \beta }$ and is used to describe the color of noise by this relationship: ${\displaystyle \alpha =(\beta +1)/2}$.

### For fractional Gaussian noise

For fractional Gaussian noise (FGN), we have ${\displaystyle \beta \in [-1,1]}$, and thus ${\displaystyle \alpha \in [0,1]}$, and ${\displaystyle \beta =2H-1}$, where ${\displaystyle H}$ is the Hurst exponent. ${\displaystyle \alpha }$ for FGN is equal to ${\displaystyle H}$.[18]

### For fractional Brownian motion

For fractional Brownian motion (FBM), we have ${\displaystyle \beta \in [1,3]}$, and thus ${\displaystyle \alpha \in [1,2]}$, and ${\displaystyle \beta =2H+1}$, where ${\displaystyle H}$ is the Hurst exponent. ${\displaystyle \alpha }$ for FBM is equal to ${\displaystyle H+1}$.[9] In this context, FBM is the cumulative sum or the integral of FGN, thus, the exponents of their power spectra differ by 2.

## References

1. ^ Peng, C.K.; et al. (1994). "Mosaic organization of DNA nucleotides". Phys. Rev. E. 49 (2): 1685–1689. Bibcode:1994PhRvE..49.1685P. doi:10.1103/physreve.49.1685. PMID 9961383. S2CID 3498343.
2. ^ Hardstone, Richard; Poil, Simon-Shlomo; Schiavone, Giuseppina; Jansen, Rick; Nikulin, Vadim; Mansvelder, Huibert; Linkenkaer-Hansen, Klaus (2012). "Detrended Fluctuation Analysis: A Scale-Free View on Neuronal Oscillations". Frontiers in Physiology. 3: 450. doi:10.3389/fphys.2012.00450. ISSN 1664-042X. PMC 3510427. PMID 23226132.
3. ^ Zhou, Yu; Leung, Yee (2010-06-21). "Multifractal temporally weighted detrended fluctuation analysis and its application in the analysis of scaling behavior in temperature series". Journal of Statistical Mechanics: Theory and Experiment. 2010 (6): P06021. doi:10.1088/1742-5468/2010/06/P06021. ISSN 1742-5468. S2CID 119901219.
4. ^ Peng, C.K.; et al. (1994). "Quantification of scaling exponents and crossover phenomena in nonstationary heartbeat time series". Chaos. 49 (1): 82–87. Bibcode:1995Chaos...5...82P. doi:10.1063/1.166141. PMID 11538314. S2CID 722880.
5. ^ Bryce, R.M.; Sprague, K.B. (2012). "Revisiting detrended fluctuation analysis". Sci. Rep. 2: 315. Bibcode:2012NatSR...2E.315B. doi:10.1038/srep00315. PMC 3303145. PMID 22419991.
6. ^ Clauset, Aaron; Rohilla Shalizi, Cosma; Newman, M. E. J. (2009). "Power-Law Distributions in Empirical Data". SIAM Review. 51 (4): 661–703. arXiv:0706.1062. Bibcode:2009SIAMR..51..661C. doi:10.1137/070710111. S2CID 9155618.
7. ^ Kantelhardt J.W.; et al. (2001). "Detecting long-range correlations with detrended fluctuation analysis". Physica A. 295 (3–4): 441–454. arXiv:cond-mat/0102214. Bibcode:2001PhyA..295..441K. doi:10.1016/s0378-4371(01)00144-3. S2CID 55151698.
8. ^ a b H.E. Stanley, J.W. Kantelhardt; S.A. Zschiegner; E. Koscielny-Bunde; S. Havlin; A. Bunde (2002). "Multifractal detrended fluctuation analysis of nonstationary time series". Physica A. 316 (1–4): 87–114. arXiv:physics/0202070. Bibcode:2002PhyA..316...87K. doi:10.1016/s0378-4371(02)01383-3. S2CID 18417413. Archived from the original on 2018-08-28. Retrieved 2011-07-20.
9. ^ a b Movahed, M. Sadegh; et al. (2006). "Multifractal detrended fluctuation analysis of sunspot time series". Journal of Statistical Mechanics: Theory and Experiment. 02.
10. ^ a b Hardstone, Richard; Poil, Simon-Shlomo; Schiavone, Giuseppina; Jansen, Rick; Nikulin, Vadim V.; Mansvelder, Huibert D.; Linkenkaer-Hansen, Klaus (1 January 2012). "Detrended Fluctuation Analysis: A Scale-Free View on Neuronal Oscillations". Frontiers in Physiology. 3: 450. doi:10.3389/fphys.2012.00450. PMC 3510427. PMID 23226132.
11. ^ a b Buldyrev; et al. (1995). "Long-Range Correlation-Properties of Coding And Noncoding Dna-Sequences- Genbank Analysis". Phys. Rev. E. 51 (5): 5084–5091. Bibcode:1995PhRvE..51.5084B. doi:10.1103/physreve.51.5084. PMID 9963221.
12. ^ Bunde A, Havlin S (1996). "Fractals and Disordered Systems, Springer, Berlin, Heidelberg, New York". {{cite journal}}: Cite journal requires |journal= (help)
13. ^ Little, M.; McSharry, P.; Moroz, I.; Roberts, S. (2006). "Nonlinear, Biophysically-Informed Speech Pathology Detection" (PDF). 2006 IEEE International Conference on Acoustics Speed and Signal Processing Proceedings. Vol. 2. pp. II-1080–II-1083. doi:10.1109/ICASSP.2006.1660534. ISBN 1-4244-0469-X. S2CID 11068261.
14. ^ Bunde A.; et al. (2000). "Correlated and uncorrelated regions in heart-rate fluctuations during sleep". Phys. Rev. E. 85 (17): 3736–3739. Bibcode:2000PhRvL..85.3736B. doi:10.1103/physrevlett.85.3736. PMID 11030994. S2CID 21568275.
15. ^ Bogachev, Mikhail I.; Lyanova, Asya I.; Sinitca, Aleksandr M.; Pyko, Svetlana A.; Pyko, Nikita S.; Kuzmenko, Alexander V.; Romanov, Sergey A.; Brikova, Olga I.; Tsygankova, Margarita; Ivkin, Dmitry Y.; Okovityi, Sergey V.; Prikhodko, Veronika A.; Kaplun, Dmitrii I.; Sysoev, Yuri I.; Kayumov, Airat R. (March 2023). "Understanding the complex interplay of persistent and antipersistent regimes in animal movement trajectories as a prominent characteristic of their behavioral pattern profiles: Towards an automated and robust model based quantification of anxiety test data". Biomedical Signal Processing and Control. 81: 104409. doi:10.1016/j.bspc.2022.104409. S2CID 254206934.
16. ^ Hu, K.; et al. (2001). "Effect of trends on detrended fluctuation analysis". Phys. Rev. E. 64 (1): 011114. arXiv:physics/0103018. Bibcode:2001PhRvE..64a1114H. doi:10.1103/physreve.64.011114. PMID 11461232. S2CID 2524064.
17. ^ Heneghan; et al. (2000). "Establishing the relation between detrended fluctuation analysis and power spectral density analysis for stochastic processes". Phys. Rev. E. 62 (5): 6103–6110. Bibcode:2000PhRvE..62.6103H. doi:10.1103/physreve.62.6103. PMID 11101940. S2CID 10791480.
18. ^ Taqqu, Murad S.; et al. (1995). "Estimators for long-range dependence: an empirical study". Fractals. 3 (4): 785–798. doi:10.1142/S0218348X95000692.