Adjusting for Autocorrelated Errors in Neural Networks for Time Series

Fan-Keng Sun, Christopher I. Lang, Duane S. Boning

TL;DR

Standard neural network training for time series assumes that prediction errors are completely independent over time. In reality, omitted variables and model misspecifications frequently cause errors to be autocorrelated (dependent on past errors), leading to suboptimal models. This paper introduces a simple yet powerful fix: treating the autocorrelation coefficient as a trainable parameter and optimizing it jointly with the network's weights via gradient descent, consistently boosting performance across a massive benchmark of real-world datasets.

What Problem Does This Paper Address?

When training neural networks for time series forecasting via standard Maximum Likelihood Estimation (MLE) or Mean Squared Error (MSE) loss, we implicitly assume that the errors made at different time steps are uncorrelated. However, this assumption rarely holds true in practice due to three main factors:

  1. Omitted Influential Variables: Real-world datasets often lack crucial contextual variables (e.g., missing temperature data when predicting electricity consumption).
  2. Measurement Errors: Sensor drift, calibration issues, and environmental noise naturally create temporally correlated errors.
  3. Model Misspecification: No neural network is a perfect representation of the true underlying data-generating process.

When these factors interact with the temporal nature of the data, the resulting errors become autocorrelated. In classical econometrics, ignoring this issue leads to severely underestimated standard errors and poor predictions. While linear models have long-established fixes for this, standard deep learning frameworks completely ignore error autocorrelation, leading to degraded predictive accuracy.

Methods

Econometricians typically use iterative, alternating optimization methods (like the Cochrane-Orcutt or Prais-Winsten methods) to fix autocorrelated errors. However, the authors demonstrate that this naive approach fails for neural networks because coordinate descent easily gets trapped in poor local minima.

Instead, the authors propose joint optimization via Stochastic Gradient Descent (SGD). They treat the first-order autocorrelation coefficient ($\hat{\rho}$) as a differentiable, trainable parameter. They re-formulate the network to predict an adjusted target using adjusted historical inputs:

$$X_t - \hat{\rho}X_{t-1} = f(X_{t-1} - \hat{\rho}X_{t-2}, \dots, X_{t-W} - \hat{\rho}X_{t-W-1}; \theta)$$

To ensure stability and prevent the model from exploding, they constrain the magnitude of the coefficient ($|\hat{\rho}| < 1$) using a $\tanh$ transformation. By optimizing $\hat{\rho}$ and the network parameters ($\theta$) simultaneously, the network learns to natively correct its own temporal error patterns during standard backpropagation.

Datasets

The authors evaluated their method across an extensive suite of real-world benchmarks:

  • Traffic: PeMSD4, PeMSD8, and California freeway occupancy rates.
  • Manufacturing: ADI-920 and ADI-945 (sensor logs from semiconductor plasma etchers).
  • M4 & M5 Competitions: Hourly, Daily, Weekly, Monthly, Quarterly, and Yearly subsets, alongside Walmart sales data.
  • Miscellaneous: Air-quality, Electricity consumption, Exchange rates, and Solar power production.

They also extended their evaluation beyond forecasting to synthetic datasets for time series regression, the Baydogan archive for time series classification, and manufacturing datasets (including CWRU Bearing and Chiron Mill) for unsupervised anomaly detection.

Key Insights and Ideas

  • The Expressivity Trade-off: The authors discovered a fascinating link between model capacity and error autocorrelation. As a neural network's capacity increases (e.g., adding more layers or hidden units to an LSTM), the model naturally absorbs more temporal patterns, which reduces the remaining error autocorrelation ($\hat{\rho}$ drops). Consequently, the benefit of this adjustment is highest for simpler or slightly misspecified models, though it still provides a edge to state-of-the-art architectures.
Figure 3: Results of training LSTM on the Traffic dataset with different numbers of lay- ers and hidden units averaged over 30 runs us- ing both the w/o and w/ methods. In the upper right subfigure, y-axis is the relative improve- ment of using w/ over w/o.
  • SGD Beats Grid Search: Jointly training $\hat{\rho}$ and $\theta$ allows the model to find better global solutions than traditional econometric grid-search or coordinate descent methods, which often settle for suboptimal parameters.
Figure 2: RRMSE of four combinations of models and datasets averaged over 20 runs when ˆρ ∈[−1, 1] is fixed. Orange dots are the results when ˆρ is not fixed and is instead learned jointly with model parameter θ.
  • Empirical Diagnostics for Deep Learning: Because classical statistical tests (like the Durbin-Watson statistic) don't easily translate to deep learning, the authors established empirical critical values (0.984 for 1%, 0.928 for 5%, 0.857 for 10% significance). If an unadjusted model shows a remaining error autocorrelation above 0.928, there is a 95% chance that applying this adjustment will improve performance.
Figure 1: Scatter plot of all runs in Section 5.4 and its density plot in the x-dimension. “w/o” implies without adjustment for autocorrelated errors, whereas “w/” implies with adjustment. Runs that have a larger than 10% relative improvement are considered as outliers and thus excluded. The solid lines in the scatter plot are regression lines of the corresponding methods and the dashed lines in the density plot are the critical values for 10%, 5%, and 1% right-tailed probabilities of the w/o method.

Key Results

The method was rigorously tested across 6 diverse architectures (LSTM, TPA, AGCRN, TCN, Conv-T, and DSANet).

As shown in the comprehensive results table below, the adjustment improved performance in almost all dataset-model combinations:

  • The relative improvement was most dramatic for standard architectures like LSTM (32.4% average relative improvement) and TCN (25.3%).
  • Highly specialized models like DSANet still achieved a solid 7.12% average improvement.
  • Beyond forecasting, the method consistently maintained or boosted accuracy in time series classification (up to 0.81% average improvement) and unsupervised anomaly detection (1.15% average accuracy boost).
Comprehensive forecasting results table

Limitations and Future Work

  • Linear AR(1) Assumption: The current formulation focuses strictly on linear, first-order autocorrelation ($AR(1)$). While it can be extended to higher orders, it does not natively handle complex, non-linear error dependencies.
  • Probabilistic Forecasting: The method minimizes MSE (equivalent to Gaussian MLE) and is not directly applicable out-of-the-box to models that output complex probabilistic distributions or non-Gaussian error structures without changing the underlying loss function.
  • Future Directions: The authors point toward exploring higher-order autocorrelated errors, quantile regression, and integration with probabilistic forecasting frameworks as promising next steps.

Summary updated

BibTeX
@inproceedings{sun2021adjusting,
  author = {Fan-Keng Sun and Christopher I. Lang and Duane S. Boning},
  title = {{Adjusting for Autocorrelated Errors in Neural Networks for Time Series}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
}
Figure