Time Series • Introduction to Autoregressive Models and Forecasting
Time Series / P4.05 Residual Adequacy Checks

P4.05 Residual Adequacy Checks

Practical 4 Introduction to Autoregressive Models and Forecasting

After fitting the sales-on-time regression, plot residuals against time, inspect residual ACF, and decide whether ordinary OLS looks adequate.

Practical / Solution

P4.05 Residual Adequacy Checks

Problem Statement

After fitting the sales-on-time regression, plot residuals against time, inspect residual ACF, and decide whether ordinary OLS looks adequate.

Learning Outcomes

  • Plot residuals versus time.
  • Look for leftover pattern or autocorrelation.
  • Conclude adequacy cautiously.

Theory

Adequacy checking asks whether residuals look like unstructured noise. A trend left in residuals means the mean model is incomplete. A residual ACF spike means errors are dependent, so OLS t-tests are doubtful and a time-series error model or GLS may be needed. Residual plots do not prove a model is true; they can show it is incomplete.

Dataset / Data Source

Same 24-month sales series. Optional comparison: a series with leftover sine seasonality.

Analysis / Program

import numpy as np import pandas as pd import matplotlib.pyplot as plt import statsmodels.api as sm from statsmodels.graphics.tsaplots import plot_acf t = np.arange(24) sales = 80 + 1.5 * t + np.array([ 2, -1, 3, 0, -2, 4, 1, -3, 2, 0, -1, 3, 1, -2, 2, 0, 1, -1, 3, -2, 0, 2, -1, 1 ]) fit = sm.OLS(sales, sm.add_constant(t)).fit() resid = pd.Series(fit.resid) fig, axes = plt.subplots(1, 2, figsize=(9, 4)) resid.plot(ax=axes[0], marker="o", title="Residuals vs time") axes[0].axhline(0, color="gray") plot_acf(resid, ax=axes[1], title="Residual ACF") plt.tight_layout() plt.show() print("Residual mean:", round(resid.mean(), 4))

Expected Output

A residual time plot centred near zero and an ACF plot. For this almost-linear construction, leftover ACF should be weaker than in a strongly seasonal leftover example. Describe the pattern you see; do not invent a Durbin–Watson number unless you compute it.

Result / Interpretation

If residuals wander or the ACF stays large, the linear trend is not a complete time-series model. OLS may still be a useful trend summary, but inference and short-term forecasts need a better error structure.

Note

Always inspect residuals. Ordinary regression does not automatically solve autocorrelation.