# narxnet

Nonlinear autoregressive neural network with external input

## Syntax

`narxnet(inputDelays,feedbackDelays,hiddenSizes,trainFcn)`

## Description

NARX (Nonlinear autoregressive with external input) networks can learn to predict one time series given past values of the same time series, the feedback input, and another time series, called the external or exogenous time series.

`narxnet(inputDelays,feedbackDelays,hiddenSizes,trainFcn)` takes these arguments,

 `inputDelays` Row vector of increasing 0 or positive delays (default = 1:2) `feedbackDelays` Row vector of increasing 0 or positive delays (default = 1:2) `hiddenSizes` Row vector of one or more hidden layer sizes (default = 10) `trainFcn` Training function (default = `'trainlm'`)

and returns a NARX neural network.

## Examples

Here a NARX neural network is used to solve a simple time series problem.

```[X,T] = simpleseries_dataset; net = narxnet(1:2,1:2,10); [Xs,Xi,Ai,Ts] = preparets(net,X,{},T); net = train(net,Xs,Ts,Xi,Ai); view(net) Y = net(Xs,Xi,Ai); perf = perform(net,Ts,Y) ```
```perf = 0.0192 ```

Here the NARX network is simulated in closed loop form.

```netc = closeloop(net); view(netc) [Xs,Xi,Ai,Ts] = preparets(netc,X,{},T); y = netc(Xs,Xi,Ai); ```

Here the NARX network is used to predict the next output, a timestep ahead of when it will actually appear.

```netp = removedelay(net); view(netp) [Xs,Xi,Ai,Ts] = preparets(netp,X,{},T); y = netp(Xs,Xi,Ai); ```