This function trains an Echo State Network (ESN) to a univariate time series.
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
: Alist
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)
#>
#> --- Inputs -----------------------------------------------------
#> n_obs = 144
#> n_diff = 1
#> lags = 1
#>
#> --- Reservoir generation ---------------------------------------
#> n_states = 57
#> alpha = 1
#> rho = 1
#> density = 0.5
#> scale_inputs = [-0.5, 0.5]
#> scale_win = [-0.5, 0.5]
#> scale_wres = [-0.5, 0.5]
#>
#> --- Model selection --------------------------------------------
#> n_models = 114
#> df = 19.17
#> lambda = 0.0159