Detrended range fluctuation

55 Views Asked by At

I am trying to learn how to calculate DFA from wikipedia

https://en.wikipedia.org/wiki/Detrended_fluctuation_analysis

First:

$X_t=\sum_{i=1}^t (x_i-\langle x\rangle)$

Where $X_t$ = cumulative sum, and $\langle x\rangle$ = mean value of time series, and $t\in {\mathbb {N}}$

My interpretation using arbitrary numbers $({1,2,3,4,5,6,7,8,9,10,11,12})$

$\langle x\rangle$ = 6.5

Deviations = $-5.5,-4.5,-3.5,-2.5,-1.5,-.5,.5,1.5,2.5,3.5,4.5,6.5$

Therefore, cumulative sum $X_t$ = $0$

Obviously the sum of deviations from mean will awlays be 0 so I must be missing something here.

Second:

This part confused me even more because it says Next, $X_{t}$ is divided into time windows of length $n$ samples each, and a local least squares straight-line fit (the local trend) is calculated by minimising the squared errors within each time window. Let $Y_{t}$ indicate the resulting piecewise sequence of straight-line fits. Then, the root-mean-square deviation from the trend, the fluctuation, is calculated:

${\displaystyle F(n)={\sqrt {{\frac {1}{N}}\sum _{t=1}^{N}\left(X_{t}-Y_{t}\right)^{2}}}.}$

What defines the length of the time windows and if we are getting multiple least squares regression lines as from my interpretation "$X_t$ is divided into time windows of lengh $n$" then how would one calculate a log-log graph of $F_n$ agains $n$?