0% found this document useful (0 votes)
293 views14 pages

Arx Models

The arx function estimates the parameters of ARX, ARIX, AR, and ARI models from input-output data using a least squares method. It returns an idpoly or idarx object containing the estimated model parameters. The input arguments are an iddata object containing the estimation data, the polynomial orders and delays in a vector, and optional property name-value pairs or estimation options. Examples are provided to demonstrate estimating ARX, AR, and ARIX models.

Uploaded by

JoãoEdgar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
293 views14 pages

Arx Models

The arx function estimates the parameters of ARX, ARIX, AR, and ARI models from input-output data using a least squares method. It returns an idpoly or idarx object containing the estimated model parameters. The input arguments are an iddata object containing the estimation data, the polynomial orders and delays in a vector, and optional property name-value pairs or estimation options. Examples are provided to demonstrate estimating ARX, AR, and ARIX models.

Uploaded by

JoãoEdgar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

arx

Estimate the parameters of an ARX or AR model.

Syntax
m = arx(data,orders)
m = arx(data,'na',na,'nb',nb,'nk',nk)
m= arx(data,orders,'Property1',Value1,...,'PropertyN',ValueN)

Description

The parameters of the ARX model structure

are estimated using the least-squares method.

data is an iddata object that contains the output-input data. orders is given as


orders = [na nb nk]

defining the orders and delay of the ARX model. Specifically,

See Polynomial Representation of Transfer Functions in the "Tutorial"


chapter for more information. The model orders can also be defined by
explicit pairs (...,'na',na,'nb',nb,'nk',nk,...).

m isreturned as the least-squares estimates of the parameters. For single-


output data this is an idpoly object, otherwise an idarx object.

For a time series, data contains no input channels and orders = na. Then an


AR model of order na for y is computed.

Models with several inputs


are handled by allowing nb and nk to be row vectors defining the orders and
delays associated with each input.

Models with several inputs and several outputs are handled by


allowing na, nb, and nk to contain one row for each output number.
See Multivariable ARX Models: The idarx Model in the "Tutorial" chapter for
exact definitions.

The algorithm and model structure are affected by the property name/property
value list in the input argument.

Useful options are reached by the properties 'Focus', 'InputDelay',


and 'MaxSize'.

See Algorithm Properties for details of these properties and possible values

When the true noise term   in the ARX model structure is not white noise
and na is nonzero, the estimate does not give a correct model. It is then better
to use armax, bj, iv4, or oe.

Examples

Here is an example that generates data and estimates 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]);

Algorithm

The least-squares estimation problem is an overdetermined set of linear


equations that is solved using QR-factorization.

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, the
QR-factorization is performed in a for-loop.

arx
Estimate parameters of ARX, ARIX, AR, or ARI model
collapse all in page
Syntax
sys = arx(data,[na nb nk])
sys = arx(data,[na nb nk],Name,Value)
sys = arx(data,[na nb nk],___,opt)
[sys,ic] = arx(___)

Description
example
sys = arx(data,[na nb nk]) estimates the parameters of an ARX or
an AR idpoly model sys using a least-squares method and the polynomial orders specified
in [na nb nk]. The model properties include covariances (parameter uncertainties) and
goodness of fit between the estimated and measured data.
example
sys = arx(data,[na nb nk],Name,Value) specifies additional options using one or more
name-value pair arguments. For instance, using the name-value pair
argument 'IntegrateNoise',1 estimates an ARIX or ARI structure model, which is useful for
systems with nonstationary disturbances.
example
sys = arx(data,[na nb nk],___,opt) specifies estimation options using the option set opt.
Specify opt after all other input arguments.
example
[sys,ic] = arx(___) returns the estimated initial conditions as an initialCondition object.
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.
Examples
collapse all
ARX Model
View MATLAB Command
Generate output data based on a specified ARX model and use the output data to estimate the
model.
Specify a polynomial model sys0 with the ARX structure. The model includes an input delay of
one sample, expressed as a leading zero in the B polynomial.
A = [1 -1.5 0.7];
B = [0 1 0.5];
sys0 = idpoly(A,B);
Generate a measured input signal u that contains random binary noise and an error
signal e that contains normally distributed noise. With these signals, simulate the measured
output signal y of sys0.
u = iddata([],idinput(300,'rbs'));
e = iddata([],randn(300,1));
y = sim(sys0,[u e]);
Combine y and u into a single iddata object z. Estimate a new ARX model using z and the
same polynomial orders and input delay as the original model.
z = [y,u];
sys = arx(z,[2 2 1])
sys =
Discrete-time ARX model: A(z)y(t) = B(z)u(t) + e(t)
A(z) = 1 - 1.524 z^-1 + 0.7134 z^-2
B(z) = z^-1 + 0.4748 z^-2

Sample time: 1 seconds

Parameterization:
Polynomial orders: na=2 nb=2 nk=1
Number of free coefficients: 4
Use "polydata", "getpvec", "getcov" for parameters and their
uncertainties.

Status:
Estimated using ARX on time domain data "z".
Fit to estimation data: 81.36% (prediction focus)
FPE: 1.025, MSE: 0.9846
The output displays the polynomial containing the estimated parameters alongside other
estimation details. Under Status, Fit to estimation data shows that the estimated model
has 1-step-ahead prediction accuracy above 80%.
AR Model
View MATLAB Command
Estimate a time-series AR model using the arx function. An AR model has no measured input.
Load the data, which contains the time series z9 with noise.
load iddata9 z9
Estimate a fourth-order AR model by specifying only the na order in [na nb nk].
sys = arx(z9,4);
Examine the estimated A polynomial parameters and the fit of the estimate to the data.
param = sys.Report.Parameters.ParVector
param = 4×1

-0.7923
-0.4780
-0.0921
0.4698

fit = sys.Report.Fit.FitPercent
fit = 79.4835
ARIX Model
View MATLAB Command
Estimate the parameters of an ARIX model. An ARIX model is an ARX model with integrated
noise.
Specify a polynomial model sys0 with an ARX structure. The model includes an input delay of
one sample, expressed as a leading zero in B.
A = [1 -1.5 0.7];
B = [0 1 0.5];
sys0 = idpoly(A,B);
Simulate the output signal of sys0 using the random binary input signal u and the normally
distributed error signal e.
u = iddata([],idinput(300,'rbs'));
e = iddata([],randn(300,1));
y = sim(sys0,[u e]);
Integrate the output signal and store the result yi in the iddata object zi.
yi = iddata(cumsum(y.y),[]);
zi = [yi,u];
Estimate an ARIX model from zi. Set the name-value pair
argument 'IntegrateNoise' to true.
sys = arx(zi,[2 2 1],'IntegrateNoise',true);
Predict the model output using 5-step prediction and compare the result with yi.
compare(zi,sys,5)

ARX Model with Regularization


View MATLAB Command
Use arxRegul to determine regularization constants automatically and use the values for
estimating an FIR model with an order of 50.
Obtain the lambda and R values.
load regularizationExampleData eData;
orders = [0 50 0];
[lambda,R] = arxRegul(eData,orders);
Use the returned lambda and R values for regularized ARX model estimation.
opt = arxOptions;
opt.Regularization.Lambda = lambda;
opt.Regularization.R = R;
sys = arx(eData,orders,opt);
Obtain Initial Conditions
View MATLAB Command
Load the data.
load iddata1ic z1i
Estimate a second-order ARX model sys and return the initial conditions in ic.
na = 2;
nb = 2;
nk = 1;
[sys,ic] = arx(z1i,[na nb nk]);
ic
ic =
initialCondition with properties:

A: [2x2 double]
X0: [2x1 double]
C: [0 2]
Ts: 0.1000

ic is an initialCondition object that encapsulates the free response of sys, in state-space


form, to the initial state vector in X0. You can incorporate ic when you simulate sys with
the z1i input signal and compare the response with the z1i output signal.

Input Arguments
collapse all
data — Estimation data
iddata object | frd object | idfrd object
Estimation data, specified as an iddata object, an frd (Control System Toolbox) object, or
an idfrd frequency-response object. For AR and ARI time-series models, the input channel
in data must be empty.
[na nb nk] — Polynomial orders and delays
integer row vector | row vector of integer matrices | scalar
Polynomial orders and delays for the model, specified as a 1-by-3 vector or vector of
matrices [na nb nk]. The polynomial order is equal to the number of coefficients to estimate in
that polynomial.
For an AR or ARI time-series model, which has no input, set [na nb nk] to the scalar na. For
an example, see AR Model.
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. nk is represented in ARX models by fixed leading
zeros in the B polynomial.
For instance, suppose that without transport delays, sys.b is [5 6].
o Because sys.b + 1 is a second-order polynomial, nb = 2.
o Specify a transport delay of nk = 3. Specifying this delay adds three leading
zeros to sys.b so that sys.b is now [0 0 0 5 6], while nb remains equal to
2.
o These coefficients represent the polynomial B(q) = 5 q-3 + 6q-4.
You can also implement transport delays using the name-value pair
argument 'IODelay'.
.
Example: arx(data,[2 1 1]) computes, from an iddata object, a second-order ARX model
with one input channel that has an input delay of one sample.
opt — Estimation options
arxOptions option set
Estimation options for ARX model identification, specified as an arOptions option set. Options
specified by opt include the following:

 Initial condition handling — Use this option only for frequency-domain data. For time-
domain data, the signals are shifted such that unmeasured signals are never required in
the predictors.
 Input and output data offsets — Use these options to remove offsets from time-domain
data during estimation.
 Regularization — Use this option to control the tradeoff between bias and variance
errors during the estimation process.
For more information, see arxOptions. For an example, see ARX Model with Regularization.

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 quotes. You can specify
several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.
Example: 'IntegrateNoise',true adds an integrator in the noise source s

'InputDelay' — Input delays
0 (default) | integer scalar | positive integer vector
Input delays expressed as integer multiples of the sample time, specified as the comma-
separated pair consisting of 'InputDelay' and one of the following:

 Nu-by-1 vector, where Nu is the number of inputs — Each entry is a numerical value
representing the input delay for the corresponding input channel.
 Scalar value — Apply the same delay to all input channels.
Example: arx(data,[2 1 3],'InputDelay',1) estimates a second-order ARX model with
one input channel that has an input delay of three samples.
'IODelay' — Transport delays
0 (default) | integer scalar | integer array
Transport delays for each input-output pair, expressed as integer multiples of the sample time,
and specified as the comma-separated pair consisting of 'IODelay' and one of the following:

 Ny-by-Nu matrix, where Ny is the number of outputs and Nu is the number of inputs —


Each entry is an integer value representing the transport delay for the corresponding
input-output pair.
 Scalar value — Apply the same delay is applied to all input-output pairs. This approach
is useful when the input-output delay parameter nk results in a large number of fixed
leading zeros in the B polynomial. You can factor out max(nk-1,0) lags by moving
those lags from nk into the 'IODelay' value.
For instance, suppose that you have a system with two inputs, where the first input has
a delay of three samples and the second input has a delay of six samples. Also
suppose that the B polynomials for these inputs are order n. You can express these
delays using the following:
o nk = [3 6] — This results in B polynomials of [0 0 0 b11 ... b1n] and [0
0 0 0 0 0 b21 ... b2n].
o nk = [3 6] and 'IODelay',3 — This results in B polynomials of [b11 ...
b1n] and [0 0 0 b21 ... b2n].
'IntegrateNoise' — Addition of integrators in noise channel
false (default) | logical vector
Addition of integrators in the noise channel, specified as the comma-separated pair consisting
of 'IntegrateNoise' and a logical vector of length Ny, where Ny is the number of outputs.
Setting 'IntegrateNoise' to true for a particular output creates an ARIX or ARI model for
that channel. Noise integration is useful in cases where the disturbance is nonstationary.
When using 'IntegrateNoise', you must also integrate the output channel data. For an
example, see ARIX Model.

Output Arguments
collapse all
sys — ARX model
idpoly object
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 Field Description

Status Summary of the model status, which indicates whether the model was created by construction or obtained by estim

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 o
Fit Quantitative assessment of the estimation, returned as a structure. See Loss Function and Model Quality Metrics f
Field Description

FitPercent Normalized root mean squared error (NRMSE) measure of how well the response of the model f

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 dat

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 arxOpt
RandState State of the random number stream at the start of estimation. Empty, [], if randomization was not used during es
DataUsed Attributes of the data used for estimation, returned as a structure with the following fields:
Report Field Description

Field Description

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 betw
 'foh' — First-order hold maintains a piecewise-linear input signal betwee
 'bl' — Band-limited behavior specifies that the continuous-time input sig

InputOffset Offset removed from time-domain input data during estimation. For nonlinear models,
OutputOffset Offset removed from time-domain output data during estimation. For nonlinear models

For more information on using Report, see Estimation Report.


ic — Initial conditions
initialCondition object | object array of initialCondition values
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. For an example of using this argument,
see Obtain Initial Conditions.

More About
collapse all

ARX Structure
The ARX model name stands for Autoregressive with Extra Input, because, unlike the AR
model, the ARX model includes an input term. ARX is also known as Autoregressive with
Exogenous Variables, where the exogenous variable is the input term. The ARX model structure
is given by the following equation:

y(t)+a1y(t−1)+...+anay(t−na)=b1u(t−nk)+...+bnbu(t−nb−nk+1)+e(t)
The parameters na and nb are the orders of the ARX model, and nk is the delay.

 y(t) — Output at time t


 na — Number of poles
 nb — Number of zeros
 nk — Number of input samples that occur before the input affects the output, also called
the dead time in the system
 y(t−1)…y(t−na) — Previous outputs on which the current output depends
 u(t−nk)…u(t−nk−nb+1) — Previous and delayed inputs on which the current output
depends
 e(t) — White-noise disturbance value
A more compact way to write the difference equation is

A(q)y(t)=B(q)u(t−nk)+e(t)
q  is the delay operator. Specifically,
−n
A(q)=1+a1q−1+…+anaq a

−n +1
B(q)=b1+b2q−1+…+bnbq b

ARIX Model
The ARIX (Autoregressive Integrated with Extra Input) model is an ARX model with an
integrator in the noise channel. The ARIX model structure is given by the following equation:
−1
A(q)y(t)=B(q)u(t−nk)+ e(t)
11−q
−1
where   is the integrator in the noise channel, e(t).
11−q

AR Time-Series Models
For time-series data that contains no inputs, one output, and the A polynomial order na, the
model has an AR structure of order na.
The AR (Autoregressive) model structure is given by the following equation:

A(q)y(t)=e(t)
ARI Model
The ARI (Autoregressive Integrated) model is an AR model with an integrator in the noise
channel. The ARI model structure is given by the following equation:
−1
A(q)y(t)= e(t)
11−q
Multiple-Input, Single-Output Models
For multiple-input, single-output systems (MISO) with nu inputs, nb and nk are row vectors
where the ith element corresponds to the order and delay associated with the ith input in column
vector u(t). Similarly, the coefficients of the B polynomial are row vectors. The ARX MISO
structure is then given by the following equation:

A(q)y(t)=B1(q)u1(t−nk1)+B2(q)u2(t−nk2)+⋯+Bnu(q)unu(t−nknu)
Multiple-Input, Multiple-Output Models
For multiple-input, multiple-output systems, 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


N t=1eT(t)e(t)
To transform this norm to an arbitrary quadratic norm using a weighting matrix Lambda


N t=1eT(t)Λ−1e(t)
use the following syntax:
opt = arxOptions('OutputWeight',inv(lambda))
m = arx(data,orders,opt)

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 of the following
values:
 'zero' — No adjustment
 'estimate' — Perform adjustment to the data by initial conditions that support circular
convolution
 'auto' — Automatically choose 'zero' or 'estimate' based on the data

Algorithms
QR factorization solves the overdetermined set of linear equations that constitutes the least-
squares estimation problem.
Without regularization, the ARX model parameters vector θ is estimated by solving the normal
equation

(JTJ)θ=JTy
where J is the regressor matrix and y is the measured output. Therefore,
−1
θ=(JTJ) JTy
Using regularization adds the regularization term
−1
θ=(JTJ+λR) JTy
where λ and R are the regularization constants. For more information on the regularization
constants, see arxOptions.
When the regression matrix is larger than the MaxSize specified in arxOptions, the data is
segmented and QR factorization is performed iteratively on the data segments.

See Also

armax

Estimate the parameters of an ARMAX or ARMA model.

Syntax
m = armax(data,orders)
m = armax(data,'na',na,'nb',nb,'nc',nc,'nk',nk)
m = armax(data,orders,'Property1',Value1,...,'PropertyN',ValueN)

Description
armax returns m asan idpoly object with the resulting parameter estimates,
together with estimated covariances.

armax estimates the parameters of the ARMAX model structure

using a prediction error method.

data isan iddata object containing the output-input data. The model orders


can be specified as (...,'na',na,'nb',nb,...) or by setting the
argument orders to
orders = [na nb nc nk]

The parameters na, nb, and nc are the orders of the ARMAX model, and nk is


the delay. Specifically,

Alternatively, you can specify the vector as


orders = mi

where mi is an initial guess at the ARMAX model given in idpoly format.


See Polynomial Representation of Transfer Functions in the "Tutorial" chapter
for more information.

For multi-input systems, nb and nk are row vectors, such that the k-th entry


corresponds to the order and delay associated with the k-th input.

If data has no input channels and just one output channel (i.e., it is a time
series) then
orders = [na nc],

and armax calculates an ARMA model for the time series

The structure and the estimation algorithm are affected by any property
name/property value pairs that are set in the input argument list. Useful
properties
are 'Focus', 'InitialState', 'Trace', 'MaxIter', 'Tolerance', 'LimitError'
, and 'FixedParameter'.

See Algorithm Properties, idpoly and idmodel for details of these properties


and their possible values.

armax does not support multi-output models. Use the state-space model for this
case (see n4sid and pem).

Algorithm

A robustified quadratic prediction error criterion is minimized using an


iterative search algorithm, whose details are governed by the
properties 'SearchDirection', 'MaxIter','Tolerance' and 'Advanced'. The
iterations are terminated when MaxIter is reached, when the expected
improvement is less than Tolerance, or when a lower value of the criterion
cannot be found. Information about the search is contained
in m.EstimationInfo.

The initial parameter values for the iterative search, if not specified in orders,
are constructed in a special four-stage LS-IV algorithm.

The cut-off value for the robustification is based on the property LimitError as


well as on the estimated standard deviation of the residuals from the initial
parameter estimate. It is not recalculated during the minimization.

A stability test of the predictor is performed, so as to assure that only models


corresponding to stable predictors are tested. Generally, both   and   
(if applicable) must have all their zeros inside the unit circle.

Information about the minimization is furnished to the screen in case the


property 'Trace' is set to 'On' or 'Full'. With 'Trace' = 'Full', current and
previous parameter estimates (in column vector form, listing parameters in
alphabetical order) as well as the values of the criterion function are given.
The Gauss-Newton vector and its norm are also displayed. With 'Trace' =
'On' just criterion values are displayed.
See Also

arx, bj, idmodel, idpoly, oe, pem, Algorithm Properties, EstimationInfo

References

Ljung (1999), Section 10.2.

You might also like