Learn R Programming

gratis (version 1.0.7)

ets_model: Specify parameters for an ETS model

Description

This function allows the parameters of a ETS state space model to be specified. The output can be used in simulate.ets() and generate.ets. If any argument is NULL, the corresponding parameters are randomly selected. The error component is chosen from {A,M}, the trend component is chosen from {N,A,Ad}, and the seasonal component is chosen from {N,A,M}. In all cases, the component is selected uniformly on the options. The parameters are selected uniformly on the forecastable parameter space. The noise variance sigma is uniformly sampled on (1,5) for additive errors, and on (0.0001,0.05) for multiplicative errors. The initial states are chosen uniformly on (-1,1) in all cases except for multiplicative seasonal states which are uniform on (0.5, 1.5), and models with multiplicative errors for which the level is uniform on (2, 10). The parameterization is as specified in Hyndman & Athanasopoulos (2021).

Usage

ets_model(
  frequency = 1,
  error = NULL,
  trend = NULL,
  seasonal = NULL,
  alpha = NULL,
  beta = NULL,
  gamma = NULL,
  phi = NULL,
  level = NULL,
  slope = NULL,
  season = NULL,
  damped = NULL,
  sigma = NULL
)

Value

An `ets` object as described in the ets function from the forecast package.

Arguments

frequency

The length of the seasonal period (e.g., 12 for monthly data).

error

A character string specifying the error part of the ETS model: either "A" or "M".

trend

A character string specifying the trend part of the ETS model: either "N", "A" or "Ad".

seasonal

A character string specifying the seasonal part of the ETS model: either "N", "A" or "M".

alpha

A numeric value for the smoothing parameter controlling the level.

beta

A numeric value for the smoothing parameter controlling the trend.

gamma

A numeric value for the smoothing parameter controlling the seasonality.

phi

A numeric value specifying the damping parameter.

level

A numeric value specifying the initial level \(\ell_0\).

slope

A numeric value specifying the initial slope \(b_0\)

season

A numeric vector specifying the initial states \(s_{1-m},...,s_0\).

damped

A logical value indicating if the trend is damped or not.

sigma

The standard deviation of the noise.

Author

Rob J Hyndman

See Also

simulate.ets

Examples

Run this code
# An ETS(A,A,N) model with random parameters
model1 <- ets_model(error = "A", trend = "A", seasonal = "N")
# An ETS(A,A,N) model with specific parameters
model2 <- ets_model(
  error = "A", trend = "A", seasonal = "N",
  alpha = 0.3, beta = 0.2, level = 0, slope = 1, sigma = 2
)
# A multiplicative quarterly seasonal ETS model with random parameters
model3 <- ets_model(seasonal = "M", frequency = 4)
# Simulate from each model and plot the results
library(forecast)
simulate(model1, 100) %>% plot()
simulate(model2, 100) %>% plot()
simulate(model3, 100) %>% plot()

Run the code above in your browser using DataLab