-
Notifications
You must be signed in to change notification settings - Fork 22
Scale Model
The sm() function creates a model for the scale (variance) of the error term based on a fitted ADAM model. This allows modelling heteroscedasticity using ETS or ARIMA (with explanatory variables) structures for the scale parameter, similar to GARCH or GAMLSS approaches.
Note: The scale model currently only works with models estimated via maximum likelihood (
loss="likelihood").
Note: This is not yet implemented in Python.
In many time series, the variance of errors changes over time (heteroscedasticity). The scale model extends ADAM by:
- Modelling the scale parameter dynamically over time
- Supporting ETS and ARIMA structures for scale dynamics
- Allowing explanatory variables to affect variance
- Enabling automatic model selection for the scale component
Read more about this in Svetunkov (2023), Chapter 17.
The function prepares the data and then calls for adam() to fir the scale model.
For a location model:
y_t = μ_t + σ_t × ε_t
The scale model estimates σ_t dynamically:
σ_t = f(states, regressors)
where f() can follow ETS, ARIMA, or regression structures.
# Step 1: Fit location model
locationModel <- adam(AirPassengers, "MMM", h=12, holdout=TRUE)
# Step 2: Fit scale model
scaleModel <- sm(locationModel, model="YYY")
# Step 3: Examine results
scaleModel# Fit location model with regressors
data <- cbind(y, x1, x2)
locationModel <- adam(data, "AAN", h=12, holdout=TRUE)
# Scale model with regressor selection
scaleModel <- sm(locationModel, model="NNN",
formula=~x1+x2,
regressors="select")# After fitting both models separately
locationModel <- adam(AirPassengers, "MMM", lags=12)
scaleModel <- sm(locationModel, model="YYY")
# Merge them
mergedModel <- implant(locationModel, scaleModel)
# New output in comparison with just location model
mergedModel
# Access scale information
mergedModel$scale
extractScale(mergedModel)| Parameter | Type (R) | Type (Python) | Default | Description |
|---|---|---|---|---|
object |
adam | - | - | Fitted ADAM |
model |
character | - | "YYY" | ETS model for scale ("NNN" for no dynamics) |
lags |
numeric vector | - | NULL | Lags for seasonal scale components |
orders |
list | - | NULL | ARIMA orders for scale |
formula |
formula | - | NULL | Formula for explanatory variables |
regressors |
character | - | "use" | How to handle regressors: "use", "select", "adapt" |
persistence |
numeric vector | - | NULL | Fixed smoothing parameters |
phi |
numeric | - | NULL | Fixed damping parameter |
initial |
character | - | "backcasting" | Initialization method |
ic |
character | - | "AICc" | Information criterion |
bounds |
character | - | "usual" | Parameter bounds |
silent |
logical | - | TRUE | Suppress output |
The sm() function returns an object of class "adam" with additional scale-specific components:
| Element | Type (R) | Description |
|---|---|---|
model |
character | Scale model specification |
scale |
numeric vector | Estimated scale values over time |
fitted |
numeric vector | Fitted scale values |
forecast |
numeric vector | Scale forecasts |
states |
matrix | Scale states |
persistence |
numeric vector | Scale smoothing parameters |
logLik |
numeric | Log-likelihood |
# Fit location model
locationModel <- adam(AirPassengers, "MMM", lags=12, h=12, holdout=TRUE)
# Automatic selection among multiplicative ETS for scale
scaleModel <- sm(locationModel, model="YYY")
scaleModel
# View scale estimates
plot(scaleModel$scale, type="l", main="Estimated Scale Over Time")# Prepare data with explanatory variables
library(datasets)
data <- cbind(Seatbelts[,"DriversKilled"],
Seatbelts[,c("law","PetrolPrice")])
colnames(data)[1] <- "drivers"
# Fit location model
locationModel <- adam(data, "AAN", h=12, holdout=TRUE)
# Scale model with regressor selection
scaleModel <- sm(locationModel, model="NNN",
formula=drivers~law+PetrolPrice,
regressors="select")
scaleModel# 1. Fit location model
locationModel <- adam(AirPassengers, "MMM", lags=12)
summary(locationModel)
# 2. Check for heteroscedasticity
plot(locationModel, which=8) # Squared residuals vs Fitted
# 3. Fit scale model
scaleModel <- sm(locationModel, model="MNM", lags=12)
# 4. Merge models
fullModel <- implant(locationModel, scaleModel)
# 5. Generate forecasts with scale
fullModelForecast <- forecast(fullModel, h=24, interval="prediction")
plot(fullModelForecast)# Location model
locationModel <- adam(BJsales, "AAN", h=12, holdout=TRUE)
# ARIMA(1,0,1) for scale
scaleModel <- sm(locationModel, model="NNN",
orders=list(ar=1, i=0, ma=1))
scaleModel- Residual variance appears to change over time
- Squared residuals show patterns (check
plot(model, which=8)) - ACF of squared residuals shows significant autocorrelation (check
plot(model, which=9)) - You need prediction intervals that adapt to changing variance
| Pattern | Recommended Model |
|---|---|
| Constant variance | No scale model needed |
| Slowly changing variance | model="MNN" |
| Seasonal variance | model="MNM" |
| Variance depends on level |
model="YYY" (automatic selection) |
| Variance depends on covariates |
model="NNN" with formula
|
| Feature | sm() | Traditional GARCH |
|---|---|---|
| Framework | State space (ETS/ARIMA) | ARMA for variance |
| Seasonality | Native support | Requires extensions |
| Regressors | Supported | Limited |
| Forecasting | Integrated with location | Separate |
| Interpretation | Smoothing parameters | ARCH/GARCH coefficients |
-
Likelihood estimation required: Scale models only work when
loss="likelihood"was used for the location model. -
Estimation order: Always fit the location model first, then the scale model.
-
Model complexity: Adding a scale model increases the number of estimated parameters. Use information criteria to check if it improves the model.
-
Multiplicative errors: Scale models are particularly useful for multiplicative error models where variance is proportional to level.
- Svetunkov, I. (2023). Forecasting and Analytics with the Augmented Dynamic Adaptive Model (ADAM). Chapman and Hall/CRC. Online book: https://openforecast.org/adam/
- ADAM - Main ADAM function
- Refitting-and-Reforecasting - Uncertainty analysis
- Model-Information - Extracting model components
- Likelihood-and-Information-Criteria - Model comparison