Unit 2
Moving Average and Smoothing Forecasts
This unit is formula-heavy. Learn the decision rule first, then the computation: no pattern, trend, seasonality, or trend plus seasonality.
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.
| Range | Typical horizon | Use |
|---|---|---|
| Short term | Days to months | Rostering, inventory, daily operations. |
| Medium term | Months to a few years | Hiring, capacity, route adjustment. |
| Long term | Several years | Strategic planning and large investments. |
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.
- Sort observations by time.
- Use the older portion for training.
- Hold out the latest portion for testing.
- If seasonality exists, keep at least one complete season in the test set.
- 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_tMAE = average(|et|)MSE = average(et^2)RMSE = sqrt(MSE)MAPE = average(|et / yt|) x 100Simple Forecasting Methods
| Method | Forecast for next period | Best for | Weakness |
|---|---|---|---|
| Naive forecast | Use the latest observation: y_hat_(t+1) = yt. | Baseline, random walk-like data. | Ignores all older observations. |
| Average forecast | Average of all observations. | Stable series with no trend or seasonality. | Slow to adapt to recent change. |
| Moving average forecast | Average 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
- Choose window size n.
- Add n consecutive observations.
- Divide by n.
- Move the window by one period and repeat.
- 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 value | Behavior | Use |
|---|---|---|
| Near 1 | Forecast reacts strongly to latest observation. | When recent changes are important. |
| Near 0 | Forecast changes slowly. | When noise is high and the level is stable. |
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 + hBtAlpha 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 StAdditive forecast idea: trend forecast + seasonal effectMultiplicative forecast idea: trend forecast x seasonal indexChoosing a Forecasting Method
| Pattern in data | Suitable method | Reason |
|---|---|---|
| No trend, no seasonality | Average forecast, moving average, SES | Only level needs to be estimated. |
| Trend, no seasonality | Holt / double exponential smoothing | Needs level and trend. |
| Seasonality, no major trend | Seasonal indices with level smoothing | Needs repeating seasonal pattern. |
| Trend and seasonality | Holt-Winters | Needs 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.