# ivx

ARX model estimation using instrumental variable method with arbitrary instruments

## Syntax

``````sys = ivx(tt,[na nb nk],x)``````
``sys = ivx(u,y,[na nb nk],x)``
``sys = ivx(data,[na nb nk],x)``
``sys = ivx(___,max_size)``
``sys = ivx(___,Name,Value)``
``[sys,ic] = ivx(___)``

## Description

### Estimate ARX Polynomial Model

``````sys = ivx(tt,[na nb nk],x)``` estimates an ARX polynomial model `sys` using the time-domain data in the timetable `tt`. `[na nb nk]` specifies the ARX structure orders of the A and B polynomials and the input-to-output delay, expressed in the number of samples. `x` specifies the instrument variable matrix.The software estimates `sys` using the instrumental variable method with arbitrary instruments.An ARX model is represented as:$A\left(q\right)y\left(t\right)=B\left(q\right)u\left(t-nk\right)+v\left(t\right)$For more details on the ARX model structure, see `arx`.```
````sys = ivx(u,y,[na nb nk],x)` uses the time-domain input and output signals in the comma-separated matrices `u`,`y`. The software assumes that the data sample time is one second. To change the sample time, set `Ts` using name-value syntax.```
````sys = ivx(data,[na nb nk],x)` uses the time-domain or frequency-domain data in the data object `data`. Use this syntax especially when you want to estimate a model using frequency-domain or frequency-response data, or when you want to take advantage of the additional information, such as data sample time or experiment labeling, that data objects provide.```
````sys = ivx(___,max_size)` specifies the maximum size of matrices formed during estimation.You can use this syntax with any of the previous input-argument combinations.```

### Specify Additional Model Options

````sys = ivx(___,Name,Value)` specifies additional options using one or more name-value arguments.```

### Return Estimated Initial Conditions

````[sys,ic] = ivx(___)` returns the estimated initial conditions as an `initialCondition` object. For more information on `ic`, see the `ic` argument description. Use this syntax if you plan to simulate or predict the model response using the same estimation input data and then compare the response with the same estimation output data. Incorporating the initial conditions yields a better match during the first part of the simulation.```

## Input Arguments

collapse all

Timetable-based estimation data, specified as a `timetable` that uses a regularly spaced time vector. `tt` contains variables representing input and output channels.

For multiexperiment data, specify `tt` as an Ne-by-1 cell array of timetables, where Ne is the number of experiments. The sample times of all the experiments must match.

To select individual input and output channels to use for estimation, use the `InputName` and `OutputName` name-value arguments.

For example, use the following command to select timetable variables `"u1"` and `"u3"` as inputs and the variables `"y2"` and `"y4"` as outputs.

```sys = ivx(tt,__,'InputName',["u1" "u3"],'OutputName',["y2" "y4"])```

For more information about working with estimation data types, see Data Domains and Data Types in System Identification Toolbox.

Estimation data, specified for SISO systems as a comma-separated pair of Ns-element numeric column vectors that contain uniformly sampled input and output time-domain signal values. Here, Ns is the number of samples.

For MIMO systems, specify `u`,`y` as an input/output matrix pair with the following dimensions:

• `u`Ns-by-Nu, where Nu is the number of inputs

• `y`Ns-by-Ny, where Ny is the number of outputs

For multiexperiment data, specify `u`,`y` as a pair of 1-by-Ne cell arrays, where Ne is the number of experiments. The sample times of all the experiments must match.

For more information about working with estimation data types, see Data Domains and Data Types in System Identification Toolbox.

Estimation data, specified as an `iddata`, `idfrd`, or `frd` (Control System Toolbox) object.

When using frequency-domain data, there must be only one output.

For more information about working with estimation data types, see Data Domains and Data Types in System Identification Toolbox.

ARX polynomial orders and delay, specified as a row vector of integers or integer matrices.

• For SISO models, `[na nb nk]` is a 1-by-3 row vector of nonnegative integers that correspond to the orders of the A(q) and B(q) polynomials and the input-to-output delays, respectively. The polynomial order is equal to the number of coefficients to estimate in that polynomial.

• For a model with Ny outputs and Nu inputs:

• `na` is the order of polynomial A(q), specified as an Ny-by-Ny matrix of nonnegative integers.

• `nb` is the order of polynomial B(q) + 1, specified as an Ny-by-Nu matrix of nonnegative integers.

• `nk` is the input-output delay, also known as the transport delay, specified as an Ny-by-Nu matrix of nonnegative integers.

.

For more details on the ARX model structure, see `arx`.

Instrument variable matrix that contains the arbitrary instruments for use in the instrumental variable method, specified as a matrix that is the same size as the output data, `data.y`. For multi-experiment data, specify `x` as a cell array with one entry for each experiment.

The instruments used are analogous to the regression vector, with `y` replaced by `x`.

Maximum matrix size for any matrix formed by the algorithm for estimation, specified as a positive integer. Specify `max_size` as a reasonably large value.

### Name-Value Arguments

Specify optional pairs of arguments as `Name1=Value1,...,NameN=ValueN`, where `Name` is the argument name and `Value` is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: `InputName=["u1" "u3"]` specifies timetable variables `u1` `u3` as the input variables. Alternatively, you can use `'InputName',["u1","u3"]`.

Input channel names, specified as a string, character vector, string array, or cell array of character vectors.

If you are using a timetable for the data source, the names in `InputName` must be a subset of the timetable variables.

Example: `sys = ivx(tt,__,'InputName',["u1" "u2"])` selects the variables `u1` and `u2` as the input channels from the timetable `tt` to use for the estimation.

Output channel names, specified as a string, character vector, string array, or cell array of character vectors.

If you are using a timetable for the data source, the names in `OutputName` must be a subset of the timetable variables.

Example: `sys = ivx(tt,__,'OutputName',["y1" "y3"])` selects the variables `y1` and `y3` as the output channels from the timetable `tt` to use for the estimation.

## Output Arguments

collapse all

ARX model that fits the estimation data, returned as a discrete-time `idpoly` object. This model is created using the specified model orders, delays, and estimation options. `ivx` does not return any estimated covariance information for `sys`.

Information about the estimation results and options used is stored in the `Report` property of the model. `Report` has the following fields:

Report FieldDescription
`Status`

Summary of the model status, which indicates whether the model was created by construction or obtained by estimation.

`Method`

Estimation command used.

`InitialCondition`

Handling of initial conditions during model estimation, returned as one of the following values:

• `'zero'` — The initial conditions were set to zero.

• `'estimate'` — The initial conditions were treated as independent estimation parameters.

• `'backcast'` — The initial conditions were estimated using the best least squares fit.

This field is especially useful to view how the initial conditions were handled when the `InitialCondition` option in the estimation option set is `'auto'`.

`Fit`

Quantitative assessment of the estimation, returned as a structure. See Loss Function and Model Quality Metrics for more information on these quality metrics. The structure has the following fields:

FieldDescription
`FitPercent`

Normalized root mean squared error (NRMSE) measure of how well the response of the model fits the estimation data, expressed as the percentage fitpercent = 100(1-NRMSE).

`LossFcn`

Value of the loss function when the estimation completes.

`MSE`

Mean squared error (MSE) measure of how well the response of the model fits the estimation data.

`FPE`

Final prediction error for the model.

`AIC`

Raw Akaike Information Criteria (AIC) measure of model quality.

`AICc`

Small-sample-size corrected AIC.

`nAIC`

Normalized AIC.

`BIC`

Bayesian Information Criteria (BIC).

`Parameters`

Estimated values of model parameters.

`OptionsUsed`

Option set used for estimation. If no custom options were configured, this is a set of default options. See `arxOptions` for more information.

`RandState`

State of the random number stream at the start of estimation. Empty, `[]`, if randomization was not used during estimation. For more information, see `rng`.

`DataUsed`

Attributes of the data used for estimation, returned as a structure with the following fields.

FieldDescription
`Name`

Name of the data set.

`Type`

Data type.

`Length`

Number of data samples.

`Ts`

Sample time.

`InterSample`

Input intersample behavior, returned as one of the following values:

• `'zoh'` — Zero-order hold maintains a piecewise-constant input signal between samples.

• `'foh'` — First-order hold maintains a piecewise-linear input signal between samples.

• `'bl'` — Band-limited behavior specifies that the continuous-time input signal has zero power above the Nyquist frequency.

`InputOffset`

Offset removed from time-domain input data during estimation. For nonlinear models, it is `[]`.

`OutputOffset`

Offset removed from time-domain output data during estimation. For nonlinear models, it is `[]`.

For more information on using `Report`, see Estimation Report.

Estimated initial conditions, returned as an `initialCondition` object or an object array of `initialCondition` values.

• For a single-experiment data set, `ic` represents, in state-space form, the free response of the transfer function model (A and C matrices) to the estimated initial states (x0).

• For a multiple-experiment data set with Ne experiments, `ic` is an object array of length Ne that contains one set of `initialCondition` values for each experiment.

For more information, see `initialCondition`.

## Tips

• Use `iv4` first for IV estimation to identify ARX polynomial models where the instruments `x` are chosen automatically. Use `ivx` for nonstandard situations. For example, use `ivx` when there is feedback present in the data or when instruments other than those used in `iv4` need to be tried. You can also use `ivx` to automatically generate instruments from certain custom defined filters.

## References

[1] Ljung, Lennart. System Identification: Theory for the User, 2nd ed. Prentice Hall Information and System Sciences Series. Upper Saddle River, NJ: Prentice Hall PTR, 1999.

## Version History

Introduced before R2006a