Main Content


ARX model estimation using four-stage instrumental variable method


sys = iv4(data,[na nb nk])
sys = iv4(data,'na',na,'nb',nb,'nk',nk)
sys = iv4(___,Name,Value)
sys = iv4(___,opt)


sys = iv4(data,[na nb nk]) estimates an ARX polynomial model, sys, using the four-stage instrumental variable method, for the data object data. [na nb nk] specifies the ARX structure orders of the A and B polynomials and the input to output delay. The estimation algorithm is insensitive to the color of the noise term.

sys is an ARX model:


sys = iv4(data,'na',na,'nb',nb,'nk',nk) alternatively specify the ARX model orders separately.

sys = iv4(___,Name,Value) estimates an ARX polynomial with additional options specified by one or more Name,Value pair arguments.

sys = iv4(___,opt) uses the option set, opt, to configure the estimation behavior.

Input Arguments


Estimation data. The data can be:

  • Time- or frequency-domain input-output data

  • Time-series data

  • Frequency-response data

data must be an iddata, idfrd, or frd (Control System Toolbox) object.

data must be discrete-time (Ts>0) for frequency domain.

[na nb nk]

ARX polynomial orders.

For multi-output model, [na nb nk] contains one row for every output. In particular, specify na as an Ny-by-Ny matrix, where each entry is the polynomial order relating the corresponding output pair. Here, Ny is the number of outputs. Specify nb and nk as Ny-by-Nu matrices, where Nu is the number of inputs. For more details on the ARX model structure, see arx.


Estimation options.

opt is an options set that configures the estimation options. These options include:

  • estimation focus

  • handling of initial conditions

  • handling of data offsets

Use iv4Options to create the options set.

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.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.


Input delay for each input channel, specified as a scalar value or numeric vector. For continuous-time systems, specify input delays in the time unit stored in the TimeUnit property. For discrete-time systems, specify input delays in integer multiples of the sample time Ts. For example, InputDelay = 3 means a delay of three sample times.

For a system with Nu inputs, set InputDelay to an Nu-by-1 vector. Each entry of this vector is a numerical value that represents 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


Transport delays. IODelay is a numeric array specifying a separate transport delay for each input/output pair.

For continuous-time systems, specify transport delays in the time unit stored in the TimeUnit property. For discrete-time systems, specify transport delays in integer multiples of the sample time, Ts.

For a MIMO system with Ny outputs and Nu inputs, set IODelay to a Ny-by-Nu array. Each entry of this array is a numerical value that represents 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.

Default: 0 for all input/output pairs


Specify integrators in the noise channels.

Adding an integrator creates an ARIX model represented by:


where,11q1 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


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

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


Estimation command used.


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


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:


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


Value of the loss function when the estimation completes.


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


Final prediction error for the model.


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


Small-sample-size corrected AIC.


Normalized AIC.


Bayesian Information Criteria (BIC).


Estimated values of model parameters.


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


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


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


Name of the data set.


Data type.


Number of data samples.


Sample time.


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.


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


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

For more information on using Report, see Estimation Report.


collapse all

Load estimation data.

load iddata7;

This data has two inputs, u1 and u2, and one output, y1.

Specify the ARX model orders, using the same orders for both inputs.

na = 2;
nb = [2 2];

Specify a delay of 2 samples for input u2 and no delay for input u1.

nk = [0 2];

Estimate an ARX model using the four-stage instrumental variable method.

m = iv4(z7,[na nb nk]);


Estimation is performed in 4 stages. The first stage uses the arx function. The resulting model generates the instruments for a second-stage IV estimate. The residuals obtained from this model are modeled as a high-order AR model. At the fourth stage, the input-output data is filtered through this AR model and then subjected to the IV function with the same instrument filters as in the second stage.

For the multiple-output case, optimal instruments are obtained only if the noise sources at the different outputs have the same color. The estimates obtained with the routine are reasonably accurate, however, even in other cases.


[1] Ljung, L. System Identification: Theory for the User, equations (15.21) through (15.26), Upper Saddle River, NJ, Prentice-Hall PTR, 1999.

Version History

Introduced before R2006a

See Also

| | | | | | | |