TimeSeriesAnalysis
ExponentialSmoothingModel
exponential smoothing model
Calling Sequence
Parameters
Description
Model Variants
Typical Usage
Model Equations
Options
Working with Model Parameters
Examples
References
Compatibility
ExponentialSmoothingModel(ts, E, T, S, opts)
ts
-
(optional) Time series consisting of a single data set
E
(optional) types of error allowed (name, string, or set of these)
T
(optional) types of trend allowed (name, string, or set of these)
S
(optional) types of seasonal influence allowed (name, string, or set of these)
opts
(optional) equations of the form optionname = value to set other parameters
The ExponentialSmoothingModel command creates an exponential smoothing model or ETS model for a time series. These models are a generalization of the idea to use exponential smoothing of the previous data as a forecast. The model can get its parameters optimized automatically to fit a given time series, or the parameters can be set by hand.
There are 30 variants of this model. They are distinguished by:
whether errors are additive or multiplicative;
whether there is a trend, and if there is one, if it is additive or multiplicative and whether it is damped or not;
whether there is seasonal influence, and if there is, whether it is additive or multiplicative.
By default, Maple creates a model that potentially represents any of the 30 variants. Maple can automatically select one that is appropriate for a time series, or you can restrict the selection manually.
Restricting the selection manually can be done with the E, T, and S parameters, or by using the named options errors, trend, and seasonal. If using E, T, and S, one needs to supply all three parameters; using the named options, one can use any subset. The values are given by the following table.
Value (long)
Value(short)
errors / E
trend / T
seasonal / S
none
N
+
additive
A
additivedamped
Ad
multiplicative
M
multiplicativedamped
Md
For example, the third row of this table says that only the trend or T parameter can be additive damped, not the errors or seasonal parameter. These values are supplied either in short or long form and can be either a string or a name. If a single value is desired, then one can use the corresponding string or name by itself; otherwise a set must be given. For example, you could specify errors = "A" to consider only models with additive error, or seasonal = {"additive", "M"} to consider models with additive or multiplicative seasonality (but not models without seasonal influence).
The option damping = false will exclude the models with damped trend from being considered.
Some of these models lead to numerical difficulties. These are not considered by default. For more details, see the Specialize help page.
If you supply a time series to the ExponentialSmoothingModel command, Maple will compute the most suitable model for that time series. If you do not supply a time series to ExponentialSmoothingModel, you can perform the steps involved by hand, otherwise they happen behind the scenes:
First, use the Specialize command. This command, and all of the following, do require a time series argument. It returns a list of models of all variants that are suitable for the time series and compatible with the given options.
Then, use the Initialize command. This command finds and records initial values for the optimization procedure run next.
The Optimize command subsequently optimizes the parameters and initial values -- starting from the values generated by the Initialize command.
Finally, to select which model is the most suitable, compare the LogLikelihood and the NumberOfParameters of each candidate. Standard ways to do this are to use one of the AICc, AIC, and BIC commands to compute the corresponding information criteria, and select the model where the value is lowest. If you supply a time series to the original ExponentialSmoothingModel command, the AICc command is used.
Once the model has been generated, either fully automatically or by hand, you can use the OneStepForecasts command to see if the fit is good enough for your purposes, and then Forecast to get a forecast of future values. Both of these can include confidence intervals (obtained through simulation).
We present the equations for all variants of the model in innovation state space form.
The equations for the models can be given in terms of these variables:
The actual output at time t is a variable yt.
The level at time t is denoted by ℓt.
Models with trend have a trend variable, bt.
Models with seasonality have a seasonal variable, st.
There are errors εt.
The variables ℓ0, b0, and s1−m through s0, if present, need to be initialized. The number m is the period of the season. In addition there are parameters: α is always present, β is present in models with trend, φ is present in models with a damped trend, and γ is present in models with seasonality.
We define the equations defining the variables at time t. We start by introducing three auxiliary variables: y1t, y2t, and y3t.
The variable y1t accounts for the trend. It is defined by:
y1t={0trend=nonebt−1trend=additiveφ⁢bt−1trend=additivedampedbt−1trend=multiplicativebt−1φtrend=multiplicativedamped
The variable y2t accounts for the previous level and, if applicable, the trend. It is defined by:
y2t={ℓt−1trend=noneℓt−1+y1ttrend=additiveℓt−1+y1ttrend=additivedampedℓt−1⁢y1ttrend=multiplicativeℓt−1⁢y1ttrend=multiplicativedamped
The variable y3t is like y2t, except it also accounts for seasonal effects. (This is essentially the forecast for the output at t.) It is defined by:
y3t={y2tseasonal=noney2t+st−mseasonal=additivey2t⁢st−mseasonal=multiplicative
Now yt can be defined as follows:
yt={y3t+ϵterrors=additivey3t⁢1+ϵterrors=multiplicative
The level ℓt can be computed in the following manner:
ℓt={{y2t+α⁢ϵtst−mseasonal=multiplicativeα⁢ϵt+y2totherwiseerrors=additive{y2t+α⁢y2t+st−m⁢ϵtseasonal=additivey2t⁢α⁢ϵt+1otherwiseerrors=multiplicative
For models with trend, we define bt as follows.
bt={y1t+β⁢ϵt{st−mseasonal=multiplicative1otherwise⁢{ℓt−1trend∈multiplicative,multiplicativedamped1otherwiseerrors=additive{y1t+β⁢y1t+ℓt−1+{st−mseasonal=additive0otherwise⁢ϵttrend∈additive,additivedamped{y1t+β⁢y1t+st−mℓt−1⁢ϵtseasonal=additivey1t⁢β⁢ϵt+1otherwisetrend∈multiplicative,multiplicativedampederrors=multiplicative
For models with seasonal influence, we define st as follows.
st={{γ⁢ϵt+st−mseasonal=additivest−m+γ⁢ϵty2tseasonal=multiplicativeerrors=additive{st−m+γ⁢y2t+st−m⁢ϵtseasonal=additivest−m⁢γ⁢ϵt+1seasonal=multiplicativeerrors=multiplicative
The following options can be specified:
errors, trend, seasonal : string or name or set of strings or names
Discussed in the section on model variants.
alpha, beta, gamma, phi : numeric
Fixes the value of the given parameter, discussed in the section on model equations. This means that these parameters won't be subject to optimization when Optimize is called.
period : positive integer
Sets the period m of the season. If it is not specified explicitly, the period is taken from the time series supplied during the Optimize call. A value of 1 disables the use of model variants with seasonal influence. Exponential smoothing models are most effective when the period is at most 12; an error will be given for periods greater than 24.
l0, b0 : numeric
Fixes the value of the given initial value, ℓ0 or b0, respectively; they are the initial values for ℓt and bt, discussed in the section on model equations. If not specified, the initial values are subject to optimization when Optimize is called.
s : list or Vector with numeric entries
Initial values for the seasonal parameter s. There are m values, one for each period. They correspond to the values s1−m, ..., s0, and they need to occur in that order in the list or Vector. If not specified, these values are subject to optimization when Optimize is called.
sigma : numeric
The standard deviation of the normal random variable that supplies the errors, εt in the section on model equations. If not specified explicitly, its value is taken from the errors in the time series supplied to Optimize.
damping : true or false
If damping = false is included as an option, then models with damped trend will not be considered. The default is damping = true.
constraints : equal to usual, admissible, or both
There are traditional constraints on the parameters α, β, γ, and φ that allow for the model to be interpreted in the framework of exponential smoothing. These are called the "usual" constraints. There are also constraints (typically, but not always, less strict) that need to be satisfied for the model to be numerically stable, or "admissible". The constraints option selects which constraints are used: constraints = usual uses only the usual constraints, constraints = admissible uses only the constraints for an admissible model, and constraints = both (the default) uses both sets of constraints.
criterion : procedure
By default, as explained in the section on typical usage, Maple uses Akaike's information criterion with the sample size correction, AICc, to select the best model. If you supply the criterion option, you can choose a different criterion. Typical choices would be AIC or BIC, but you can also supply a different procedure. This procedure will be passed three arguments: the model, the time series, and the argument loglikelihood = ll, where ll is the precomputed log likelihood. The procedure should return a number. Maple selects the model where the returned value is the lowest.
The exponential smoothing model constructed by this command has parameters that can be examined and set using the GetParameter, GetParameters, and SetParameter commands. These correspond loosely to the named options above, but they are generally less flexible. The parameters are detailed below, with a description of what are legal values for the parameter. When using SetParameter, you need to make sure that the new value conforms with these restrictions.
Legal values
errors, trend, seasonal
set of one- or two-letter strings (a suitable subset of A,Ad,M,Md,N)
alpha, beta, gamma, phi, l0, b0, sigma
algebraic constant
period
positive integer
s
Vector with rtable options given by datatype = float[8] and storage = rectangular, and no indexing functions
constraints
string, in particular one of "usual", "admissible", or "both"
There is no damping parameter - that information is encoded in the errors, trend, and seasonal parameters. There is also no criterion parameter: that information is only used when a time series is included in the ExponentialSmoothingModel calling sequence.
If there is no seasonality, the value of period is 1.
with⁡TimeSeriesAnalysis:
Consider the following time series. It represents international tourist visitor nights in Australia.
ts≔TimeSeries⁡41.7,24.0,32.3,37.3,46.2,29.3,36.5,43.0,48.9,31.2,37.7,40.4,51.2,31.9,41.0,43.8,55.6,33.9,42.1,45.6,59.8,35.2,44.3,47.9,startdate=2005,frequency=quarterly,header=Visitor nights
ts≔Time seriesVisitor nights24 rows of data:2005-Jan-01 - 2010-Oct-01
We fit an exponential smoothing model to it.
esm≔ExponentialSmoothingModel⁡ts
esm≔< an ETS(M,A,M) model >
To evaluate the fit of this model, view the one step forecasts.
onestepfcs≔OneStepForecasts⁡esm,ts
onestepfcs≔Time seriesVisitor nights (1 step forecasts)24 rows of data:2005-Jan-01 - 2010-Oct-01
TimeSeriesPlot⁡onestepfcs,color=Spring Blue,thickness=2,ts,color=Spring Rose,thickness=4
Let's add 80% and 95% confidence intervals.
onestepconf≔OneStepForecasts⁡esm,ts,output=percentiles⁡2.5,10,90,97.5
onestepconf≔Time seriesVisitor nights (1 step forecast - 2 percentile), ..., Visitor nights (1 step forecast - 98 percentile)24 rows of data:2005-Jan-01 - 2010-Oct-01
TimeSeriesPlot⁡onestepfcs,color=Spring Blue,thickness=2,onestepconf,color=Spring YellowGreen..Spring BlueGreen,ts,color=Spring Rose,thickness=4
The fit looks pretty good. Now let us add the forecasts.
fcs≔Forecast⁡esm,ts,8
fcs≔Time seriesVisitor nights (forecast)8 rows of data:2010-Dec-31 - 2012-Sep-30
conf≔Forecast⁡esm,ts,8,output=percentiles⁡2.5,10,90,97.5
conf≔Time seriesVisitor nights (forecast - 2 percentile), ..., Visitor nights (forecast - 98 percentile)8 rows of data:2010-Dec-31 - 2012-Sep-30
TimeSeriesPlot⁡onestepfcs,color=Spring Blue,thickness=2,onestepconf,color=Spring YellowGreen..Spring BlueGreen,fcs,color=Spring Blue,thickness=2,legend=,conf,color=Spring YellowGreen..Spring BlueGreen,legend=,ts,color=Spring Rose,thickness=4
Doing this by hand, we could go about this as follows. We see that the seasonal influence is very significant; a model that doesn't take that into account is not likely to do well. We will also relax the constraints to allow all admissible parameter values.
esm2≔ExponentialSmoothingModel⁡seasonal=A,M,constraints=admissible
esm2≔< an ETS(*,*,*) model >
Transform to a collection of specialized models.
models≔Specialize⁡esm2,ts
models≔< an ETS(A,A,A) model >,< an ETS(A,Ad,A) model >,< an ETS(A,N,A) model >,< an ETS(M,A,A) model >,< an ETS(M,A,M) model >,< an ETS(M,Ad,A) model >,< an ETS(M,Ad,M) model >,< an ETS(M,M,M) model >,< an ETS(M,Md,M) model >,< an ETS(M,N,A) model >,< an ETS(M,N,M) model >
Find initial points for optimization for all of these.
inits≔map⁡Initialize,models,ts:
Optimize all of them.
foritonumelems⁡modelsdoOptimize⁡modelsi,ts,initsienddo:
Evaluate the Bayesian information criterion for each model.
map⁡model↦print⁡model,BIC⁡model,ts,models:
< an ETS(A,A,A) model >,126.7819508
< an ETS(A,Ad,A) model >,126.9258852
< an ETS(A,N,A) model >,129.9242821
< an ETS(M,A,A) model >,141.6667862
< an ETS(M,A,M) model >,109.4702551
< an ETS(M,Ad,A) model >,135.7502647
< an ETS(M,Ad,M) model >,109.9821406
< an ETS(M,M,M) model >,111.2692148
< an ETS(M,Md,M) model >,109.4060877
< an ETS(M,N,A) model >,140.6230023
< an ETS(M,N,M) model >,112.5756460
Compare all models' fits.
colors≔ColorTools:-Gradient⁡Niagara Navy..Niagara Purple,number=numelems⁡models
colors≔〈RGB : 0 0.0549 0.471〉,〈RGB : 0.0392 0.0503 0.469〉,〈RGB : 0.0784 0.0458 0.467〉,〈RGB : 0.118 0.0412 0.465〉,〈RGB : 0.157 0.0366 0.463〉,〈RGB : 0.196 0.032 0.461〉,〈RGB : 0.235 0.0275 0.459〉,〈RGB : 0.275 0.0229 0.457〉,〈RGB : 0.314 0.0183 0.455〉,〈RGB : 0.353 0.0137 0.453〉,〈RGB : 0.392 0.00915 0.451〉,〈RGB : 0.431 0.00458 0.449〉,〈RGB : 0.471 0 0.447〉
TimeSeriesPlot⁡seq⁡OneStepForecasts⁡modelsi,ts,color=ToPlotColor⁡colorsi,legend=print_preprocess⁡modelsi,i=1..numelems⁡models,ts,color=Niagara Green,thickness=3
In the following example, let's assume we know beforehand that we want a model with additive errors, a trend that is either additive or additive damped, and additive or multiplicative seasonality. Additionally, we know that α is equal to 110 and φ, if present in the model, is equal to 0.95.
esm3≔ExponentialSmoothingModel⁡ts,A,A,Ad,A,M,α=110,φ=0.95
esm3≔< an ETS(A,A,A) model >
The optimized model is in this case not a damped model. So φ is not part of this model, and therefore its value is set to the default - 1. The setting of α we required is respected.
GetParameter⁡esm3,α,φ
110,1.
A plot of data and forecasts:
TimeSeriesPlot⁡ts,color=Niagara Green,OneStepForecasts⁡esm3,ts,Forecast⁡esm3,ts,8,output=percentiles⁡2.5,10,50,90,97.5
Hyndman, R.J. and Athanasopoulos, G. (2013) Forecasting: principles and practice. http://otexts.org/fpp/. Accessed on 2013-10-09.
Hyndman, R.J., Koehler, A.B., Ord, J.K., and Snyder, R.D. (2008) Forecasting with Exponential Smoothing: The State Space Approach. Springer Series in Statistics. Springer-Verlag Berlin Heidelberg.
The TimeSeriesAnalysis[ExponentialSmoothingModel] command was introduced in Maple 18.
For more information on Maple 18 changes, see Updates in Maple 18.
See Also
Initialize
LogLikelihood
Optimize
Specialize
Download Help Document