Documentation

This is machine translation

Translated by
Mouse over text to see original. Click the button below to return to the English verison of the page.

arx

Estimate parameters of ARX or AR model using least squares

Syntax

```sys = arx(data,[na nb nk])sys = arx(data,[na nb nk],Name,Value)sys = arx(data,[na nb nk],___,opt)```

Description

 Note:   `arx` does not support continuous-time estimations. Use `tfest` instead.

```sys = arx(data,[na nb nk])``` returns an ARX structure polynomial model, `sys`, with estimated parameters and covariances (parameter uncertainties) using the least-squares method and specified `orders`.

```sys = arx(data,[na nb nk],Name,Value)``` estimates a polynomial model with additional options specified by one or more `Name,Value` pair arguments.

```sys = arx(data,[na nb nk],___,opt)``` specifies estimation options that configure the estimation objective, initial conditions and handle input/output data offsets.

Input Arguments

 `data` Estimation data. Specify `data` as an `iddata` object, an `frd` object, or an `idfrd` frequency-response-data object. `[na nb nk]` Polynomial orders. `[na nb nk]` define the polynomial orders of an ARX model. `na` — Order of the polynomial A(q). Specify `na` as an Ny-by-Ny matrix of nonnegative integers. Ny is the number of outputs.`nb` — Order of the polynomial B(q) + 1.`nb` is an Ny-by-Nu matrix of nonnegative integers. Ny is the number of outputs and Nu is the number of inputs.`nk` — Input-output delay expressed as fixed leading zeros of the B polynomial. Specify `nk` as an Ny-by-Nu matrix of nonnegative integers. Ny is the number of outputs and Nu is the number of inputs. `opt` Estimation options. `opt` is an options set that specifies estimation options, including: input/output data offsetsoutput weight Use `arxOptions` to create the options set.

Name-Value Pair Arguments

Specify optional comma-separated pairs of `Name,Value` arguments. `Name` is the argument name and `Value` is the corresponding value. `Name` must appear inside single quotes (`' '`). You can specify several name and value pair arguments in any order as `Name1,Value1,...,NameN,ValueN`.

 `'InputDelay'` Input delays. `InputDelay` is a numeric vector specifying a time delay for each input channel. Specify input delays in integer multiples of the sample time `Ts`. For example, `InputDelay = 3` means a delay of three sampling periods. For a system with `Nu` inputs, set `InputDelay` to an `Nu`-by-1 vector, where each entry is a numerical value representing the input delay for the corresponding input channel. You can also set `InputDelay` to a scalar value to apply the same delay to all channels. Default: 0 for all input channels `'IODelay'` Transport delays. `IODelay` is a numeric array specifying a separate transport delay for each input/output pair. Specify transport delays as integers denoting delay of a multiple of the sample time, `Ts`. For a MIMO system with `Ny` outputs and `Nu` inputs, set `IODelay` to a `Ny`-by-`Nu` array, where each entry is a numerical value representing the transport delay for the corresponding input/output pair. You can also set `IODelay` to a scalar value to apply the same delay to all input/output pairs. Useful as a replacement for the `nk` order, you can factor out `max(nk-1,0)` lags as the `IODelay` value. Default: 0 for all input/output pairs `'IntegrateNoise'` Specify integrators in the noise channels. Adding an integrator creates an ARIX model represented by: `$A\left(q\right)y\left(t\right)=B\left(q\right)u\left(t-nk\right)+\frac{1}{1-{q}^{-1}}e\left(t\right)$` where,$\frac{1}{1-{q}^{-1}}$ is the integrator in the noise channel, e(t). `IntegrateNoise` is a logical vector of length `Ny`, where `Ny` is the number of outputs. Default: `false(Ny,1)`, where `Ny` is the number of outputs

Output Arguments

`sys`

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.

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.

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 a percentage.

`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` in the MATLAB® documentation.

`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.

Examples

collapse all

Generate input data based on a specified ARX model, and then use this data to estimate an ARX model.

```A = [1 -1.5 0.7]; B = [0 1 0.5]; m0 = idpoly(A,B); u = iddata([],idinput(300,'rbs')); e = iddata([],randn(300,1)); y = sim(m0,[u e]); z = [y,u]; m = arx(z,[2 2 1]); ```

Use `arxRegul` to automatically determine regularization constants and use the values for estimating an FIR model of order 50.

Obtain `L` and `R` values.

```load regularizationExampleData eData; orders = [0 50 0]; [L,R] = arxRegul(eData,orders); ```

By default, the `TC` kernel is used.

Use the returned `Lambda` and `R` values for regularized ARX model estimation.

```opt = arxOptions; opt.Regularization.Lambda = L; opt.Regularization.R = R; model = arx(eData,orders,opt); ```

More About

collapse all

ARX structure

The ARX model structure is :

`$\begin{array}{l}y\left(t\right)+{a}_{1}y\left(t-1\right)+...+{a}_{na}y\left(t-na\right)=\\ {b}_{1}u\left(t-nk\right)+...+{b}_{nb}u\left(t-nb-nk+1\right)+e\left(t\right)\end{array}$`

The parameters `na` and `nb` are the orders of the ARX model, and `nk` is the delay.

• $y\left(t\right)$— Output at time $t$.

• ${n}_{a}$ — Number of poles.

• ${n}_{b}$ — Number of zeroes plus 1.

• ${n}_{k}$ — Number of input samples that occur before the input affects the output, also called the dead time in the system.

• $y\left(t-1\right)\dots y\left(t-{n}_{a}\right)$ — Previous outputs on which the current output depends.

• $u\left(t-{n}_{k}\right)\dots u\left(t-{n}_{k}-{n}_{b}+1\right)$ — Previous and delayed inputs on which the current output depends.

• $e\left(t\right)$ — White-noise disturbance value.

A more compact way to write the difference equation is

`$A\left(q\right)y\left(t\right)=B\left(q\right)u\left(t-{n}_{k}\right)+e\left(t\right)$`

q is the delay operator. Specifically,

`$A\left(q\right)=1+{a}_{1}{q}^{-1}+\dots +{a}_{{n}_{a}}{q}^{-{n}_{a}}$`
`$B\left(q\right)={b}_{1}+{b}_{2}{q}^{-1}+\dots +{b}_{{n}_{b}}{q}^{-{n}_{b}+1}$`

Time Series Models

For time-series data that contains no inputs, one output and ```orders = na```, the model has AR structure of order `na`.

The AR model structure is

`$A\left(q\right)y\left(t\right)=e\left(t\right)$`

Multiple Inputs and Single-Output Models

For multiple-input systems, `nb` and `nk` are row vectors where the `i`th element corresponds to the order and delay associated with the `i`th input.

Multi-Output Models

For models with multiple inputs and multiple outputs, `na`, `nb`, and `nk` contain one row for each output signal.

In the multiple-output case, `arx` minimizes the trace of the prediction error covariance matrix, or the norm

`$\sum _{t=1}^{N}{e}^{T}\left(t\right)e\left(t\right)$`

To transform this to an arbitrary quadratic norm using a weighting matrix `Lambda`

`$\sum _{t=1}^{N}{e}^{T}\left(t\right){\Lambda }^{-1}e\left(t\right)$`

use the syntax

```opt = arxOptions('OutputWeight',inv(lambda)) m = arx(data,orders,opt) ```

Estimating Initial Conditions

For time-domain data, the signals are shifted such that unmeasured signals are never required in the predictors. Therefore, there is no need to estimate initial conditions.

For frequency-domain data, it might be necessary to adjust the data by initial conditions that support circular convolution.

Set the `InitialCondition` estimation option (see `arxOptions`) to one the following values:

• `'zero'` — No adjustment.

• `'estimate'` — Perform adjustment to the data by initial conditions that support circular convolution.

• `'auto'` — Automatically choose between `'zero'` and `'estimate'` based on the data.

Algorithms

QR factorization solves the overdetermined set of linear equations that constitutes the least-squares estimation problem.

The regression matrix is formed so that only measured quantities are used (no fill-out with zeros). When the regression matrix is larger than `MaxSize`, data is segmented and QR factorization is performed iteratively on these data segments.

Without regularization, the ARX model parameters vector θ is estimated by solving the normal equation:

$\left({J}^{T}J\right)\theta ={J}^{T}y$

where J is the regressor matrix and y is the measured output. Therefore,

$\theta ={\left({J}^{T}J\right)}^{-1}{J}^{T}y$.

Using regularization adds a regularization term:

$\theta ={\left({J}^{T}J+\lambda R\right)}^{-1}{J}^{T}y$

where, λ and R are the regularization constants. See `arxOptions` for more information on the regularization constants.

See Also

Introduced before R2006a

Was this topic helpful?

Get trial now