Simple exponential smoothing
Today let's understand simple exponential smoothing, a way to forecast a series that has no steady climb, fall, or repeating season, using nothing more than the series' own past values.
Take Algeria's exports of goods and services, recorded by the World Bank as a percent of the country's GDP, one value a year from 1960 to 2017. Here are all 58 years of it, plotted in order.
Look at that shape. It swings between about 13 and 49 percent of GDP again and again across almost six decades, but it never settles into a steady rise or fall, and it never repeats a fixed calendar pattern. That is exactly the kind of series simple exponential smoothing forecasts.
The best guess when a series has no trend to follow
Suppose you had to guess next year's export percentage using nothing but these 58 years. Two answers come to mind immediately, and both are worth checking.
The first is to just repeat the last value, 22.64 from 2017. But that throws away every year before it, even though those 57 years still hold real information about how this series tends to move.
The second is to average all 58 years and use that number every time. That is wrong in a different way: it treats 1960 and 2017 as equally relevant to a forecast for 2018, when the recent years are clearly the better guide to what happens next.
Build Algeria's 58 years of exports as a tsibble, a tidyverse table indexed by time, then compute the two candidates side by side.
The two candidates sit far apart, and neither one uses the data well. Simple exponential smoothing sits between them: it uses every one of the 58 years, but it does not weigh them all the same. Recent years count for more, and older years count for less.
The weighted-average view: weights that fade geometrically
There is another way to picture what simple exponential smoothing does: write the forecast out as one weighted average of every year that came before it.
\[ \hat{y}_{T+1|T} = \alpha y_T + \alpha(1-\alpha) y_{T-1} + \alpha(1-\alpha)^2 y_{T-2} + \cdots \]
Here \(\alpha\) is the smoothing parameter, a number between 0 and 1 that the model fits to the data. It sets how fast the weight on each year fades as you move back in time: the most recent year, \(y_T\), gets weight \(\alpha\); the year before it gets weight \(\alpha(1-\alpha)\); the year before that gets \(\alpha(1-\alpha)^2\), and so on, each weight a little smaller than the one before it.
This series' own \(\alpha\), fit formally in a moment, comes out to 0.8399875. Plug that into the weights and see how fast they fall off.
The most recent year alone gets 84% of the total weight. Add the year before it and you are already at 97.44%. Add up just the four most recent years and you reach 99.93% of the total; every year before that contributes barely a rounding error.
Because \(\alpha\) is close to 1 for this series, its forecast leans almost entirely on the last one or two years and barely remembers the rest of its 58-year history. A smaller \(\alpha\) would make these same weights fade more slowly, spreading credit across many more years instead.
The level equation: one step of the recursion by hand
Adding up an infinite weighted sum by hand is not how software actually computes a simple exponential smoothing forecast. There is a shortcut: the same numbers come out of a recursion instead, a formula that reuses its own previous output as the input to the next one.
\[ l_t = \alpha y_t + (1 - \alpha) l_{t-1} \]
\(l_t\) is called the level: the model's best estimate of where the series sits, updated after seeing year \(t\)'s real value. \(l_{t-1}\) is last year's level, and \(y_t\) is this year's observation. Each new level blends the two, \(\alpha\)'s share of the new observation and \((1-\alpha)\)'s share of the old level. Once you have a year's level, the forecast for the following year is just that level; that is the whole model.
Every recursion needs a starting point before the first real year, called l[0], the level's value before any data arrives. This series' own l[0], fit at the same time as \(\alpha\), is 39.539.
Starting from l[0] = 39.539, work out the level after 1960 and after 1961 by hand.
The level after 1960, 39.12, sits close to l[0], 39.539, because that year's observation, 39.04, was itself already close to 39.539, so blending the two barely moves it. The level after 1961 tells a clearer story: the observation jumps to 46.24, and because \(\alpha\) is high, the new level, 45.10, follows that jump most of the way, leaving only a small trace of the old level, 39.12.
Fitting SES with ETS() in fable
Simple exponential smoothing is commonly abbreviated SES, and fable's function for fitting it, along with every other member of the exponential smoothing family, is ETS(). The three arguments name the model's three parts: error("A") picks an additive error, trend("N") says there is no trend component, and season("N") says there is no seasonal component. Simple exponential smoothing is exactly this combination, a level with no trend and no season, which fable's report() calls ETS(A,N,N).
Fit that exact model to Algeria's 58 years and read its two fitted numbers, \(\alpha\) and l[0], straight out of report().
alpha comes back as 0.8399875 and l[0] as 39.539, the exact numbers the hand computation already used. model() searches over every possible \(\alpha\) and l[0] and settles on the pair whose one-step-ahead forecasts track the real 58 years most closely; report() is just reading those two numbers back out.
Because l[0] is the very first level, before any real year has updated it, the model's very first fitted value, for 1960, is just l[0] itself.
The fitted value for 1960, 39.54, is l[0] rounded, and the residual, -0.5, is just 39.04 minus 39.54: the model's one honest miss before it has seen anything real to update on. Three ways of looking at the same model now agree with each other: the weighted average, the level recursion computed by hand, and this real fit all land on \(\alpha\) = 0.84 and the same fitted numbers. That is simple exponential smoothing: one smoothing parameter, one running level, fit by search instead of guesswork.
Turning the alpha dial: what large and small values do
What \(\alpha\) actually controls is easiest to see on a plain curve, away from Algeria's numbers for a moment.
This widget fits its own built-in curve, not Algeria's exports, but the same trade-off applies to any smoothing parameter, including \(\alpha\) here. Drag the slider from stiff to wiggly. A stiff line changes very little from one point to the next, the way a low \(\alpha\) keeps the level anchored to old history and barely reacts to a new observation. A wiggly line chases every bump in the data, the way an \(\alpha\) near 1 lets the level jump almost all the way to whatever value just arrived.
See that difference in real numbers by fitting this same series twice, once with \(\alpha\) forced down to 0.2 instead of left to search.
alpha sits inside trend() in that code, not error(), even though this model has no trend at all. That is just where fable's ETS() syntax happens to expose the level's smoothing parameter.With \(\alpha\) pinned to 0.2, the starting level comes out at 30.32, and by 2017 the level has only crept down to 29.57, nowhere near the real recent fall to 20.86 and 22.64. This series' own fitted \(\alpha\), 0.84, gets there: its 2017 level lands at 22.44, tracking that fall closely.
Quick check: what alpha changes
Why the forecast is flat beyond the last data point
Once the model has a level for every one of the 58 years, forecasting the future comes down to one rule.
\[ \hat{y}_{T+h|T} = l_T \quad \text{for every } h = 1, 2, 3, \ldots \]
\(l_T\) is the level after the last real observation, 2017's level. The forecast for every future year, \(h\) steps past 2017, is just that one number, no matter how far out \(h\) reaches. Nothing in the model updates \(l_T\) once the data runs out: the level equation only fires when a new observation arrives, and trend("N") means there is no slope term sitting underneath the level to keep pushing it up or down on its own.
Forecast five years past 2017 and check that the forecast actually repeats the same number five times.
All five years get 22.44, the same number as 2017's fitted level. Whether \(h\) is 1 or 5 makes no difference: with no trend to keep moving the level along, the best guess for every future year is exactly where the level stood at the end of the real data.
The level path the model actually estimated
This is the same 58 years from the very first chart, but now plotted as the model's estimated level instead of the raw data itself.
Toggle between line and point. The level path moves far more gently than the raw series did at the start: it dips to 21.43 by 2016 and closes at 22.44 in 2017, the same number the forecast repeats for every year after it.
That flatter path is simple exponential smoothing's whole job: turn a series that jumps around across more than 30 percentage points into one slow-moving number you can actually forecast from.
Quiz: reading the fitted level and its forecast
Your turn: fit SES and read its forecast
alg still holds all 58 years of Algeria's exports from earlier in this lesson. Fit the same ETS(A,N,N) model on it and forecast 5 years ahead.
Show answer
# Fit ETS(A,N,N) on alg, then forecast five years ahead
fit <- alg |>
model(ETS(Exports ~ error("A") + trend("N") + season("N")))
forecast(fit, h = 5) |>
as.data.frame() |>
transmute(Year, forecast = round(.mean, 2))
#> Year forecast
#> 1 2018 22.44
#> 2 2019 22.44
#> 3 2020 22.44
#> 4 2021 22.44
#> 5 2022 22.44References
- Forecasting: Principles and Practice, section 8.1, Simple exponential smoothing - Hyndman and Athanasopoulos (3rd ed.), the source for the weighted-average and recursive forms used in this lesson.
- Forecasting seasonals and trends by exponentially weighted moving averages - Holt, C.E. (1957), reprinted (2004) in International Journal of Forecasting, 20(1), 5-10.
- A state space framework for automatic forecasting using exponential smoothing methods00110-8) - Hyndman, Koehler, Snyder and Grose (2002), International Journal of Forecasting, 18(3), 439-454.
- fable package reference documentation for ETS()
- tsibbledata package reference documentation for global_economy - the World Bank national accounts data used throughout this lesson.
What simple exponential smoothing gives you
You can now write simple exponential smoothing as a weighted average of every past value, its weights fading by \((1-\alpha)\) each step back, and explain what a high or low alpha does to that fade.
You can also compute the same forecast a second way, one running update, \(l_t = \alpha y_t + (1-\alpha) l_{t-1}\), and read a fitted level and its consequence straight off real ETS() output.
And you can fit ETS(Exports ~ error("A") + trend("N") + season("N")) in fable yourself and forecast from it, knowing why that forecast stays exactly flat: no trend term means nothing keeps pushing the level once the real data stops.
The next part in this course adds a trend component to the model, so that flat forecast starts moving again.