This function trains an Echo State Network (ESN) to a univariate time series.

train_esn(
  y,
  lags = 1,
  inf_crit = "bic",
  n_diff = NULL,
  n_states = NULL,
  n_models = NULL,
  n_initial = NULL,
  n_seed = 42,
  alpha = 1,
  rho = 1,
  density = 0.5,
  lambda = c(1e-04, 2),
  scale_win = 0.5,
  scale_wres = 0.5,
  scale_inputs = c(-0.5, 0.5)
)

Arguments

y

Numeric vector containing the response variable.

lags

Integer vectors with the lags associated with the input variable.

inf_crit

Character value. The information criterion used for variable selection inf_crit = c("aic", "aicc", "bic").

n_diff

Integer vector. The nth-differences of the response variable.

n_states

Integer value. The number of internal states per reservoir.

n_models

Integer value. The maximum number of (random) models to train for model selection.

n_initial

Integer value. The number of observations of internal states for initial drop out (throw-off).

n_seed

Integer value. The seed for the random number generator (for reproducibility).

alpha

Numeric value. The leakage rate (smoothing parameter) applied to the reservoir.

rho

Numeric value. The spectral radius for scaling the reservoir weight matrix.

density

Numeric value. The connectivity of the reservoir weight matrix (dense or sparse).

lambda

Numeric vector. Lower and upper bound of lambda sequence for ridge regression.

scale_win

Numeric value. The lower and upper bound of the uniform distribution for scaling the input weight matrix.

scale_wres

Numeric value. The lower and upper bound of the uniform distribution for scaling the reservoir weight matrix.

scale_inputs

Numeric vector. The lower and upper bound for scaling the time series data.

Value

A list containing:

  • actual: Numeric vector containing the actual values.

  • fitted: Numeric vector containing the fitted values.

  • resid: Numeric vector containing the residuals.

  • states_train: Numeric matrix containing the internal states.

  • method: A list containing several objects and meta information of the trained ESN (weight matrices, hyperparameters, model metrics, etc.).

Examples

xdata <- as.numeric(AirPassengers)
xmodel <- train_esn(y = xdata)
summary(xmodel)
#> 
#> --- Layers ----------------------------------------------------- 
#>  n_inputs  =  1 
#>  n_states  =  57 
#>  n_outputs =  1 
#> 
#> --- Meta --------------------------------------------------- 
#>  lags     =  1 
#>  n_diff   =  1 
#>  n_models =  114 
#> 
#> --- Scaling ----------------------------------------------------
#> scale_inputs = [-0.5, 0.5]
#> scale_win    = [-0.5, 0.5]
#> scale_wres   = [-0.5, 0.5]
#> 
#> --- Hyperparameters -------------------------------------------- 
#>  alpha   =  1 
#>  rho     =  1 
#>  density =  0.5