◢◤ ARKANE_
SYS_TIME UTC+0
Work with me
/W15

实验Lab: Forecast, and beat the naive baseline

week 15
Dataset
Mauna Loa CO₂, weekly 1958 to 2001 (ships with statsmodels)
Time
3 hours

Capstone Due this week: Capstone final: notebook, report, and a five-minute talk.

This week you'll be able to

  • Decompose a series into trend, seasonality, and residual, and test for stationarity.
  • Fit exponential smoothing and ARIMA, and forecast with prediction intervals.
  • Evaluate forecasts on a time-ordered split against a naive baseline, with MAE and MASE.

Goal

Forecast a real series with trend and seasonality. Test stationarity, fit classical models, and prove they beat a naive forecast on a time-ordered split.

Data

Weekly atmospheric CO₂ at Mauna Loa Observatory, in parts per million. Data from the US National Oceanic and Atmospheric Administration (NOAA), bundled with statsmodels.

import statsmodels.api as sm

co2 = sm.datasets.co2.load_pandas().data["co2"]
co2 = co2.resample("MS").mean().interpolate()  # 59 weeks are missing. Monthly means smooth the gaps.

Tasks

  1. Plot the series. Describe the trend and the seasonal pattern in two sentences.

  2. Split by time (Procedure 20.1): train up to the end of 1997, test from 1998.

  3. Decompose the training series with STL. Is the seasonal swing additive or multiplicative?

  4. Run the ADF test on the raw series, then on first differences, then on seasonal differences (Procedure 20.2). What differencing does it need?

  5. Read the ACF and PACF of the differenced series. Choose SARIMA orders (Procedure 20.3). Fit the model.

  6. Fit Holt-Winters exponential smoothing as well.

  7. Build two naive baselines: repeat the last value, and repeat last year's value for the same month.

  8. Forecast the test period with all four. Report MAE and MASE (Procedure 20.4). Which models beat the seasonal naive forecast?

    MASE isn't in the chapter. It divides your forecast's MAE by the MAE of a one-step naive forecast on the training data. Under 1 means your errors are smaller than that baseline's. Hyndman and Koehler (2006), on the extended reading list, introduced it.

  9. Plot the SARIMA forecast with its 95% interval. How wide is the interval at one month and at four years?

Deliverable

A notebook with the decomposition, the stationarity tests, a results table for all four forecasts, and the interval plot.

Done when

  • Nothing from 1998 onwards is used in fitting.
  • Every model is compared with both naive baselines.
  • Errors are reported with MASE as well as MAE.

Capstone

Your capstone final is due this week. See the capstone brief.

Stretch

Run time-series cross-validation (Procedure 13.3) with an expanding window and 12-month horizons. Does the model ranking hold across folds?

online /teaching/semester-1/labs/15 Newcastle, UK v0.1.0 // rss