Description Usage Arguments Details Value Author(s) References Examples

Functions for performing Detrended Fluctuation Analysis (DFA), a widely used technique for detecting long range correlations in time series. These functions are able to estimate several scaling exponents from the time series being analyzed. These scaling exponents characterize short or long-term fluctuations, depending of the range used for regression (see details).

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ```
dfa(time.series, window.size.range = c(10, 300), npoints = 20,
do.plot = TRUE, ...)
## S3 method for class 'dfa'
windowSizes(x)
## S3 method for class 'dfa'
fluctuationFunction(x)
## S3 method for class 'dfa'
plot(x, main = "Detrended Fluctuation Analysis",
xlab = "Window size: t", ylab = "Fluctuation function: F(t)",
log = "xy", ...)
## S3 method for class 'dfa'
estimate(x, regression.range = NULL, do.plot = FALSE,
fit.col = 2, fit.lty = 1, fit.lwd = 1, add.legend = TRUE, ...)
``` |

`time.series` |
The original time series to be analyzed. |

`window.size.range` |
Range of values for the windows size that will be used to estimate the fluctuation function. Default: c(10,300). |

`npoints` |
The number of different window sizes that will be used to estimate the Fluctuation function in each zone. |

`do.plot` |
logical value. If TRUE (default value), a plot of the Fluctuation function is shown. |

`...` |
Additional graphical parameters. |

`x` |
A |

`main` |
A title for the plot. |

`xlab` |
A title for the x axis. |

`ylab` |
A title for the y axis. |

`log` |
A character string which contains "x" if the x axis is to be logarithmic, "y" if the y axis is to be logarithmic and "xy" or "yx" if both axes are to be logarithmic. |

`regression.range` |
Vector with 2 components denoting the range where the function will perform linear regression. |

`fit.col` |
A colors to plot the regression line. |

`fit.lty` |
The type of line to plot the regression line. |

`fit.lwd` |
The width of the line for the regression line. |

`add.legend` |
add a legend with the resulting estmation to the plot? |

The Detrended Fluctuation Analysis (DFA) has become a widely used technique for detecting long range correlations in time series. The DFA procedure may be summarized as follows:

Integrate the time series to be analyzed. The time series resulting from the integration will be referred to as the profile.

Divide the profile into N non-overlapping segments.

Calculate the local trend for each of the segments using least-square regression. Compute the total error for each ofi the segments.

Compute the average of the total error over all segments and take its root square. By repeating the previous steps for several segment sizes (let's denote it by t), we obtain the so-called Fluctuation function

*F(t)*.If the data presents long-range power law correlations:

*F(t) proportional t^alpha*and we may estimate using regression.Usually, when plotting

*log(F(t)) Vs log(t)*we may distinguish two linear regions. By regressing them separately, we obtain two scaling exponents,(characterizing short-term fluctuations) and*alpha1*(characterizing long-term fluctuations).*alpha2*

Steps 1-4 are performed using the *dfa* function. In order to obtain a
estimate of some scaling exponent, the user must use the *estimate*
function specifying the regression range (window sizes used to detrend the
series).

A *dfa* object.

The *windowSizes* function returns the windows sizes used
to detrend the time series.

The *fluctuationFunction* function returns the fluctuation
function obtained in the DFA represented by the *dfa* object.

Constantino A. Garcia

Penzel, Thomas, et al. "Comparison of detrended fluctuation analysis and spectral analysis for heart rate variability in sleep and sleep apnea." Biomedical Engineering, IEEE Transactions on 50.10 (2003): 1143-1151.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | ```
## Not run:
white.noise = rnorm(5000)
dfa.analysis = dfa(time.series = white.noise, npoints = 10,
window.size.range=c(10,1000), do.plot=FALSE)
white.estimation = estimate(dfa.analysis,do.plot=TRUE)
cat("Theorical: 0.5---Estimated: ",white.estimation ,"\n")
library(fArma)
fgn = as.numeric(fArma::fgnSim(n = 2000, H = 0.75))
dfa.analysis = dfa(time.series = fgn, npoints = 30,
window.size.range=c(10,1000),
do.plot=FALSE)
fgn.estimation = estimate(dfa.analysis, do.plot = TRUE,
fit.col="blue",fit.lwd=2,fit.lty=2,
main="Fitting DFA to fGn")
cat("Theorical: 0.75---Estimated: ",fgn.estimation ,"\n")
fbm = as.numeric(fArma::fbmSim(n = 2000, H = 0.25))
dfa.analysis = dfa(time.series = fbm, npoints = 50,
window.size.range=c(10,300),
do.plot=FALSE)
fbm.estimation = estimate(dfa.analysis,do.plot = TRUE,
add.legend=F, main="DFA of fBm")
cat("Theorical: 1.25 ---Estimated: ",fbm.estimation ,"\n")
## End(Not run)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.