Computes the scaling exponent alpha of an activity time series using
Detrended Fluctuation Analysis (Peng et al., 1994). DFA quantifies long-range
temporal correlations: alpha approximately 0.5 indicates uncorrelated (white)
noise, alpha approximately 1.0 indicates 1/f (pink) noise, and alpha
approximately 1.5 indicates Brownian (random-walk / brown) noise. Healthy
human activity fluctuations typically show alpha in the 0.9 to 1.0 range, with
reductions reported in aging and Alzheimer's disease (Hu et al., 2009); those
reference values were obtained with quadratic DFA-2 (detrend_order = 2),
which can differ from the default linear DFA-1 on trend-carrying data.
Arguments
- x
Numeric vector of activity counts (minute-level recommended). Internally analyzed on the longest continuous non-NA segment.
- scale_min
Integer. Smallest window size (box length) in samples. Must be >= 4 so that a line can be detrended with residual degrees of freedom. Default 4.
- scale_max
Integer or NULL. Largest window size in samples. If NULL (default) it is set to floor(N / 4) where N is the length of the analyzed segment, ensuring at least four windows at the largest scale. The top scales then have only about four windows and are somewhat undersampled; Hu et al. (2001) suggest a maximum nearer N / 10 for well-sampled fluctuations.
- breakpoint_min
Numeric. Window-size boundary (in samples / minutes for minute-level data) separating the short-timescale exponent
alpha1(scales < breakpoint_min) from the long-timescale exponentalpha2(scales >= breakpoint_min). Default 90.- detrend_order
Integer order of the within-window polynomial detrend: 1 (default) is linear DFA-1 (Peng et al. 1994); 2 is quadratic DFA-2, the convention Hu et al. (2009) used for activity data.
Value
A list with class "actiRhythm_dfa" containing:
- alpha
Overall scaling exponent: slope of
lm(log10(F) ~ log10(n))across all scales.- alpha1
Short-timescale exponent (scales <
breakpoint_min). NA if fewer than two qualifying scales.- alpha2
Long-timescale exponent (scales >=
breakpoint_min). NA if fewer than two qualifying scales.- scales
Integer vector of window sizes n that were used.
- fluctuations
Numeric vector of fluctuation magnitudes F(n) corresponding to
scales.- n_used
Length of the analyzed (longest non-NA) segment.
- breakpoint_min
The breakpoint value used.
On an unusable series (too short, all NA, or constant) the numeric scaling outputs are returned as NA with the same structure (never an error).
Details
Algorithm (integrated, non-overlapping DFA, polynomial detrend of order
detrend_order):
Extract the longest continuous non-NA segment of
x.Integrate the mean-centred signal:
y = cumsum(x - mean(x)).For each window size n (log-spaced from
scale_mintoscale_max), split y into floor(N / n) non-overlapping windows of length n, fit and remove a least-squares polynomial of orderdetrend_orderwithin each window, and pool the residuals. The fluctuation isF(n) = sqrt(mean(residuals^2))over all pooled residuals.The scaling exponent is the slope of
log10(F(n))regressed onlog10(n).
Window sizes are unique integers chosen on a base-10 log grid, which gives approximately even spacing in the log-log fit and matches the convention used by reference implementations such as nonlinearTseries.
