TSF Study DeskUnit 1 + Unit 2

Building Forecasting Models

A model needs relevant history. Very little data gives unreliable forecasts; very old data may describe a market that no longer exists. Forecast range depends on business purpose and data availability.

RangeTypical horizonUse
Short termDays to monthsRostering, inventory, daily operations.
Medium termMonths to a few yearsHiring, capacity, route adjustment.
Long termSeveral yearsStrategic planning and large investments.
Very long-range forecasts are fragile because they assume future conditions change gradually. Sudden shocks can make past patterns unusable.

Train-Test Split for Time Series

In ordinary machine learning, test rows are often chosen randomly. In time series, the test set must be the most recent portion because forecasting always predicts forward.

  1. Sort observations by time.
  2. Use the older portion for training.
  3. Hold out the latest portion for testing.
  4. If seasonality exists, keep at least one complete season in the test set.
  5. After selecting the model, refit using all available data before forecasting the future.

Measures of Forecast Accuracy

Accuracy is measured by comparing actual values yt with forecast values y_hat_t on the test period.

Error: et = yt - y_hat_t
MAE = average(|et|)
MSE = average(et^2)
RMSE = sqrt(MSE)
MAPE = average(|et / yt|) x 100
Lower error usually means a better forecast, but compare models on the same test period.

Simple Forecasting Methods

MethodForecast for next periodBest forWeakness
Naive forecastUse the latest observation: y_hat_(t+1) = yt.Baseline, random walk-like data.Ignores all older observations.
Average forecastAverage of all observations.Stable series with no trend or seasonality.Slow to adapt to recent change.
Moving average forecastAverage of the latest n observations.Smoothing short-term noise.Lags behind trend and struggles with seasonality.

Moving Average Forecast

A moving average takes the average over a fixed-width window and moves that window one time point at a time. A larger window gives stronger smoothing but more lag.

Simple MA forecast: y_hat_(t+1) = (yt + y_(t-1) + ... + y_(t-n+1)) / n

How to calculate

  1. Choose window size n.
  2. Add n consecutive observations.
  3. Divide by n.
  4. Move the window by one period and repeat.
  5. For forecasting, the next forecast uses the most recent n actual observations.

Limitations

  • Gives equal weight to all observations inside the window.
  • Ignores all observations outside the window.
  • Can mislead when trend or seasonality is strong.
  • Larger n smooths more but reacts more slowly.

Odd and Even Period Moving Averages

For odd window sizes, the moving average naturally belongs to the center period. For even window sizes, the first average lies between two periods, so you must center it by averaging adjacent moving averages.

Odd n, such as 3, 5, 7

A 3-year moving average of 1991, 1992, 1993 is placed at 1992. A 5-year moving average from 1991 to 1995 is placed at 1993.

Even n, such as 4

Compute 4-year moving averages first. Then average two neighboring 4-year values to get a centered value that aligns with an actual year.

Centered MA for even n = (raw MA_i + raw MA_(i+1)) / 2

Simple Exponential Smoothing

Exponential smoothing is a weighted moving average idea where recent observations receive more weight and older observations receive exponentially smaller weights. The smoothing parameter alpha lies between 0 and 1.

SES: y_hat_(t+1) = y_hat_t + alpha(yt - y_hat_t)
Alpha valueBehaviorUse
Near 1Forecast reacts strongly to latest observation.When recent changes are important.
Near 0Forecast changes slowly.When noise is high and the level is stable.
SES is for data with no clear trend and no clear seasonality. If trend exists, use Holt's method instead.

Double Exponential Smoothing: Holt Method

Holt's linear trend method extends SES by estimating two components: level and trend. It is used when the data has trend but no seasonality.

Level: Lt = alpha yt + (1 - alpha)(L_(t-1) + B_(t-1))
Trend: Bt = beta(Lt - L_(t-1)) + (1 - beta)B_(t-1)
Forecast: F_(t+h) = Lt + hBt

Alpha smooths the level; beta smooths the trend. A common exam explanation is: level captures the current baseline, trend captures the slope.

Triple Exponential Smoothing: Holt-Winters

Holt-Winters adds a seasonal component. It is used when the series has both trend and seasonality. It can be additive or multiplicative depending on the seasonal amplitude.

Components: level Lt, trend Bt, seasonal index St
Additive forecast idea: trend forecast + seasonal effect
Multiplicative forecast idea: trend forecast x seasonal index

Choosing a Forecasting Method

Pattern in dataSuitable methodReason
No trend, no seasonalityAverage forecast, moving average, SESOnly level needs to be estimated.
Trend, no seasonalityHolt / double exponential smoothingNeeds level and trend.
Seasonality, no major trendSeasonal indices with level smoothingNeeds repeating seasonal pattern.
Trend and seasonalityHolt-WintersNeeds level, trend, and seasonal component.
Mini worked moving-average example

For values 102, 105, 114, 110, 108, 116, 112, the first 3-year MA is (102 + 105 + 114) / 3 = 107. The full 3-year MA sequence is 107.00, 109.67, 110.67, 111.33, 112.00.