Comparison of Various Model Identification Methods
Comparison of Various Model Identification Methods
Resources
y = G u + H e
where y is the output and u is the input, while e denotes the unmeasured (white) noise source. G is the system's transfer function and H gives the
description of the noise disturbance.
There are many ways to estimate G and H. Essentially they correspond to different ways of parameterizing these functions.
Defining a Model
System Identification Toolbox provides users with the option of simulating data as would have been obtained from a physical process. Let us
simulate the data from an IDPOLY model with a given set of coefficients.
B = [0 1 0.5]; Get
A = [1 -1.5 0.7];
m0 = idpoly(A,B,[1 -1 0.2],'Ts',0.25,'Variable','q^-1'); % The sample time is 0.25 s.
The third argument [1 -1 0.2] gives a characterization of the disturbances that act on the system. Execution of these commands produces the
following discrete-time idpoly model:
m0 Get
m0 =
Discrete-time ARMAX model: A(q)y(t) = B(q)u(t) + C(q)e(t)
A(q) = 1 - 1.5 q^-1 + 0.7 q^-2
Parameterization:
Polynomial orders: na=2 nb=2 nc=2 nk=1
Number of free coefficients: 6
Use "polydata", "getpvec", "getcov" for parameters and their uncertainties.
Status:
Created by direct construction or transformation. Not estimated.
Here q denotes the shift operator so that A(q)y(t) is really short for y(t) - 1.5 y(t-1) + 0.7 y(t-2). The display of model m0 shows that it is an ARMAX
model.
This particular model structure is known as an ARMAX model, where AR (Autoregressive) refers to the A-polynomial, MA (Moving average) to the
noise C-polynomial and X to the "eXtra" input B(q)u(t).
In terms of the general transfer functions G and H, this model corresponds to a parameterization:
https://uk.mathworks.com/help/ident/ug/comparison-of-various-model-identification-methods.html#iddemo2-9 1/15
28/04/2025, 07:34 Comparison of Various Model Identification Methods
y =
One aspect to note is that the signals u and y are both IDDATA objects. Next we collect this input-output data to form a single iddata object.
z = [y,u]; Get
To get information on the data object (which now incorporates both the input and output data samples), just enter its name at the MATLAB®
command window:
z Get
z =
To plot the first 100 values of the input u and output y, use the plot command on the iddata object:
https://uk.mathworks.com/help/ident/ug/comparison-of-various-model-identification-methods.html#iddemo2-9 2/15
28/04/2025, 07:34 Comparison of Various Model Identification Methods
It is good practice to use only a portion of the data for estimation purposes, ze and save another part to validate the estimated models later on:
ze = z(1:200); Get
zv = z(201:350);
GS = spa(ze); Get
The result of spectral analysis is a complex-valued function of frequency: the frequency response. It is packaged into an object called IDFRD object
(Identified Frequency Response Data):
GS Get
GS =
IDFRD model.
Contains Frequency Response Data for 1 output(s) and 1 input(s), and the spectra for disturbances at the outputs.
Response data and disturbance spectra are available at 128 frequency points, ranging from 0.09817 rad/s to 12.57 rad/s.
To plot the frequency response it is customary to use the Bode plot, with the bode or bodeplot command:
clf Get
h = bodeplot(GS); % bodeplot returns a plot handle, which bode does not
ax = axis;
axis([0.1 10 ax(3:4)])
https://uk.mathworks.com/help/ident/ug/comparison-of-various-model-identification-methods.html#iddemo2-9 3/15
28/04/2025, 07:34 Comparison of Various Model Identification Methods
The estimate GS is uncertain, since it is formed from noise corrupted data. The spectral analysis method provides also its own assessment of this
uncertainty. To display the uncertainty (say for example 3 standard deviations) we can use the showConfidence command on the plot handle h
returned by the previous bodeplot command.
showConfidence(h,3) Get
The plot says that although the nominal estimate of the frequency response (blue line) is not necessarily accurate, there is a 99.7% probability (3
standard deviations of the normal distribution) that the true response is within the shaded (light-blue) region.
https://uk.mathworks.com/help/ident/ug/comparison-of-various-model-identification-methods.html#iddemo2-9 4/15
28/04/2025, 07:34 Comparison of Various Model Identification Methods
m =
Continuous-time identified state-space model:
dx/dt = A x(t) + B u(t) + K e(t)
y(t) = C x(t) + D u(t) + e(t)
A =
x1 x2
x1 -0.007167 1.743
x2 -2.181 -1.337
B =
u1
x1 0.09388
x2 0.2408
C =
x1 x2
y1 47.34 -14.4
D =
u1
y1 0
K =
y1
x1 0.04108
x2 -0.03751
Parameterization:
FREE form (all coefficients in A, B, C free).
Feedthrough: none
Disturbance component: estimate
Number of free coefficients: 10
Use "idssdata", "getpvec", "getcov" for parameters and their uncertainties.
Status:
Estimated using SSEST on time domain data "m0".
Fit to estimation data: 75.08% (prediction focus)
FPE: 0.9835, MSE: 0.9262
At this point the state-space model matrices do not tell us very much. We could compare the frequency response of the model m with that of the
spectral analysis estimate GS. Note that GS is a discrete-time model while m is a continuous-time model. It is possible to use ssest to compute
discrete time models too.
bodeplot(m,GS) Get
ax = axis;
axis([0.1 10 ax(3:4)])
https://uk.mathworks.com/help/ident/ug/comparison-of-various-model-identification-methods.html#iddemo2-9 5/15
28/04/2025, 07:34 Comparison of Various Model Identification Methods
We note that the two frequency responses are close, despite the fact that they have been estimated in very different ways.
where NUM(s) and DEN(s) are the numerator and denominator polynomials, and Y(s), U(s) and E(s) are the Laplace Transforms of the output, input
and error signals (y(t), u(t) and e(t)) respectively. NUM and DEN can be parameterized by their orders which represent the number of zeros and poles.
For a given number of poles and zeros, we can estimate a transfer function using the tfest command:
mtf =
Parameterization:
Number of poles: 2 Number of zeros: 2
Number of free coefficients: 5
Use "tfdata", "getpvec", "getcov" for parameters and their uncertainties.
Status:
Estimated using TFEST on time domain data "m0".
Fit to estimation data: 71.69%
FPE: 1.282, MSE: 1.195
or in long-hand,
https://uk.mathworks.com/help/ident/ug/comparison-of-various-model-identification-methods.html#iddemo2-9 6/15
28/04/2025, 07:34 Comparison of Various Model Identification Methods
mx =
Discrete-time ARX model: A(z)y(t) = B(z)u(t) + e(t)
A(z) = 1 - 1.32 z^-1 + 0.5393 z^-2
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 "m0".
Fit to estimation data: 68.18% (prediction focus)
FPE: 1.603, MSE: 1.509
compare(zv,m,mtf,mx) Get
The fit is the percent of the output variation that is explained by the model. Clearly m is the better model, although mtf comes close. A discrete-time
transfer function can be estimate using either the tfest or the oe command. The former creates an IDTF model while the latter creates an IDPOLY
model of Output-Error structure (y(t) = B(q)/F(q)u(t) + e(t)), but they are mathematically equivalent.
md1 = tfest(ze,2,2,'Ts',0.25) % two poles and 2 zeros (counted as roots of polynomials in z^-1) Get
https://uk.mathworks.com/help/ident/ug/comparison-of-various-model-identification-methods.html#iddemo2-9 7/15
28/04/2025, 07:34 Comparison of Various Model Identification Methods
md1 =
Parameterization:
Number of poles: 2 Number of zeros: 2
Number of free coefficients: 4
Use "tfdata", "getpvec", "getcov" for parameters and their uncertainties.
Status:
Estimated using TFEST on time domain data "m0".
Fit to estimation data: 71.46%
FPE: 1.264, MSE: 1.214
md2 =
Discrete-time OE model: y(t) = [B(z)/F(z)]u(t) + e(t)
B(z) = 0.8383 z^-1 + 0.7199 z^-2
Parameterization:
Polynomial orders: nb=2 nf=2 nk=1
Number of free coefficients: 4
Use "polydata", "getpvec", "getcov" for parameters and their uncertainties.
Status:
Estimated using OE on time domain data "m0".
Fit to estimation data: 71.46%
FPE: 1.264, MSE: 1.214
https://uk.mathworks.com/help/ident/ug/comparison-of-various-model-identification-methods.html#iddemo2-9 8/15
28/04/2025, 07:34 Comparison of Various Model Identification Methods
The models md1 and md2 deliver identical fits to the data.
Residual Analysis
A further way to gain insight into the quality of a model is to compute the "residuals": i.e. that part e in y = Gu + He that could not be explained by
the model. Ideally, these should be uncorrelated with the input and also mutually uncorrelated. The residuals are computed and their correlation
properties are displayed by the resid command. This function can be used to evaluate the residues both in the time and frequency domains. First let
us obtain the residuals for the Output-Error model in the time domain:
We see that the cross correlation between residuals and input lies in the confidence region, indicating that there is no significant correlation. The
estimate of the dynamics G should then be considered as adequate. However, the (auto) correlation of e is significant, so e cannot be seen as white
noise. This means that the noise model H is not adequate.
am2 =
Discrete-time ARMAX model: A(z)y(t) = B(z)u(t) + C(z)e(t)
A(z) = 1 - 1.516 z^-1 + 0.7145 z^-2
Parameterization:
Polynomial orders: na=2 nb=2 nc=2 nk=1
Number of free coefficients: 6
Use "polydata", "getpvec", "getcov" for parameters and their uncertainties.
Status:
Estimated using ARMAX on time domain data "m0".
Fit to estimation data: 75.08% (prediction focus)
FPE: 0.9837, MSE: 0.9264
https://uk.mathworks.com/help/ident/ug/comparison-of-various-model-identification-methods.html#iddemo2-9 9/15
28/04/2025, 07:34 Comparison of Various Model Identification Methods
bj2 =
Discrete-time BJ model: y(t) = [B(z)/F(z)]u(t) + [C(z)/D(z)]e(t)
B(z) = 0.9922 z^-1 + 0.4701 z^-2
Parameterization:
Polynomial orders: nb=2 nc=2 nd=2 nf=2 nk=1
Number of free coefficients: 8
Use "polydata", "getpvec", "getcov" for parameters and their uncertainties.
Status:
Estimated using BJ on time domain data "m0".
Fit to estimation data: 75.47% (prediction focus)
FPE: 0.9722, MSE: 0.8974
clf Get
compare(zv,am2,md2,bj2,mx,mtf,m)
We can also compare how well the various estimated models are able to predict the output, say, 1 step ahead:
compare(zv,am2,md2,bj2,mx,mtf,m,1) Get
https://uk.mathworks.com/help/ident/ug/comparison-of-various-model-identification-methods.html#iddemo2-9 10/15
28/04/2025, 07:34 Comparison of Various Model Identification Methods
The residual analysis of model bj2 shows that the prediction error is devoid of any information - it is not auto-correlated and also uncorrelated with
the input. This shows that the extra dynamic elements of a Box-Jenkins model (the C and D polynomials) were able to capture the noise dynamics.
resid(zv,bj2) Get
https://uk.mathworks.com/help/ident/ug/comparison-of-various-model-identification-methods.html#iddemo2-9 11/15
28/04/2025, 07:34 Comparison of Various Model Identification Methods
clf Get
w = linspace(0.1,4*pi,100);
bp = bodeplot(GS,m,mx,mtf,md2,am2,bj2,w);
bp.PhaseMatchingEnabled = 'on';
legend({'SPA','SS','ARX','TF','OE','ARMAX','BJ'},'Location','West');
The noise spectra of the estimated models can also be analyzed. For example here we compare the noise spectra the ARMAX and the Box-Jenkins
models with the state-space and the Spectral Analysis models. For this, we use the spectrum command:
spectrum(GS,m,mx,am2,bj2,w) Get
legend('SPA','SS','ARX','ARMAX','BJ');
https://uk.mathworks.com/help/ident/ug/comparison-of-various-model-identification-methods.html#iddemo2-9 12/15
28/04/2025, 07:34 Comparison of Various Model Identification Methods
bode(m0,am2,w) Get
The responses practically coincide. The noise spectra can also be compared.
spectrum(m0,am2,w) Get
https://uk.mathworks.com/help/ident/ug/comparison-of-various-model-identification-methods.html#iddemo2-9 13/15
28/04/2025, 07:34 Comparison of Various Model Identification Methods
h = iopzplot(m0,am2); Get
It can be seen that the poles and the zeros of the true system (blue) and the ARMAX model (green) are very close.
We can also evaluate the uncertainty of the zeros and poles. To plot confidence regions around the estimated poles and zeros corresponding to 3
standard deviations, use showConfidence or turn on the "Confidence Region" characteristic from the plot's context (right-click) menu.
showConfidence(h,3) Get
We see that the true, blue zeros and poles are well inside the green uncertainty regions.
https://uk.mathworks.com/help/ident/ug/comparison-of-various-model-identification-methods.html#iddemo2-9 14/15
28/04/2025, 07:34 Comparison of Various Model Identification Methods
https://uk.mathworks.com/help/ident/ug/comparison-of-various-model-identification-methods.html#iddemo2-9 15/15