This function fits ELM neural networks for time series forecasting.

```
elm(y, m = frequency(y), hd = NULL, type = c("lasso", "ridge", "step",
"lm"), reps = 20, comb = c("median", "mean", "mode"), lags = NULL,
keep = NULL, difforder = NULL, outplot = c(FALSE, TRUE),
sel.lag = c(TRUE, FALSE), direct = c(FALSE, TRUE),
allow.det.season = c(TRUE, FALSE), det.type = c("auto", "bin", "trg"),
xreg = NULL, xreg.lags = NULL, xreg.keep = NULL, barebone = c(FALSE,
TRUE), model = NULL, retrain = c(FALSE, TRUE))
```

y

Input time series. Can be ts or msts object.

m

Frequency of the time series. By default it is picked up from y.

hd

Number of hidden nodes. This can be a vector, where each number represents the number of hidden nodes of a different hidden layer. Use NULL to automatically specify.

type

Estimation type for output layer weights. Can be "lasso" (lasso with CV), "ridge" (ridge regression with CV), "step" (stepwise regression with AIC) or "lm" (linear regression).

reps

Number of networks to train, the result is the ensemble forecast.

comb

Combination operator for forecasts when reps > 1. Can be "median", "mode" (based on KDE estimation) and "mean".

lags

Lags of y to use as inputs. If none provided then 1:frequency(y) is used. Use 0 for no univariate lags.

keep

Logical vector to force lags to stay in the model if sel.lag == TRUE. If NULL then it keep = rep(FALSE,length(lags)).

difforder

Vector including the differencing lags. For example c(1,12) will apply first and seasonal (12) differences. For no differencing use 0. For automatic selection use NULL.

outplot

Provide plot of model fit. Can be TRUE or FALSE.

sel.lag

Automatically select lags. Can be TRUE or FALSE.

direct

Use direct input-output connections to model strictly linear effects. Can be TRUE or FALSE.

allow.det.season

Permit modelling seasonality with deterministic dummies.

det.type

Type of deterministic seasonality dummies to use. This can be "bin" for binary or "trg" for a sine-cosine pair. With "auto" if ony a single seasonality is used and periodicity is up to 12 then "bin" is used, otherwise "trg".

xreg

Exogenous regressors. Each column is a different regressor and the sample size must be at least as long as the target in-sample set, but can be longer.

xreg.lags

This is a list containing the lags for each exogenous variable. Each list is a numeric vector containing lags. If xreg has 3 columns then the xreg.lags list must contain three elements. If NULL then it is automatically specified.

xreg.keep

List of logical vectors to force lags of xreg to stay in the model if sel.lag == TRUE. If NULL then all exogenous lags can be removed.

barebone

Use an alternative elm implementation (written in R) that is faster when the number of inputs is very high. Typically not needed.

model

A previously trained mlp object. If this is provided then the same model is fitted to y, without re-estimating any model parameters.

retrain

If a previous model is provided, retrain the network or not. If the network is retrained the size of the hidden layer is reset.

Return object of class `elm`

. If barebone == TRUE then the object inherits a second class "`elm.fast`

".
The function `plot`

produces a plot the network architecture.
`elm`

contains:

`net`

- ELM networks. If it is of class "`elm.fast`

" then this is NULL.`hd`

- Number of hidden nodes. If it is of class "`elm.fast`

" this is a vector with a different number for each repetition.`W.in`

- NULL unless it is of class "`elm.fast`

". Contains the input weights.`W`

- Output layer weights for each repetition.`b`

- Contains the output node bias for each training repetition.`W.dct`

- Contains the direct connection weights if argument direct == TRUE. Otherwise is NULL.`lags`

- Input lags used.`xreg.lags`

-`xreg`

lags used.`difforder`

- Differencing used.`sdummy`

- Use of deterministic seasonality.`ff`

- Seasonal frequencies detected in data (taken from ts or msts object).`ff.det`

- Seasonal frequencies coded using deterministic dummies.`det.type`

- Type of determistic seasonality.`y`

- Input time series.`minmax`

- Scaling structure.`xreg.minmax`

- Scaling structure for xreg variables.`comb`

- Combination operator used.`type`

- Estimation used for output layer weights.`direct`

- Presence of direct input-output connections.`fitted`

- Fitted values.`MSE`

- In-sample Mean Squared Error.

For an introduction to neural networks see: Ord K., Fildes R., Kourentzes N. (2017) Principles of Business Forecasting 2e.

*Wessex Press Publishing Co.*, Chapter 10.For combination operators see: Kourentzes N., Barrow B.K., Crone S.F. (2014) Neural network ensemble operators for time series forecasting.

*Expert Systems with Applications*,**41**(**9**), 4235-4244.For variable selection see: Crone S.F., Kourentzes N. (2010) Feature selection for time series prediction <U+2013> A combined filter and wrapper approach for neural networks.

*Neurocomputing*,**73**(**10**), 1923-1936.For ELMs see: Huang G.B., Zhou H., Ding X. (2006) Extreme learning machine: theory and applications.

*Neurocomputing*,**70**(**1**), 489-501.

```
# NOT RUN {
fit <- elm(AirPassengers)
print(fit)
plot(fit)
frc <- forecast(fit,h=36)
plot(frc)
# }
# NOT RUN {
# }
```

Run the code above in your browser using DataLab