This function performs ridge regression forecasting using attention-based context vectors as external regressors. Context vectors are computed from the training data using various attention mechanisms and then used to enhance the forecast model.

contextridge2f(
  y,
  h = 5L,
  attention_type = "exponential",
  window_size = 3,
  decay_factor = 5,
  temperature = 1,
  sigma = 1,
  sensitivity = 1,
  alpha = 0.5,
  beta = 0.5,
  ...
)

Arguments

y

A multivariate time series object.

h

Integer. Forecast horizon. Defaults to 5.

attention_type

String specifying the type of attention mechanism. Options are: "cosine", "exponential", "dot_product", "scaled_dot_product", "gaussian", "linear", "value_based", "hybrid", "parametric". Default is "exponential".

window_size

Integer parameter for window size (applicable for "cosine" attention). Defaults to 3.

decay_factor

Double for decay factor (applicable for "exponential" and "hybrid" attention). Defaults to 5.0.

temperature

Double for temperature (applicable for "scaled_dot_product" attention). Defaults to 1.0.

sigma

Double for sigma (applicable for "gaussian" attention). Defaults to 1.0.

sensitivity

Double for sensitivity (applicable for "value_based" or "hybrid" attention). Defaults to 1.0.

alpha

Double for alpha (applicable for "parametric" attention). Defaults to 0.5.

beta

Double for beta (applicable for "parametric" attention). Defaults to 0.5.

...

Additional arguments passed to ahead::ridge2f (e.g., lags, lambda_1, lambda_2, nb_hidden, etc.).

Value

An object returned by ahead::ridge2f for the forecast, typically a list including mean and prediction intervals.

Details

This approach allows the model to leverage temporal dependencies captured by attention mechanisms, potentially improving forecast accuracy by incorporating weighted historical information.

Examples


plot(contextridge2f(AirPassengers, h = 15, lags = 15, attention_type = "exponential"))


plot(contextridge2f(fdeaths, h = 20, lags = 15, attention_type = "exponential"))