Time Series Regression

Time series regression applies the linear-model machinery to the setting where the predictors are functions of time (trends, seasonal indicators, sinusoids, lagged values of the response, exogenous time-indexed covariates) and the residuals are almost never independent. The mechanics of fitting the regression are the standard ones from linear and multiple linear regression; what changes is which predictors appear in the design, how to handle the serially correlated residuals, and how to validate the fit without leaking future information into past training data. The basic specification is

where are the time-indexed predictors and is the noise process. Common choices for the predictors include a polynomial in (trend), seasonal dummies or low-frequency Fourier basis (seasonality), lagged response values (autoregressive structure), exogenous inputs , and lagged versions of those exogenous inputs (distributed-lag).

The single time-series-specific topic that needs its own treatment in this folder is the sinusoidal regression model, in which is fit by a sum of sines and cosines at one or more frequencies. With known frequencies the model is linear in and the OLS solution applies directly; with unknown frequencies it becomes nonlinear in the parameters and is usually fit by profile least squares over a frequency grid. The model also obeys the Nyquist limit: at sampling frequency , only frequencies are identifiable, with higher frequencies aliasing into this range.

Three further practical points reshape the regression workflow when applied to time series. First, OLS standard errors are wrong under serial correlation, even though the point estimates remain unbiased; the right substitutes are HAC (Newey-West) standard errors or generalized least squares (GLS) with an estimated noise covariance. Second, regressing one nonstationary series on another can produce spurious regression: a high and significant coefficients even when the series are independent, driven by their shared stochastic trends. The remedy is to difference the series, test for cointegration, or include explicit trend terms. Third, cross-validation by random folds breaks chronology and is replaced by rolling-origin CV.

Use Time-Series Cross-Validation -fold CV mixes future observations into past training sets and produces wildly optimistic error estimates. Always use rolling-origin CV (TimeSeriesSplit in scikit-learn) for any model selection or hyperparameter tuning on time-series data, including for choosing the ridge or comparing ARIMA orders.

Random

Intuition

A time series is not a bag of independent samples that happen to be indexed by time; the index matters. Two facts follow. The predictors a time-series regression cares about are usually time itself (trends), periodic functions of time (seasonal cycles), and lagged values of the response or of exogenous inputs (memory). The residuals from such a regression almost never look like white noise on the first try; they carry the leftover serial structure the model failed to capture, and the analyst’s job is to inspect them and refine the model until they do.

The general regression machinery, OLS, MLE, ridge, lasso, cross-validation, lives in the machine-learning regression folder and is not re-derived here. This folder covers only the pieces that are time-series-specific: the sinusoidal regression model and the Nyquist limit (this note), distributed-lag identification of input-output couplings (2.4.3 Time-Lagged Regression), and rolling-origin cross-validation (2.4.5 Time-Series Cross-Validation).

Sinusoidal Regression and the Nyquist Limit

A pure sinusoid observed in noise can be written

using the trigonometric identity , which gives and . Recovering the amplitude and phase from the fitted coefficients uses and .

(Known Frequency) If is known, sinusoidal regression is ordinary linear regression.

The design matrix is

and the OLS solution is . Multiple known frequencies can be stacked into one design with three columns per frequency (the constant and the two trig basis), recovering the harmonic-regression model. This is what produces the Fourier-basis representation of seasonality in classical time-series regression.

(Nyquist Limit) Only frequencies are identifiable from data sampled at rate .

A signal at frequency aliases into the range : it is indistinguishable from a signal at frequency for some integer . The cutoff is the Nyquist frequency, and is the Nyquist period, the shortest period that can be resolved at sampling rate . For monthly data ( cycle/month) the Nyquist limit is cycles/month, so the shortest detectable period is months. Any oscillation faster than that aliases into the resolvable range. Practically: a frequency grid for sinusoidal regression should never extend past , and a sampling rate should be chosen to lie above twice the highest frequency of interest in the underlying signal.

(Unknown Frequency) If must be estimated, the model is nonlinear and fit by profile least squares over a grid.

Parameterizing the unknown explicitly turns the model into a nonlinear regression. The clean way to fit it exploits that the model is linear in for any fixed : pick a fine grid , fit OLS at every grid point to get and the residual sum of squares , then select and the corresponding . This profile least squares trick reduces the nonlinear problem to a sequence of linear regressions, one per grid point, and is what every periodogram-based frequency-detection routine is doing under the hood. The resulting as a function of is, up to a constant, the negative of the periodogram.

(Multiple Frequencies) Either pre-specify a set of candidates or use sparse regularization.

When several frequencies may be present, the design grows to one constant plus two trigonometric columns per candidate frequency. Two strategies emerge. If the candidate frequencies are known (e.g., monthly seasonal harmonics at ), fit the full design by OLS. If the candidate set is large and only a few are truly active, lasso or group lasso is the right tool: it sets the inactive frequency pairs to exactly zero and recovers a sparse representation. This is the regression-side counterpart to peak-picking on the periodogram and gives more stable estimates of the active frequencies’ amplitudes.

Contents

  • 2.4.3 Time-Lagged Regression: distributed-lag (FIR) regression for identifying impulse responses between two series, with applications to neuroscience (STRF), economics, and audio.
  • 2.4.5 Time-Series Cross-Validation: rolling-origin and fixed-window CV schemes that respect chronology, the right replacement for random -fold on time-series data.

The general linear-regression machinery (OLS solution, residual variance, , Gauss-Markov, ridge, lasso, ordinary cross-validation) lives in the machine-learning regression folder: 1.2. Linear Regression, 1.2a. Multiple Linear Regression, 1.4. Nonlinear Regression, 1.5. Regularization, 1.6. Cross-Validation. Reach for those notes when the question is about regression mechanics; reach for the notes in this folder when the question is about time-series-specific features (sinusoidal models, Nyquist, distributed lags, rolling-origin CV).

Examples

Sinusoidal fit at an unknown frequency

A signal is observed for time points and is believed to contain a single sinusoidal component at unknown frequency .

Trend plus seasonal dummies

Monthly airline passenger counts over years exhibit both an upward trend and strong yearly seasonality.

Spurious regression on two random walks

Two independent random walks and are simulated. A linear regression of on is fit.

See Also