## What are Nonlinear ARX Models?

Nonlinear ARX models extend the linear ARX models to the nonlinear case. The structure of these models enables you to model complex nonlinear behavior using flexible nonlinear functions, such as wavelet and sigmoid networks. For information about when to fit nonlinear models, see About Identified Nonlinear Models.

### Nonlinear ARX Model Extends the Linear ARX Structure

A linear SISO ARX model has the following structure:

$$y(t)+{a}_{1}y(t-1)+{a}_{2}y(t-2)+\mathrm{...}+{a}_{na}y(t-na)={b}_{1}u(t)+{b}_{2}u(t-1)+\mathrm{...}+{b}_{nb}u(t-nb+1)+e\left(t\right)$$

Where, *u*,*y*, and *e* are the
input, output, and noise. This structure implies that the current output
*y*(*t*) is predicted as a weighted sum of
past output values and current and past input values. *na* is the
number of past output terms, and *nb* is the number of past input
terms used to predict the current output. The input delay *nk* is
set to zero to simplify the notation. Rewriting the equation as a product
gives:

$${y}_{p}(t)=\left[-{a}_{1},-{a}_{2},\mathrm{...},-{a}_{na},{b}_{1},{b}_{2},\mathrm{..},{b}_{nb}\right]\ast {\left[y(t-1),y(t-2),\mathrm{...},y(t-na),u(t),u(t-1),\mathrm{...},u(t-nb-1)\right]}^{T}$$

where $$y(t-1),y(t-2),\mathrm{...},y(t-na),u(t),u(t-1),\mathrm{...},u(t-nb-1)$$ are delayed input and output variables, called
*regressors*. The coefficients vector
*[–a _{1}, ...
,b_{nb}]* represents the weighting applied to these
regressors. The linear ARX model thus predicts the current output

*y*as a weighted sum of its regressors.

_{p}The structure of a nonlinear ARX model allows the following additional flexibility:

Instead of the weighted sum of the regressors that represents a linear mapping, the nonlinear ARX model has a more flexible nonlinear mapping function,

*F*.$${y}_{p}(t)=F(y(t-1),y(t-2),y(t-3),\mathrm{...},u(t),u(t-1),u(t-2),\mathrm{..})$$

Inputs to

*F*are model regressors. When you specify the nonlinear ARX model structure, you can choose one of several available nonlinear functions. For example,*F*can represent a weighted sum of wavelets that operate on the distance of the regressors from their means. For more information, see Available Mapping Functions for Nonlinear ARX Models.Nonlinear ARX regressors can be both delayed input-output variables and more complex, nonlinear expressions of delayed input and output variables. Examples of such nonlinear regressors are

*y*(*t*-1)^{2},*u*(*t*-1)**y*(*t*-2), abs(*u*(*t*-1)), and max(*u*(*t*-1)**y*(*t*-3),-10).

### Structure of Nonlinear ARX Models

A nonlinear ARX model consists of model regressors and an output function. The output function
contains one or more *mapping objects*, one for each model output. Each
mapping object can include a linear and a nonlinear function that act on the model
regressors to give the model output and a fixed offset for that output. This block diagram
represents the structure of a single-output nonlinear ARX model in a simulation scenario.

The software computes the nonlinear ARX model output *y* in
two stages:

It computes regressor values from the current and past input values and the past output data.

In the simplest case, regressors are delayed inputs and outputs, such as

*u*(*t*–1) and*y*(*t*–3). These kind of regressors are called*linear regressors*. You specify linear regressors using the`linearRegressor`

object. You can also specify linear regressors by using linear ARX model orders as an input argument. For more information, see Nonlinear ARX Model Orders and Delay. However, this second approach constrains your regressor set to linear regressors with consecutive delays. To create*polynomial regressors*, use the`polynomialRegressor`

object. To create*periodic regressors*that contain the sine and cosine functions of delayed input and output variables , use the`periodicRegressor`

object. You can also specify*custom regressors*, which are nonlinear functions of delayed inputs and outputs. For example,*u*(*t*–1)*y*(*t*–3) is a custom regressor that multiplies instances of input and output together. Specify custom regressors using the`customRegressor`

object.You can assign any of the regressors as inputs to the linear function block of the output function, the nonlinear function block, or both.

It maps the regressors to the model output using an output function block. The output function block can include multiple mapping objects, with each mapping object containing linear, nonlinear, and offset blocks in parallel. For example, consider the following equation:

$$F(x)={L}^{T}(x-r)+g\left(Q(x-r)\right)+d$$

Here,

*x*is a vector of the regressors, and*r*is the mean of*x*. $$F(x)={L}^{T}(x-r)+{y}_{0}$$ is the output of the linear function block. $$g\left(Q(x-r)\right)+{y}_{0}$$ represents the output of the nonlinear function block.*Q*is a projection matrix that makes the calculations well-conditioned.*d*is a scalar offset that is added to the combined outputs of the linear and nonlinear blocks. The exact form of*F*(*x*) depends on your choice of output function. You can select from the available mapping objects, such as tree-partition networks, wavelet networks, and multilayer neural networks. You can also exclude either the linear or the nonlinear function block from the output function.When estimating a nonlinear ARX model, the software computes the model parameter values, such as

*L*,*r*,*d*,*Q*, and other parameters specifying*g*.

The resulting nonlinear ARX models are `idnlarx`

objects that store all model data, including model regressors and
parameters of the output function. For more information about these objects, see Nonlinear Model Structures.

Typically, you use nonlinear ARX models as black-box structures. The nonlinear
function of the nonlinear ARX model is a flexible nonlinearity estimator with
parameters that need not have physical significance. You can estimate nonlinear ARX
in the **System Identification** app or at the command
line using the `nlarx`

command. You can use uniformly
sampled time-domain input-output data or time-series data (no inputs) for estimating
nonlinear ARX models. Your data can have one or more input and output channels. You
cannot use frequency-domain data for estimation.

### Nonlinear ARX Model Orders and Delay

You can use the orders and delays of a nonlinear ARX model to define the linear regressors of the model. The orders and delay are defined as follows:

*na*— Number of past output terms used to predict the current output.*nb*— Number of past input terms used to predict the current output.*nk*— Delay from input to the output in terms of the number of samples.

The meaning of *na*, *nb*, and
*nk* is similar to that for linear ARX model parameters. Orders
are specified as scalars for SISO data, and as
*ny*-by-*nu* matrices for MIMO data, where
*ny* and *nu* are the number of outputs and
inputs. If you are not sure what values to use for the orders and delays, you can
estimate them as described in Preliminary Step – Estimating Model Orders and Input Delays. Such an
estimate is based on linear ARX models and only provides initial guidance. The best
orders for a linear ARX model might not be the best orders for a nonlinear ARX
model.

System Identification Toolbox™ software computes linear regressors using the model orders and delays.
For example, suppose that you specify `na = 2`

, ```
nb =
3
```

, and `nk = 5`

for a SISO model with input
*u* and output *y*. The toolbox computes
linear regressors *y*(*t*-2),
*y*(*t*-1),*u(**t*-5),
*u*(*t*-6), and
*u*(*t*-7).

Rather than use ARX model order to specify regressor delays, you can also specify regressors directly to capture more complex behavior. When you specify linear regressors directly, you can include nonconsecutive delay terms. You can also specify polynomial regressors and custom regressors. For more information, see Estimate Nonlinear ARX Models in the App and Estimate Nonlinear ARX Models at the Command Line.