Linear Detrending
What you'll learn: You'll learn how to remove a straight-line trend from time series data using regression-based detrending.
Why Linear Detrending?
Imagine tracking your savings account balance over time. It steadily grows, but you want to analyze the fluctuations around that growth pattern—not the growth itself. Linear detrending removes the upward (or downward) slant so you can focus on what's left: the variations that matter for your analysis.
The Core Idea
Linear detrending fits a straight line through your time series data and then subtracts that line from the original values. The result is a detrended series centered around zero, with the long-term linear trend removed.
This is fundamentally a regression problem:
- Independent variable: time (often just the index: 1, 2, 3, ...)
- Dependent variable: your time series values
- Goal: fit the line
y = a + b*time, then subtract it
How It Works
- Fit a linear regression: find the best-fit line through your data points
- Calculate predicted values from that line
- Subtract the predicted values from the original series:
detrended = original - predicted
The detrended series retains seasonality, cycles, and noise—but the steady upward or downward drift is gone.
When to Use It
Linear detrending works well when your trend is approximately straight. If your data curves or accelerates, you might need polynomial detrending or logarithmic transformation instead. But for many business and economic time series with steady growth, linear detrending is simple and effective.
Key Takeaway: Linear detrending removes a straight-line trend by fitting a regression line to your time series and subtracting it, leaving you with stationary fluctuations around zero for easier analysis.