-
Notifications
You must be signed in to change notification settings - Fork 22
Initialisation
This page documents the initial parameter and initialisation methods used across smooth models.
Read more about this in Section 11.4 of Svetunkov (2023).
The initial parameter controls how initial state values are determined before model estimation begins.
R
# Use backcasting (default)
model <- adam(y, model="AAA", lags=12, initial="backcasting")
# Optimize all initial states
model <- adam(y, model="AAA", lags=12, initial="optimal")Python
# Use backcasting (default)
model = ADAM(model="AAA", lags=12, initial="backcasting")
# Optimize all initial states
model = ADAM(model="AAA", lags=12, initial="optimal")| Method | Description | Speed | Recommended For |
|---|---|---|---|
"backcasting" |
Initialize via backcasting procedure | Fast | High-frequency data, large datasets |
"optimal" |
Optimize all initial states | Slow | Short series, when accuracy is critical |
"two-stage" |
Backcast first, then optimize | Slower | Refine the initials, gain in accuracy |
"complete" |
Full backcasting including regressors | Fast | ETSX/ARIMAX models on large datasets |
The default method. Runs the model forward and backwards through the data to estimate initial states:
- Start from the beginning of the data, apply the model
- Revert the model and move from the end of the series to the beginning
- Use the resulting states as initial values
Note: This method still estimates the values of the parameters for the explanatory variables.
Advantages:
- Fast, especially for long series
- Works well for high-frequency data
- Provides reasonable starting points
- Requires fewer parameters to estimate
When to use: Default choice for most situations, especially with high-frequency or long series.
model <- adam(y, model="AAA", lags=12, initial="backcasting")model = ADAM(model="AAA", lags=12, initial="backcasting")The number of iterations in backcasting can be controlled via the nIterations parameter:
model <- adam(y, model="AAA", lags=12, initial="backcasting", nIterations=2)model = ADAM(model="AAA", lags=12, initial="backcasting", n_iterations=2)Default is 2 iterations, which suffices in the majority of cases. Larger values will slow down the estimation.
All initial states are treated as parameters and optimized along with other model parameters:
- Initial states are included in the parameter vector
- Optimizer finds values that minimize the loss function
- Results in potentially better fit but more parameters to estimate
Advantages:
- Can improve fit for short series
- This is the default approach in all the other ETS implementations
Disadvantages:
- Slower, especially for seasonal models with long lags and large datasets
- More parameters to estimate
- Parameter estimates for initial states are neither efficient, nor consistent
- Might become a nightmare in case of large order ARIMA
When to use: Short time series where initial states significantly impact the fit.
model <- adam(y, model="AAA", lags=12, initial="optimal")model = ADAM(model="AAA", lags=12, initial="optimal")Combines backcasting and optimization:
- First, perform backcasting to get initial estimates
- Then, refine these estimates through optimization
Advantages:
- Better starting point for optimization
- Can achieve better fit than pure backcasting
Disadvantages:
- The same as in case of "optimal".
When to use: When you want a better model fit, and are not satisfied with the "optimal" ones.
model <- adam(y, model="AAA", lags=12, initial="two-stage")model = ADAM(model="AAA", lags=12, initial="two-stage")Full backcasting that also initializes explanatory variable coefficients:
- Backcast all states including regressor parameters
- No optimization of initial values for ETS/ARIMA components
Advantages:
- Fast for models with regressors
- Consistent treatment of all components
Disadvantages:
- Estimates of parameters for explanatory variables might be biased
When to use: ETSX, ARIMAX, or other models with explanatory variables.
model <- adam(data, model="AAN", formula=y~x1+x2, initial="complete")model = ADAM(model="AAN", regressors="use", initial="complete")
model.fit(y, X)Instead of using a character method, you can provide specific initial values.
| Component | Description | Required For |
|---|---|---|
level |
Initial level value | All ETS models |
trend |
Initial trend value | ETS models with trend (A, Ad, M, Md) |
seasonal |
List/Vector of seasonal indices | Seasonal ETS models |
arima |
Initial ARIMA states | ARIMA components |
xreg |
Initial regressor coefficients | Models with explanatory variables |
# R: Provide specific initial values
model <- adam(y, model="AAA", lags=12,
initial=list(
level=100,
trend=1,
seasonal=c(0.9, 1.0, 1.1, 0.95, 1.05, 0.98,
1.02, 0.97, 1.03, 0.96, 1.04, 1.0)
))In case of several seasonal components, the list of components should be passed to seasonal with each element including a vector of components for respective lags.
# Python: Provide initial values as dictionary
model = ADAM(model="AAA", lags=12,
initial={"level": 100, "trend": 1, "seasonal": [0.9, 1.0, 1.1, ...]})If some components are provided but others are missing, the missing ones will be estimated:
# Provide level, estimate everything else
model <- adam(y, model="AAA", lags=12,
initial=list(level=100))model = ADAM(model="AAA", lags=12,
initial={"level": 100})Components can also be provided as a vector in the order: level, trend, seasonal, ARIMA, xreg (with no gaps).
# Order: level, trend, 12 seasonal values
init_vec <- c(100, 1, 0.9, 1.0, 1.1, 0.95, 1.05, 0.98, 1.02, 0.97, 1.03, 0.96, 1.04, 1.0)
model <- adam(y, model="AAA", lags=12, initial=init_vec)Note: Providing initial values as a plain vector is not supported in Python. Use a dictionary instead (see "As a Named List/Dict" above).
In R, The initialSeason parameter (in ES) allows specifying initial seasonal values separately:
# R: ES with specific seasonal initials
model <- es(y, model="AAA", lags=12,
initialSeason=c(0.9, 1.0, 1.1, 0.95, 1.05, 0.98,
1.02, 0.97, 1.03, 0.96, 1.04, 1.0))After fitting, you can access the initial values used:
# R: Access initial values
model <- adam(y, model="AAA", lags=12)
model$initial # Named list of initial values
model$initialType # Method used ("backcasting", "optimal", etc.)
model$initialEstimated # Which components were estimated# Python: Access initial values
model = ADAM(model="AAA", lags=12)
model.fit(y)
model.initial_states_ # Initial state values-
Default: Use
"backcasting"- it's fast and usually sufficient -
Short series: Consider
"optimal"if you don't like the model fit from "backcasting" -
With regressors: If the sample size is large and you don't want to wait, use
"complete" - Domain knowledge: If you know reasonable initial values, provide them
- Numerical issues: If estimation fails, try different initialization methods
- Svetunkov, I. (2023). Forecasting and Analytics with the Augmented Dynamic Adaptive Model (ADAM). Online book: https://openforecast.org/adam/
- Hyndman, R.J., et al. (2008). Forecasting with Exponential Smoothing: The State Space Approach. Springer.
- ADAM - Main ADAM function
- ES - Exponential Smoothing
- Persistence - Smoothing parameters
- Coefficients-and-Parameters - Extracting estimated parameters