Time Series • Statistics Background for Forecasting
Time Series / P3.09 Forecast Using ARIMA

P3.09 Forecast Using ARIMA

Practical 3 Statistics Background for Forecasting

Fit a justified ARIMA to a wandering teaching series, forecast 6 steps, plot history vs forecast, and report hold-out MAE if you leave out the last 6 points.

Practical / Solution

P3.09 Forecast Using ARIMA

Problem Statement

Fit a justified ARIMA to a wandering teaching series, forecast 6 steps, plot history vs forecast, and report hold-out MAE if you leave out the last 6 points.

Learning Outcomes

  • Produce a multi-step ARIMA forecast.
  • Plot and evaluate on a time-based hold-out.

Theory

After identifying a simple ARIMA, forecasts are the model's expected future path. Intervals widen with horizon. Evaluate on later observations not used in fitting.

Dataset / Data Source

Constructed 80-point cumulative series. Teaching data.

Analysis / Program

import numpy as np import pandas as pd import matplotlib.pyplot as plt from statsmodels.tsa.arima.model import ARIMA rng = np.random.default_rng(4) y = pd.Series(np.cumsum(rng.normal(size=80))) train, test = y.iloc[:-6], y.iloc[-6:] fit = ARIMA(train, order=(0, 1, 0)).fit() fc = fit.get_forecast(steps=6) mean = fc.predicted_mean print(mean) mae = np.mean(np.abs(test.values - mean.values)) print("Hold-out MAE:", round(mae, 3)) train.plot(label="train") test.plot(label="test") mean.plot(label="forecast", style="--") plt.legend() plt.tight_layout() plt.show()

Expected Output

A six-step forecast table, hold-out MAE for this simulation, and a plot of train, test and forecast. Random-walk forecasts stay near the last train value.

Result / Interpretation

ARIMA(0,1,0) forecasts a flat line at the last level. That is correct for a pure random walk mean. MAE describes average miss on the six hold-out points of this run.

Note

A good ARIMA forecast still needs a plot and an error metric on unused dates.