Step-by-step guide on using the AutoETS Model
with Statsforecast
.
Ord, Koehler
, and
Snyder (1997), Hyndman, Koehler, Snyder, and Grose (2002)
and
Hyndman, Koehler, Ord
, and Snyder (2005b)
have shown that all
exponential smoothing methods (including non-linear methods) are optimal
forecasts from innovations state space models.
Exponential smoothing methods were originally classified by
Pegels’ (1969) taxonomy
. This was later extended by
Gardner (1985), modified by Hyndman et al. (2002)
, and extended again
by Taylor (2003)
, giving a total of fifteen methods seen in the
following table.
Trend Component | Seasonal Component |
---|
Component | N(None)) | A (Additive) | M (Multiplicative) |
---|---|---|---|
N (None) | (N,N) | (N,A) | (N,M) |
A (Additive) | (A,N) | (A,A) | (A,M) |
Ad (Additive damped) | (Ad,N) | (Ad,A) | (Ad,M) |
M (Multiplicative) | (M,N ) | (M,A ) | (M,M) |
Md (Multiplicative damped) | (Md,N ) | ( Md,A) | (Md,M) |
(N,N)
describes the simple exponential smoothing (or SES)
method, cell (A,N)
describes Holt’s linear method, and cell
(Ad,N)
describes the damped trend method. The additive
Holt-Winters’ method is given by cell (A,A)
and the multiplicative
Holt-Winters’ method is given by cell (A,M)
. The other cells
correspond to less commonly used but analogous methods.
(A,A)
, the he Holt-Winters’ additive
method:
where is the length of seasonality (e.g., the number of months or
quarters in a year), represents the level of the series,
denotes the growth, is the seasonal component,
is the forecast for periods ahead, and
. To use method (1), we need values
for the initial states , and , and
for the smoothing parameters and . All of
these will be estimated from the observed data.
Equation (1c) is slightly different from the usual Holt-Winters
equations such as those in Makridakis et al. (1998) or Bowerman,
O’Connell, and Koehler (2005). These authors replace (1c) with
If is substituted using (1a), we obtain
Thus, we obtain identical forecasts using this approach by replacing
in (1c) with . The modification given in
(1c) was proposed by Ord et al. (1997) to make the state space
formulation simpler. It is equivalent to Archibald’s (1990) variation of
the Holt-Winters’ method.
(E,T,S)
refers to the three components: error, trend and seasonality.
So the model ETS(A,A,N)
has additive errors, additive trend and no
seasonality—in other words, this is Holt’s linear method with additive
errors. Similarly, ETS(M,Md,M)
refers to a model with multiplicative
errors, a damped multiplicative trend and multiplicative seasonality.
The notation ETS(·,·,·)
helps in remembering the order in which the
components are specified.
Once a model is specified, we can study the probability distribution of
future values of the series and find, for example, the conditional mean
of a future observation given knowledge of the past. We denote this as
, where xt contains the unobserved
components such as , and . For we use
as a shorthand notation. For many models, these
conditional means will be identical to the point forecasts given in
Table Other ETS models, so that
. However, for other models (those with
multiplicative trend or multiplicative seasonality), the conditional
mean and the point forecast will differ slightly for .
We illustrate these ideas using the damped trend method of Gardner and
McKenzie (1985).
Each model consists of a measurement equation that describes the
observed data, and some state equations that describe how the unobserved
components or states (level, trend, seasonal) change over time. Hence,
these are referred to as state space models.
For each method there exist two models: one with additive errors and one
with multiplicative errors. The point forecasts produced by the models
are identical if they use the same smoothing parameter values. They
will, however, generate different prediction intervals.
To distinguish between a model with additive errors and one with
multiplicative errors (and also to distinguish the models from the
methods), we add a third letter to the classification of in the above
Table. We label each state space model as ETS(⋅,.,.)
for (Error,
Trend, Seasonal). This label can also be thought of as ExponenTial
Smoothing. Using the same notation as in the above Table, the
possibilities for each component (or state) are: Error ={ A,M }
,
Trend ={N,A,Ad}
and Seasonal ={ N,A,M }
.
(Hyndman et al., 2008, pp. 149-161)
. For example, for the ETS(A,N,N)
model, the traditional parameter region is but the
admissible region is . For the ETS(A,A,N)
model, the
traditional parameter region is and but
the admissible region is and .
ETS
statistical framework is that information
criteria can be used for model selection. The AIC, AIC_c
and BIC
,
can be used here to determine which of the ETS
models is most
appropriate for a given time series.
For ETS
models, Akaike’s Information Criterion (AIC)
is defined as
where is the likelihood of the model and is the total number of
parameters and initial states that have been estimated (including the
residual variance).
The AIC
corrected for small sample bias (AIC_c)
is defined as
and the Bayesian Information Criterion (BIC)
is
Three of the combinations of (Error, Trend, Seasonal) can lead to
numerical difficulties. Specifically, the models that can cause such
instabilities are ETS(A,N,M), ETS(A,A,M)
, and ETS(A,Ad,M)
, due to
division by values potentially close to zero in the state equations. We
normally do not consider these particular combinations when selecting a
model.
Models with multiplicative errors are useful when the data are strictly
positive, but are not numerically stable when the data contain zeros or
negative values. Therefore, multiplicative error models will not be
considered if the time series is not strictly positive. In that case,
only the six fully additive models will be applied.
Tip Statsforecast will be needed. To install, see instructions.Next, we import plotting libraries and configure the plotting style.
year | value | |
---|---|---|
0 | 1960-01-01 | 69.123902 |
1 | 1961-01-01 | 69.760244 |
2 | 1962-01-01 | 69.149756 |
3 | 1963-01-01 | 69.248049 |
4 | 1964-01-01 | 70.311707 |
unique_id
(string, int or category) represents an identifier
for the series.
ds
(datestamp) column should be of a format expected by
Pandas, ideally YYYY-MM-DD for a date or YYYY-MM-DD HH:MM:SS for a
timestamp.
y
(numeric) represents the measurement we wish to forecast.
ds | y | unique_id | |
---|---|---|---|
0 | 1960-01-01 | 69.123902 | 1 |
1 | 1961-01-01 | 69.760244 | 1 |
2 | 1962-01-01 | 69.149756 | 1 |
3 | 1963-01-01 | 69.248049 | 1 |
4 | 1964-01-01 | 70.311707 | 1 |
ds
from object
type to datetime.
unique_id | ds | AutoETS | |
---|---|---|---|
0 | 1 | 2014-01-01 | 82.952553 |
1 | 1 | 2015-01-01 | 83.146150 |
2 | 1 | 2016-01-01 | 83.339747 |
3 | 1 | 2017-01-01 | 83.533344 |
4 | 1 | 2018-01-01 | 83.726940 |
5 | 1 | 2019-01-01 | 83.920537 |
unique_id | ds | AutoETS | AutoETS-lo-95 | AutoETS-lo-90 | AutoETS-lo-80 | AutoETS-hi-80 | AutoETS-hi-90 | AutoETS-hi-95 | |
---|---|---|---|---|---|---|---|---|---|
0 | 1 | 2014-01-01 | 82.952553 | 82.500416 | 82.573107 | 82.656916 | 83.248190 | 83.331999 | 83.404691 |
1 | 1 | 2015-01-01 | 83.146150 | 82.693437 | 82.766221 | 82.850137 | 83.442163 | 83.526078 | 83.598863 |
2 | 1 | 2016-01-01 | 83.339747 | 82.884744 | 82.957897 | 83.042237 | 83.637257 | 83.721597 | 83.794749 |
3 | 1 | 2017-01-01 | 83.533344 | 83.073235 | 83.147208 | 83.232495 | 83.834192 | 83.919479 | 83.993452 |
4 | 1 | 2018-01-01 | 83.726940 | 83.257894 | 83.333304 | 83.420247 | 84.033634 | 84.120577 | 84.195987 |
5 | 1 | 2019-01-01 | 83.920537 | 83.437859 | 83.515461 | 83.604931 | 84.236144 | 84.325614 | 84.403216 |
unique_id | ds | AutoETS | |
---|---|---|---|
0 | 1 | 2014-01-01 | 82.952553 |
1 | 1 | 2015-01-01 | 83.146150 |
2 | 1 | 2016-01-01 | 83.339747 |
3 | 1 | 2017-01-01 | 83.533344 |
4 | 1 | 2018-01-01 | 83.726940 |
5 | 1 | 2019-01-01 | 83.920537 |
unique_id | ds | y | AutoETS | |
---|---|---|---|---|
0 | 1 | 1960-01-01 | 69.123902 | 69.005305 |
1 | 1 | 1961-01-01 | 69.760244 | 69.237346 |
2 | 1 | 1962-01-01 | 69.149756 | 69.495763 |
… | … | … | … | … |
51 | 1 | 2011-01-01 | 82.187805 | 82.348633 |
52 | 1 | 2012-01-01 | 82.239024 | 82.561938 |
53 | 1 | 2013-01-01 | 82.690244 | 82.758963 |
unique_id | metric | AutoETS | |
---|---|---|---|
0 | 1 | mae | 0.421060 |
1 | 1 | mape | 0.005073 |
2 | 1 | mase | 1.340056 |
3 | 1 | rmse | 0.483558 |
4 | 1 | smape | 0.002528 |