ETS (Exponential Smoothing) › Example: Forecasting Monthly Sales

Michael BrenndoerferAugust 8, 20258 min read
Machine Learning from ScratchAll chapters
Part 8 of 9Time Series
Chapter 57ETS (Exponential Smoothing) › Example: Forecasting Monthly Sales
Reading section 4 of 8 · Example: Forecasting Monthly Sales · 8 minSection 4 of 8 · 8 min

Book contents

Section 4 of 8 · 8 min read

ETS (Exponential Smoothing) › Example: Forecasting Monthly SalesOne section · Sections in this chapter4 / 8 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Let's work through a detailed, step-by-step example that demonstrates exponential smoothing in action. This hands-on walkthrough will help you understand exactly how the method processes data and generates forecasts.

The scenario: You're managing a retail store and need to forecast next month's sales to plan inventory. You have 10 months of historical sales data showing a clear upward trend. Let's see how exponential smoothing can help you make this forecast.

Given Data (Monthly Sales in thousands of dollars):

MonthSalesMonthSales
11006120
21057125
31108130
41159135
511810140

Looking at this data, we can see sales are increasing steadily, from 100 in month 1 to 140 in month 10. This upward trend is exactly the kind of pattern where exponential smoothing can be effective, though we'll use simple exponential smoothing here to keep the example clear (in practice, you might use Holt's method for this trending data).

Step 1: Initialize the forecast

Before we can start applying the exponential smoothing formula, we need an initial forecast for the first period. Since we have no prior data to work with, a common approach is to use the first observation as the initial forecast:

y^1=y1=100\hat{y}_1 = y_1 = 100

This initialization assumes that the first observation is our best guess for what the forecast would have been. In practice, there are other initialization methods (like using the average of the first few observations), but using the first observation is simple and often works well.

Step 2: Choose the smoothing parameter

The choice of α\alpha is important. For this example, let's use α=0.3\alpha = 0.3. This means:

  • 30% weight goes to the current observation (we're moderately responsive to new data)
  • 70% weight goes to the previous forecast (we maintain stability from historical patterns)

This moderate value is a good starting point for data with a trend, as it balances responsiveness to the upward movement with stability against random fluctuations. In practice, you might try different values and choose the one that minimizes forecast errors.

Step 3: Calculate forecasts using the exponential smoothing formula

Now we'll apply the formula recursively: y^t+1=αyt+(1−α)y^t\hat{y}_{t+1} = \alpha y_t + (1-\alpha) \hat{y}_t

Let's trace through each calculation to see exactly how the method works:

Month 2: We forecast month 2 using month 1's actual sales and our initial forecast:

y^2=αy1+(1−α)y^1=0.3×100+0.7×100=30+70=100\hat{y}_2 = \alpha y_1 + (1-\alpha) \hat{y}_1 = 0.3 \times 100 + 0.7 \times 100 = 30 + 70 = 100

where α=0.3\alpha = 0.3 and y1=y^1=100y_1 = \hat{y}_1 = 100.

Since both the actual value and initial forecast were 100, the forecast remains 100. Notice that the actual sales in month 2 were 105, so our forecast of 100 was too low by 5 units.

Month 3: Now we use month 2's actual sales (105) and our previous forecast (100):

y^3=αy2+(1−α)y^2=0.3×105+0.7×100=31.5+70=101.5\hat{y}_3 = \alpha y_2 + (1-\alpha) \hat{y}_2 = 0.3 \times 105 + 0.7 \times 100 = 31.5 + 70 = 101.5

where y2=105y_2 = 105 and y^2=100\hat{y}_2 = 100.

The forecast increases slightly to 101.5. The 30% weight on the higher actual value pulls the forecast up, but the 70% weight on the previous forecast keeps it relatively stable. The actual sales in month 3 were 110.

Month 4: Continuing the pattern:

y^4=αy3+(1−α)y^3=0.3×110+0.7×101.5=33+71.05=104.05\hat{y}_4 = \alpha y_3 + (1-\alpha) \hat{y}_3 = 0.3 \times 110 + 0.7 \times 101.5 = 33 + 71.05 = 104.05

where y3=110y_3 = 110 and y^3=101.5\hat{y}_3 = 101.5.

The forecast continues to increase, gradually catching up to the upward trend. Notice how each new observation pulls the forecast upward, but the method maintains stability by giving substantial weight to the previous forecast.

Month 5:

y^5=αy4+(1−α)y^4=0.3×115+0.7×104.05=34.5+72.835=107.335\hat{y}_5 = \alpha y_4 + (1-\alpha) \hat{y}_4 = 0.3 \times 115 + 0.7 \times 104.05 = 34.5 + 72.835 = 107.335

Month 6:

y^6=αy5+(1−α)y^5=0.3×118+0.7×107.335=35.4+75.135=110.535\hat{y}_6 = \alpha y_5 + (1-\alpha) \hat{y}_5 = 0.3 \times 118 + 0.7 \times 107.335 = 35.4 + 75.135 = 110.535

Month 7:

y^7=αy6+(1−α)y^6=0.3×120+0.7×110.535=36+77.375=113.375\hat{y}_7 = \alpha y_6 + (1-\alpha) \hat{y}_6 = 0.3 \times 120 + 0.7 \times 110.535 = 36 + 77.375 = 113.375

Month 8:

y^8=αy7+(1−α)y^7=0.3×125+0.7×113.375=37.5+79.363=116.863\hat{y}_8 = \alpha y_7 + (1-\alpha) \hat{y}_7 = 0.3 \times 125 + 0.7 \times 113.375 = 37.5 + 79.363 = 116.863

Month 9:

y^9=αy8+(1−α)y^8=0.3×130+0.7×116.863=39+81.804=120.804\hat{y}_9 = \alpha y_8 + (1-\alpha) \hat{y}_8 = 0.3 \times 130 + 0.7 \times 116.863 = 39 + 81.804 = 120.804

Month 10:

y^10=αy9+(1−α)y^9=0.3×135+0.7×120.804=40.5+84.563=125.063\hat{y}_{10} = \alpha y_9 + (1-\alpha) \hat{y}_9 = 0.3 \times 135 + 0.7 \times 120.804 = 40.5 + 84.563 = 125.063

Observing the pattern: Notice how the forecasts gradually increase over time, tracking the upward trend in the data. The method is "learning" from each new observation, adjusting the forecast upward as it sees consistently higher sales. However, because α=0.3\alpha = 0.3 gives only 30% weight to new observations, the forecasts lag behind the actual values. This is the characteristic behavior of simple exponential smoothing on trending data.

Step 4: Calculate the forecast for Month 11

Now we can forecast the next month (month 11) using month 10's actual sales:

y^11=αy10+(1−α)y^10=0.3×140+0.7×125.063=42+87.544=129.544\hat{y}_{11} = \alpha y_{10} + (1-\alpha) \hat{y}_{10} = 0.3 \times 140 + 0.7 \times 125.063 = 42 + 87.544 = 129.544

Our forecast for month 11 is 129.544 thousand dollars. This forecast incorporates all the historical information through the recursive formula, with recent observations (especially month 10's sales of 140) having the most influence.

Step 5: Calculate forecast errors and evaluate performance

To assess how well our model performed, we need to measure the forecast errors. Let's calculate the error for each period where we made a forecast:

| Month | Actual | Forecast | Error | |Error| | Error² | |-------|--------|----------|-------|-------|--------| | 2 | 105 | 100.000 | 5.000 | 5.000 | 25.000 | | 3 | 110 | 101.500 | 8.500 | 8.500 | 72.250 | | 4 | 115 | 104.050 | 10.950| 10.950| 119.903| | 5 | 118 | 107.335 | 10.665| 10.665| 113.742| | 6 | 120 | 110.535 | 9.465 | 9.465 | 89.586 | | 7 | 125 | 113.375 | 11.625| 11.625| 135.141| | 8 | 130 | 116.863 | 13.137| 13.137| 172.581| | 9 | 135 | 120.804 | 14.196| 14.196| 201.526| | 10 | 140 | 125.063 | 14.937| 14.937| 223.114|

Understanding the errors: Notice that all errors are positive, meaning we consistently under-forecasted. This is exactly what we'd expect with simple exponential smoothing on trending data because the method lags behind the upward trend. The errors also increase over time, which reflects that the gap between the forecast and actual values widens as the trend continues.

Calculating summary metrics:

Mean Absolute Error (MAE):

MAE=1n∑t=210∣yt−y^t∣=19∑t=210∣yt−y^t∣=5.000+8.500+10.950+10.665+9.465+11.625+13.137+14.196+14.9379=10.941\begin{align*} MAE &= \frac{1}{n} \sum_{t=2}^{10} |y_t - \hat{y}_t| \\ &= \frac{1}{9} \sum_{t=2}^{10} |y_t - \hat{y}_t| \\ &= \frac{5.000 + 8.500 + 10.950 + 10.665 + 9.465 + 11.625 + 13.137 + 14.196 + 14.937}{9} \\ &= 10.941 \end{align*}

where n=9n = 9 is the number of forecast periods (months 2 through 10), yty_t is the actual value at time tt, and y^t\hat{y}_t is the forecast for time tt.

The MAE of 10.941 tells us that, on average, our forecasts were off by about 10.9 thousand dollars. This is a straightforward measure that treats all errors equally.

Mean Squared Error (MSE):

MSE=1n∑t=210(yt−y^t)2=19∑t=210(yt−y^t)2=25.000+72.250+119.903+113.742+89.586+135.141+172.581+201.526+223.1149=127.316\begin{align*} MSE &= \frac{1}{n} \sum_{t=2}^{10} (y_t - \hat{y}_t)^2 \\ &= \frac{1}{9} \sum_{t=2}^{10} (y_t - \hat{y}_t)^2 \\ &= \frac{25.000 + 72.250 + 119.903 + 113.742 + 89.586 + 135.141 + 172.581 + 201.526 + 223.114}{9} \\ &= 127.316 \\ \end{align*}

where n=9n = 9 is the number of forecast periods, yty_t is the actual value at time tt, and y^t\hat{y}_t is the forecast for time tt. The MSE penalizes larger errors more heavily than smaller ones because it squares the forecast errors.

The MSE of 127.316 penalizes larger errors more heavily. Since our errors increase over time, the MSE is higher than it would be if errors were more evenly distributed.

Step 6: Interpret the results

The exponential smoothing model with α=0.3\alpha = 0.3 produces a forecast of 129.544 thousand dollars for Month 11.

What the forecast tells us:

  • The model has learned from the historical upward trend and projects it forward
  • The forecast of 129.544 is higher than month 10's forecast (125.063), showing the continued upward movement
  • However, it's lower than month 10's actual sales (140), showing the lag characteristic of simple exponential smoothing on trending data

What the errors tell us:

  • The MAE of 10.941 indicates that, on average, forecasts are off by about 10.9 thousand dollars
  • Relative to sales levels around 100-140, this represents approximately 8-9% error
  • The consistent positive errors suggest we might benefit from using Holt's method (double exponential smoothing) to better capture the trend

Key insights from this example:

  1. Exponential smoothing gradually adapts to trends, but with a lag
  2. The recursive formula efficiently incorporates all historical information
  3. The smoothing parameter α\alpha controls the balance between responsiveness and stability
  4. Error analysis reveals systematic patterns (like consistent under-forecasting) that can guide model improvement

This example demonstrates exponential smoothing in action, showing how the method processes data step-by-step to create forecasts that balance recent observations with historical patterns.