Statistical Methods
Audit what a linear detrending step removes
Define the task
Identify whether the baseline is a nuisance component or part of the scientific question. Removing a trend before testing for a trend can erase the feature you intended to study. Keep the raw sequence, sampling times and transformation settings. A linear detrend over sample indices assumes that index spacing is the appropriate time coordinate.
Carry out the check
Constant detrending subtracts a mean. Linear detrending subtracts a least-squares straight line. Specify which form was used, the axis and any breakpoints; piecewise fits may change behavior at segment boundaries. Examine the fitted baseline and residual sequence together. Detrending changes low-frequency content, so record it alongside spectral and correlation calculations rather than leaving it as an invisible software default.
Worked hypothetical example
For hypothetical values 2, 5 and 8 at indices 0, 1 and 2, the fitted line is 2+3 times the index, so linear-detrended residuals are all zero. Mean subtraction instead gives −3, 0 and 3. These operations answer different preprocessing questions. A perfectly removed line in this example is an algebraic result, not evidence that a real measurement trend was artifact. With uneven timestamps, fit against the actual times or use an appropriate method before interpreting a slope.
Method checked 15 November 2026 against SciPy documentation: detrend.