You are on page 1of 33

System Identification

Control Engineering B.Sc., 3rd year


Technical University of Cluj-Napoca
Romania

Lecturer: Lucian Busoniu

Analytical development

Matlab example

Part VI
Instrumental variable methods

Theoretical guarantees

Analytical development

Matlab example

Table of contents

Analytical development

Matlab example

Theoretical guarantees

We stay in the single-output, single-input case for this lecture.

Theoretical guarantees

Analytical development

Matlab example

Theoretical guarantees

Classification

1
2
3

Mental or verbal models


Graphs and tables (nonparametric)
Mathematical models, with two subtypes:
First-principles, analytical models
Models from system identification

Like prediction error methods, instrumental variable methods produce


parametric, polynomial models.

Analytical development

Matlab example

Table of contents

Analytical development
Starting point: ARX
Instrumental variables methods
Comparison: IV versus PEM

Matlab example

Theoretical guarantees

Theoretical guarantees

Analytical development

Setting: discrete time

Matlab example

Theoretical guarantees

Analytical development

Matlab example

Theoretical guarantees

Recall ARX model


A(q 1 )y (k ) = B(q 1 )u(k) + e(k )
(1+a1 q 1 + + ana q na )y (k ) =
(b1 q 1 + + bnb q nb )u(k ) + e(k )

In explicit form:
y(k) + a1 y(k 1) + a2 y (k 2) + . . . + ana y(k na)
= b1 u(k 1) + b2 u(k 2) + . . . + bnb u(k nb) + e(k)
where the model parameters are: a1 , a2 , . . . , ana and b1 , b2 , . . . , bnb .

Analytical development

Matlab example

Theoretical guarantees

Linear regression representation

y (k ) = a1 y (k 1) a2 y (k 2) . . . ana y (k na)
b1 u(k 1) + b2 u(k 2) + . . . + bnb u(k nb) + e(k)


= y (k 1) y (k na) u(k 1) u(k nb)

>
a1 ana b1 bnb + e(k )
=:> (k ) + e(k )
Regressor vector: Rna+nb , previous output and input values.
Parameter vector: Rna+nb , polynomial coefficients.

Analytical development

Matlab example

Theoretical guarantees

Identification problem and solution


Given dataset u(k ), y (k ), k = 1, . . . , N, find model parameters to
achieve small equation errors (k) in:
y (k ) = > (k ) + (k )
Formal objective: minimize the mean squared error:
V () =

N
1 X
(k)2
N
k=1

Solution: can be written in several ways, we use:


#1 "
#
N
N
X
X
1
1
>
b =
(k ) (k )
(k )y (k)
N
N
"

k =1

k =1

Analytical development

Matlab example

Theoretical guarantees

Theoretical guarantee
Recall that for the guarantees, a true parameter vector 0 is assumed
to exist:
y (k ) = > (k )0 + v (k)
Analyze the parameter errors (a vector of n elements):
#1 "
N
X
1
1
>
b 0 =
(k) (k )
N
N
k=1
"
#1 "
N
1 X
1
>
(k ) (k)

N
N
k=1
"
#
"
1
N
1 X
1
>
=
(k) (k )
N
N
k=1
"
#1 "
N
1 X
1
>
=
(k) (k )
N
N
"

k=1

N
X

#
(k)y(k)

k=1
N
X

#
>

(k ) (k) 0

k=1
N
X

#
(k)[y (k) > (k)0 ]

k=1
N
X
k=1

#
(k)v (k)

Analytical development

Matlab example

Theoretical guarantees

Further assumptions
We wish the algorithm to be consistent: the parameter errors to
become 0 in the limit of infinite data.
As N :
N


1 X
(k )> (k) E (k)> (k )
N
k=1

N
1 X
(k )v (k) E {(k)v (k )}
N
k =1

For the error to be well-defined and equal to zero, we need:




E (k)> (k ) invertible.
E {(k )v (k )} zero.

Analytical development

Matlab example

Table of contents

Analytical development
Starting point: ARX
Instrumental variables methods
Comparison: IV versus PEM

Matlab example

Theoretical guarantees

Theoretical guarantees

Analytical development

Matlab example

Theoretical guarantees

Motivation: ARX requires white noise

We have E {(k )v (k)} = 0 if the elements of (k ) are


uncorrelated with v (k) (note that v (k) is assumed zero-mean).
But (k) includes y (k 1), y(k 2), . . . , which depend on
v (k 1), v (k 2), . . . !
So the only option is to have v (k ) uncorrelated with
v (k 1), v (k 2), . . . v (k ) must be white noise.
Instrumental variables are a solution to remove this limitation to white
noise.

Analytical development

Matlab example

Theoretical guarantees

Intuition

#1 "
#
N
N
X
X
1
1
>
(k ) (k)
(k )v (k )
b 0 =
N
N
"

k=1

k=1

Idea: What if a different vector than (k ) could be included in the


parameter errors?
"
b 0 =

#1 "
#
N
N
1 X
1 X
>
Z (k) (k)
Z (k)v (k )
N
N
k=1

k=1

where the elements of Z (k) are uncorrelated with v (k ). Then


E {Z (k )v (k)} = 0 and the error can be zero.
Vector Z (k ) has n elements, which are called instruments.

Analytical development

Matlab example

Theoretical guarantees

Instrumental variable method


In order to have:
"
b 0 =

#1 "
#
N
N
1 X
1 X
>
Z (k ) (k)
Z (k )v (k )
N
N
k=1

the estimated parameter must be:


"
#1 "
#
N
N
X
X
1
1
b =
Z (k )> (k )
Z (k )y (k)
N
N
k =1

(6.1)

k=1

(6.2)

k =1

This b is the solution to the system of n equations:


"
#
N
1 X
>
Z (k )[ (k) y (k )] = 0
N

(6.3)

k=1

Constructing and solving this system comprises the basic


instrumental variable (IV) method.
Exercise: Show that (6.3) implies (6.2), and that (6.2) implies (6.1).

Analytical development

Matlab example

Theoretical guarantees

Simple instruments

So far the instruments Z (k ) were not discussed. They are usually


created based on the inputs (including outputs would lead to
correlation with v and so eliminate the advantage of IV).
Simple possibility: just include additional delayed inputs to obtain a
vector of the appropriate size, n = na + nb:
>

Z (k ) = [u(k nb 1), . . . u(k na nb), u(k 1), . . . , u(k nb)]


Compare to original vector:
>

(k) = [y (k 1), . . . , y (k na), u(k 1), . . . , u(k nb)]

Analytical development

Matlab example

Theoretical guarantees

Generalization
Pass the input through a transfer function:
C(q 1 )x(k) = D(q 1 )u(k )
(1+c1 q 1 + + cnb q nc )x(k ) =
(d1 q 1 + + dnd q nd )u(k )
x(k) = c1 y(k 1) c2 y (k 2) . . . cnc y(k nc)
d1 u(k 1) + d2 u(k 2) + . . . + dnd u(k nd)
and take na past values from the output x:
>

Z (k ) = [x(k 1), . . . , x(k na), u(k 1), . . . , u(k nb)]


Remark: C(q 1 ), D(q 1 ) have different meanings than in PEM.

Analytical development

Matlab example

Theoretical guarantees

Generalized instruments: obtaining the simple case

In order to obtain:
>

Z (k ) = [u(k nb 1), . . . u(k na nb), u(k 1), . . . , u(k nb)]


set C = 1, D = q nb .
Exercise: Verify the desired Z (k ) is indeed obtained.

Analytical development

Matlab example

Theoretical guarantees

Generalized instruments: Initial model


Generalized instruments:
>

Z (k ) = [x(k 1), . . . , x(k na), u(k 1), u(k 2), . . . , u(k nb)]
Compare to original vector:
>

(k) = [y (k 1), . . . , y (k na), u(k 1), . . . , u(k nb)]

Idea: Take instrument generator equal to an initial model,


b 1 ), D(q 1 ) = B(q
b 1 ). This model can be obtained e.g.
C(q 1 ) = A(q
with ARX estimation.
b 1 ) = A(q 1 ),
In the ideal case where the model is correct, A(q
b 1 ) = B(q 1 ), we obtain noise-free outputs y at the appropriate
B(q
positions in Z (k ). Otherwise, we have an approximation of y :
>
Z (k) = [y (k 1), . . . y (k na), u(k 1), . . . , u(k nb)]
but without the disadvantage of correlation with the noise.

Analytical development

Matlab example

Table of contents

Analytical development
Starting point: ARX
Instrumental variables methods
Comparison: IV versus PEM

Matlab example

Theoretical guarantees

Theoretical guarantees

Analytical development

Matlab example

Theoretical guarantees

Comparison

Both PEM and IV can be seen as extensions of ARX:


A(q 1 )y(k) = B(q 1 )u(k ) + e(k )
to disturbances v (k ) different from white noise e(k ).
PEM explicitly include the disturbance model in the structure,
e.g. in ARMAX v (k ) = C(q 1 )e(k ) leading to
A(q 1 )y (k ) = B(q 1 )u(k) + C(q 1 )e(k).
IV methods do not explicitly model the disturbance, but are
designed to be resilient to non-white, colored disturbance (by
using instruments Z (k) uncorrelated with it).

Analytical development

Matlab example

Theoretical guarantees

Comparison (continued)

Advantage of IV: Simple model structure, identification consists of


simply solving a system of linear equations. In contrast, PEM
required solving optimization problems with Newtons method,
susceptible to local minima etc.
Disadvantage of IV: In practice (for finite number N of data), model
quality depends heavily the choice of instruments Z (k).
Methods exist to choose instruments Z (k) that are optimal in a certain sense,
but they will not be discussed here.

Analytical development

Table of contents

Analytical development

Matlab example

Theoretical guarantees

Matlab example

Theoretical guarantees

Analytical development

Matlab example

Theoretical guarantees

Experimental data
Separate identification and validation data sets:
plot(id); and plot(val);

From prior knowledge, the system has order 2 and the disturbance is
colored (does not obey the ARX model structure).
Remarks: As before, the identification input is a pseudo-random
binary signal, and the validation input a sequence of steps.

Analytical development

Matlab example

Theoretical guarantees

IV identification with custom instruments

Define the instruments by the generating transfer function, using


polynomials C(q 1 ) and D(q 1 ).
model = iv(id, [na, nb, nk], C, D);
Arguments:
1
2

Identification data.
Array containing the orders of A and B and the delay nk (like for
ARX).
Polynomials C and D, as vectors of coefficients in increasing
power of q 1 .

Analytical development

Matlab example

Theoretical guarantees

Result with simple instruments


Take C(q 1 ) = 1, D(q 1 ) = q nb , leading to
>
Z (k ) = [u(k nb 1), . . . u(k na nb), u(k 1), . . . , u(k nb)] .
Compare to ARX.

Conclusions:
IV models are not guaranteed to be stable!
Results very bad with this simple choice.

Analytical development

Matlab example

Theoretical guarantees

Result with ARX-model instruments


1 ), D(q 1 ) = B(q
1 ) from the ARX experiment,
Take C(q 1 ) = A(q
leading to
>
Z (k ) = [y (k 1), . . . y (k na), u(k 1), . . . , u(k nb)] .

Conclusion: IV obtains better results. This is because the disturbance


is colored, and IV can deal effectively with this case (whereas ARX
cannot).

Analytical development

Matlab example

Theoretical guarantees

Result with automatic instruments


model = iv4(id, [na, nb, nk]);
Implements an algorithm that generates near-optimal instruments.

Conclusion: Works slightly better than just ARX instruments.

Analytical development

Table of contents

Analytical development

Matlab example

Theoretical guarantees

Matlab example

Theoretical guarantees

Analytical development

Matlab example

Theoretical guarantees

Assumptions

Assumptions (simplified)
1

The disturbance v (k ) = H(q 1 )e(k) where e(k ) is zero-mean


white noise, H(q 1 ) is a transfer function satisfying certain
conditions.
The input signal u(k ) is sufficiently informative and does not
depend on the disturbance (the experiment is open-loop).
The real system is stable and uniquely representable by the
model chosen: there exists exactly one 0 so that polynomials
A(q 1 ; 0 ) and B(q 1 ; 0 ) are identical to those of the real
system.


Matrix E Z (k )Z > (k) is invertible.

Analytical development

Matlab example

Theoretical guarantees

Discussion of assumptions
Assumption 1 shows the main advantage of IV over PEM: the
disturbance can be colored.
Assumptions 2 and 3 are not very different from those made by
PEM. Stability of a discrete-time system requires its poles to be
strictly inside the unit circle:

Assumption 4 is required to solve the linear system, and given a


sufficiently informative input boils down to an appropriate
selection of instruments (e.g. not repeating the same delayed
input u(k i) twice).

Analytical development

Matlab example

Theoretical guarantees

Guarantee

Theorem 1
As the number of data points N , the solution b of IV estimation
converges to the true parameter vector 0 .
Remark: This is a consistency guarantee, in the limit of infinitely
many data points.

Analytical development

Matlab example

Theoretical guarantees

Possible extensions

Multiple-input, multiple-output systems.


Larger-dimension instruments Z than parameter vectors
with other modifications, called extended IV methods.

You might also like