Ph.D. IN ENGINEERING AND Advanced methods for system APPLIED SCIENCES identification Ph.D. course

Lesson 4: Instrumental variables TEACHER Mirko Mazzoleni

PLACE University of Bergamo Outline

1. Introduction to error-in-variables problems

2. revised

3. The instrumental variable method

4. Estimate an ARX model from ARMAX generated data

5. Application study: the VRFT approach for direct data driven control

6. Conclusions

2 /44 Outline

1. Introduction to error-in-variables problems

2. Least Squares revised

3. The instrumental variable method

4. Estimate an ARX model from ARMAX generated data

5. Application study: the VRFT approach for direct data driven control

6. Conclusions

3 /44 Introduction

Many different solutions have been presented for of linear dynamic systems from noise-corrupted output measurements

On the other hand, estimation of the parameters for linear dynamic systems when also the input is affected by noise is recognized as a more difficult problem

Representations where errors or measurement noises are present on both inputs and outputs are usually called Errors-in-Variables (EIV) models

In case of static systems, errors-in-variables representations are closely related to other well-known topics such as latent variables models and factor models

4 /44 Introduction Errors-in-variables models can be motivated in several situations: • modeling of the dynamics between the noise-free input and noise-free output. The reason can be to have a better understanding of the underlying relations (e.g. in econometrics), rather than to make a good prediction from noisy data

• when the user lacks enough information to classify the available signals into inputs and outputs and prefer to use a “symmetric” system model. This is closely connected to the behavioral approach to modeling

• In some settings, especially in non technical areas such as nature, biology, economics, the identification experiment may not be under full “control” of the modeler, so we have to work with observational data and treat variables accordingly

5 /44 Example: data-driven control design Consider the Virtual Reference Feedback Tuning (VRFT) algorithm:

• Unknown SISO linear system 퐺 푧 • Family of linear parametric 1-DOF controllers 휷 푧 = 훽 푧 훽 푧 … 훽 푧 푇 푦 푡 = 퐺 푧 푢 푡 + 푦෤ 푡 푅 푧; 휽 = 휷푇 푧 휽 1 2 푛 1 × 푑 푑 × 1 푇 휽 = 휃1 휃2 … 휃푛 • Model reference specification 푦෤ 푡 푀 푧 : Reference model + + Design 푅 푧; 휽 such that 푀 푧 푟ҧ 푡 푢 푡 푦0 푡 + 푦 푡 푅 푧; 휽 퐺 푧 − 퐺 푧 푅 푧; 휽 푀 푧 ≈ 1 + 퐺 푧 푅 푧; 휽

Campi, M. C., Lecchini, A., & Savaresi, S. M. (2002) 6 /44 Example: data-driven control design 푁 1 2 What we can minimize : 퐽푁 휽 = ෍ 푢 푡 − 푅 푧; 휽 푒 푡 푉푅 푁 퐿 퐿 푡=1 푀−1 푧 Given a set of I/O measures 푢 푡 , 푦 푡 푡=1,…,푁 Noisy «input»

Compute: + 푟푣ҧ 푡 푒푣 푡 푢 푡 푦 푡 −1 • Virtual noisy reference 푟푣ҧ 푡 = 푀 푧 푦 푡 ? 퐺 푧 − • Filtered noisy virtual error 푒퐿 푡 = 퐿 푧 푟푣ҧ 푡 − 푦 푡

• Filtered input 푢퐿 푡 = 퐿 푧 푢 푡

If 푅 푧; 휽 is linear in the parameters, we can estiamate 휽 via Least Squares. However, in this case the noise is on the regressor signal 푒퐿 푡 and not on the output 푢 푡

7 /44 Basic setup We now describe the basic setup for an EIV problem: 푦෤ 푡

• 푢 푡 푦 푡 푢 푡 + 0 and 0 denote the undisturbed 0 푦0 푡 푦 푡 푆 input and output, respectively, such that +

−1 푛푎 • 퐴 푧 = 1 − 푎1푧 − ⋯ − 푧 + 퐴 푧 푦0 푡 = 퐵 푧 푢0 푡 푢෤ 푡 푢 푡 −1 푛푏 • 퐵 푧 = 푏1푧 + ⋯ + 푧 +

So that:

푦0 푡 = 푎1푦0 푡 − 1 + ⋯ + 푎푛푎푦0 푡 − 푛푎 + 푏1푢0 푡 − 1 + ⋯ + 푏푛푏 푢0 푡 − 푛푏

8 /44 Basic setup

• 푢෤ 푡 and 푦෤ 푡 are zero-mean disturbances on input and output. The available signals are 푢 푡 = 푢0 푡 + 푢෤ 푡 푦 푡 = 푦0 푡 + 푦෤ 푡 Then:

푦0 푡 = 푎1푦0 푡 − 1 + ⋯ + 푎푛푎푦0 푡 − 푛푎 + 푏1푢0 푡 − 1 + ⋯ + 푏푛푏 푢0 푡 − 푛푏

푦 푡 − 푦෤ 푡 = 푎1 푦 푡 − 1 − 푦෤ 푡 − 1 + ⋯ + 푎푛푎 푦 푡 − 푛푎 − 푦෤ 푡 − 푛푎

+푏1 푢 푡 − 1 − 푢෤ 푡 − 1 + ⋯ + 푏푛푏 푢 푡 − 푛푏 − 푢෤ 푡 − 푛푏

퐴 푧 푦 푡 = 퐵 푧 푢 푡 + 퐴 푧 푦෤ 푡 − 퐵 푧 푢෤ 푡

퐴 푧 푦 푡 = 퐵 푧 푢 푡 + 휂 푡

9 /44 ⊤ • 흋 푡 = 푦 푡 − 1 … 푦 푡 − 푛푎 푢 푡 − 1 … 푢 푡 − 푛푏 Basic setup ⊤ • 휽 = 푎1 … 푎푛푎 푏1 … 푏푛푏 We can then write the system as: 푦 푡 = 흋 푡 ⊤휽 + 휂 푡

Estimation problem 푁 Given 푁 observations 푢(푡 , 푦 푡 푡=1, estimate the system parameters

⊤ 휽 = 푎1 … 푎푛 푏1 … 푏푛 푑 × 1 푎 푏

We denote with 휽0, 퐴0 푧 , 퐵0 푧 the true values of the parameters and polynomials

Consistency. An estimated parameter vector 휽෡푁 based on 푁 data points is said to be consistent if it converges to its “true” value 휽0 as the number of measured data grows without any limit 휽෡푁 → 휽0, 푁 → +∞

10 /44 Outline

1. Introduction to error-in-variables problems

2. Least Squares revised

3. The instrumental variable method

4. Estimate an ARX model from ARMAX generated data

5. Application study: the VRFT approach for direct data driven control

6. Conclusions

11 /44 Least squares revised Consider a linear model having a the following structure:

푦 푡 = 푎1푦 푡 − 1 + ⋯ + 푎푛푎푦 푡 − 푛푎 + 푏1푢 푡 − 1 + ⋯ + 푏푛푏푢 푡 − 푛푏 + 휂 푡 퐴 푧 푦 푡 = 퐵 푧 푢 푡 + 휂 푡 where 휂 푡 denotes an equation error, which can describe disturbances as well as unmodeled dynamics (휂 푡 does not need to be white noise) 1 The Least Squares estimate, found by minimizing σ1 휂 푡 2, reads as: 푁 푡=1 −1 푁 푁 1 1 휽෡ = ෍ 흋 푡 흋 푡 ⊤ ⋅ ෍ 흋 푡 푦 푡 퐿푆 푁 푁 푑 × 1 푡=1 푑 × 1 1 × 푑 푡=1 푑 × 1 1 × 1 ⋯ ⋮ ⋮ ⋮

12 /44 Least squares revised Consider now a linear system and write it as

⊤ 퐴0 푧 푦 푡 = 퐵0 푧 푢 푡 + 푣 푡 푦 푡 = 흋 푡 휽0 + 푣 푡

The 푣 푡 term can be evaluated as

푣 푡 = 퐴0 푧 푦 푡 − 퐵0 푧 푢 푡 = 퐴0 푧 푦0 푡 + 푦෤ 푡 − 퐵0 푧 푢0 푡 + 푢෤ 푡

= 퐴0 푧 푦෤ 푡 − 퐵0 푧 푢෤ 푡

Focus now on the estimation error:

휽෡퐿푆 − 휽0

13 /44 Least squares revised −1 푁 푁 1 1 휽෡ − 휽 = ෍ 흋 푡 흋 푡 ⊤ ⋅ ෍ 흋 푡 푦 푡 − 휽 퐿푆 0 푁 푁 0 푡=1 푡=1

−1 푁 푁 푁 1 1 = ෍ 흋 푡 흋 푡 ⊤ ⋅ ෍ 흋 푡 푦 푡 − ෍ 흋 푡 흋 푡 ⊤ 휽 푁 푁 0 푡=1 푡=1 푡=1

−1 푁 푁 1 1 = ෍ 흋 푡 흋 푡 ⊤ ⋅ ෍ 흋 푡 푦 푡 − 흋 푡 ⊤휽 푁 푁 0 푡=1 푡=1

−1 푁 푁 1 1 = ෍ 흋 푡 흋 푡 ⊤ ⋅ ෍ 흋 푡 푣 푡 푁 푁 푡=1 푡=1

14 /44 Least squares revised

−1 푁 푁 1 1 휽෡ − 휽 = ෍ 흋 푡 흋 푡 ⊤ ⋅ ෍ 흋 푡 푣 푡 퐿푆 0 푁 푁 푡=1 푡=1

The summations in the equation converge to their expected values, under mild conditions. Thus, the estimate 휽෡퐿푆 is consistent if:

• 피 흋 푡 흋 푡 ⊤ is invertible

• 피 흋 푡 푣 푡 = ퟎ

15 /44 Least squares revised The second condition is the most resctrictive:

피 흋 푡 푣 푡 = ퟎ 푑 × 1 푑 × 1 If 푣 푡 is a white noise, it will be uncorrelated with all values in 흋 푡 , and so the estimate is consistent ⊤ 흋 푡 = 푦 푡 − 1 … 푦 푡 − 푛푎 푢 푡 − 1 … 푢 푡 − 푛푏

푦 푡 − 1 = 푓 푦 푡 − 2 , … , 푢 푡 − 2 , … , 푣 푡 − 1 , … ⊥ 푣 푡

In the EIV case, since 푣 푡 = 퐴0 푧 푦෤ 푡 − 퐵0 푧 푢෤ 푡 , it will be correlated with the variables in 흋 푡 , and so the estimate is NOT consistent

16 /44 Example (least squares with noise on regressor) Suppose that we want to estimate a static linear model, using regression and least squares

2 푦 푖 = 휃푥0 푖 + 푒푦 푖 휃 = 3, 푒푦 ∼ 풩 0, 휎푦 so that 푥0 푖 is noiseless. Suppose now that we measure and employ 2 푥 푖 = 푥0 푖 + 푒푥 푖 푒푥 ∼ 풩 0, 휎푥 instead of 푥0 푖 , i.e. we have a noisy regressor 푥 푖

The LS estimates are biased 2 proportionally to 휎푥

See static_system_regressor_noise.m MatLab file 17 /44 Example (least squares with noise on regressor) Let’s investigate the problem.

2 The relation assumed by LS is: 푦 푖 = 휃푥0 푖 + 푒푦 푖 휃 = 3, 푒푦 ∼ 풩 0, 휎푦 but we employ 푥 푖 = 푥0 푖 + 푒푥 푖 in place of 푥 푖

푦 푖 = 휃 푥 푖 − 푒푥 푖 + 푒푦 푖 = 휃푥 푖 − 휃푒푥 푖 + 푒푦 푖 = 휃푥 푖 + 휂 푖

So that employed regressor 푥 is correlated with the output noise 휂:

피 푥 푖 ⋅ 휂 푖 = 피 푥0 푖 + 푒푥 푖 ⋅ −휃푒푥 푖 + 푒푦 푖 ≠ 0 and a bias is present in the estimates

See static_system_regressor_noise.m MatLab file 18 /44 Outline

1. Introduction to error-in-variables problems

2. Least Squares revised

3. The instrumental variable method

4. Estimate an ARX model from ARMAX generated data

5. Application study: the VRFT approach for direct data driven control

6. Conclusions

19 /44 The instrumental variables method Instrumental variable methods can be seen as generalizations of the least squares estimates. The main idea is to modify the estimate so that it is consistent for an arbitrary disturbance

Consider again an ARX model and modify the normal equations as

푁 푁 1 1 ෍ 풛 푡 흋 푡 ⊤ ⋅ 휽෡ = ෍ 풛 푡 푦 푡 푁 퐼푉 푁 푡=1 푑 × 1 푡=1 where 풛 푡 is a vector called instrumental variable, that has to satisfy certain conditions to guarantee the consistency of the estimates 휽෡퐼푉. Notice that for 풛 푡 = 흋 푡 we have that 휽෡퐼푉 = 휽෡퐿푆

20 /44 The instrumental variables method

In particular, we want that:

• 피 풛 푡 흋 푡 ⊤ is invertible

• 피 풛 푡 푣 푡 = ퟎ so that the bias in the estimate is eliminated

−1 푁 푁 1 1 휽෡ − 휽 = ෍ 풛 푡 흋 푡 ⊤ ⋅ ෍ 풛 푡 푣 푡 = ퟎ 퐼푉 0 푁 푁 푡=1 푡=1

21 /44 Extended instrumental variables

The extended IV estimates of 휽0 are obtained by generalizing in two directions the previous result:

푛푧×1 • use an augmented 풛 푡 ∈ ℝ vector, such that 푛푧 > 푑 • prefiltering of the data by an asymptotically stable filter 퐹 푧

The extended IV estimate is given by:

2 푁 푁 ⊤ 휽෡퐼푉 = argmin휽 ෍ 풛 푡 퐹 푧 흋 푡 ⋅ 휽 − ෍ 풛 푡 퐹 푧 푦 푡 푑 × 1 푛푧 × 1 1 × 푑 푑 × 1 푛푧 × 1 1 × 1 푡=1 푡=1 푾

2 ⊤ where 풙 푾 = 풙 푾풙

22 /44 Extended instrumental variables

푁 ⊤ 푁 By renaming: • 푹 = σ푡=1 풛 푡 퐹 푧 흋 푡 • 풓 = σ푡=1 풛 푡 퐹 푧 푦 푡 we can recognize the minimization problem for an overdetermined system of equations

෡ 2 휽퐼푉 = argmin휽 푹 ⋅ 휽 − 풓 푾 푑 × 1 푛푧 × 푑 푑 × 1 푛푧 × 1 for which at least an approximate solution can be found as the solution ⊤ −1 ⊤ 휽෡퐼푉 = 푹 푾푹 ⋅ 푹 푾풓

For the extended IV estimate we require that

• 푹 has full column rank • 피 풛 푡 퐹 푧 푣 푡 = ퟎ

23 /44 Choice of the instrumental variable There isn’t a unique way to choose 풛 푡 . The important thing is that 풛 푡 should be well correlated with the regressor 흋 푡 , and uncorrelated with the disturbances 푣 푡 .

Suppose that both 푦෤ 푡 and 푢෤ 푡 are white noises. Then, 풛 푡 should be constructed from the measured input and output data, so as not to contain the elements

푦 푡 − 1 … 푦 푡 − 푛푎 푢 푡 − 1 … 푢 푡 − 푛푏 One way (among many possible ones) is to choose

풛 푡 = 흋 푡 − 푛 + 흋 푡 + 푛 , 푛 = max 푛푎, 푛푏

푦 푡 − 푛 − 1 … 푦 푡 − 푛 − 푛푎 푢 푡 − 푛 − 1 … 푢 푡 − 푛 − 푛푎

24 /44 Choice of the instrumental variable The simplest possible case, when 푢෤ ∼ WN 0, 휆2 and 푢෤ ⋅ ⊥ 푦෤ ⋅ is to let the instruments consist of delayed inputs only 푢 푡 − 푛푏 − 1 풛 푡 = ⋮ , 푝 ≥ 푛푎 + 푛푏 푢 푡 − 푛푏 − 푝 then 피 풛 푡 퐹 푧 푣 푡 = ퟎ is satisfied also for correlated output noise Example: suppose that the syste is an ARX 2, 3 . Then, 푣 푡 = 푓 푦෤ 푡 − 1 , 푦෤ 푡 − 2 , 푢෤ 푡 − 1 , 푢෤ 푡 − 2 , 푢෤ 푡 − 3

푢 푡 − 푛푏 − 1 푢 푡 − 3 − 1 푢 푡 − 4 풛 푡 = ⋮ , 푝 ≥ 2 + 3 = 5, 풛 푡 = ⋮ = ⋮ 푢 푡 − 푛푏 − 푝 푢 푡 − 3 − 5 푢 푡 − 8

25 /44 The instrumental variables method Remark • The IV method can be employed also when the input is noiseless, but the regressors contain a part which is correlated with the output noise

• This happens in all the cases where the data can be thought as generated by an ARMAX system, but we want to employ an ARX model (e.g. because we can use a closed-form solution)

• The disadvantage of using an IV method is given by quite high variance of the estimate

26 /44 Outline

1. Introduction to error-in-variables problems

2. Least Squares revised

3. The instrumental variable method

4. Estimate an ARX model from ARMAX generated data

5. Application study: the VRFT approach for direct data driven control

6. Conclusions

27 /44 Estimate an ARX model from ARMAX generated data Problem formulation We want to estimate an ARX model ⊤ 휽 = 푎1 … 푎푛푎 푏1 … 푏푛푏 퐵 푧; 휽 1 푀: 푦 푡 = 푢 푡 − 1 + 휂 푡 휂 푡 ∼ WN 0, 휇2 퐴 푧; 휽 퐴 푧; 휽

but the data are generated from an ARMAX system (퐶 푧 ≠ 1)

0 0 0 0 ⊤ 휽0 = 푎1 … 푎푛푎 푏1 … 푏푛푏

퐵 푧; 휽 퐶0 푧; 휽0, 푐1, … , 푐푛 푆: 푦 푡 = 0 0 푢 푡 − 1 + 푐 푒 푡 푒 푡 ∼ WN 0, 휆2 퐴0 푧; 휽0 퐴0 푧; 휽0

28 /44 Estimate an ARX model from ARMAX generated data Hypothesis: 퐵 푧; 휽 퐵 푧; 휽 0 ∈ 퐴0 푧; 휽 퐴 푧; 휽

The problem depends on these facts:

• We want to identify ARX models (for simplicity)

퐵 푧;휽 • We want to estimate 0 0 exactly 퐴0 푧;휽0

• The disturbance in this case can be of any quantity and, as a consequence, it can’t be any longer ignored

퐵 푧;휽 퐵 푧;휽 • 0 0 ∈ does not grant an exact estimate of this part 퐴0 푧;휽0 퐴 푧;휽

29 /44 Estimate an ARX model from ARMAX generated data We can build a from the ARX model

⊤ ⊤ 푦 푡 = 흋 푡 휽 + 휂 푡 흋 푡 = 푦 푡 − 1 … 푦 푡 − 푛푎 푢 푡 − 1 … 푢 푡 − 푛푏 ⊤ 휽 = 푎1 … 푎푛푎 푏1 … 푏푛푏

The data are generated by and ARMAX system: 0 0 0 0 푦 푡 = 푎1푦 푡 − 1 + ⋯ + 푎푛푎푦 푡 − 푛푎 + 푏1 푢 푡 − 1 + ⋯ + 푏푛푏푢 푡 − 푛푏 + 0 0 푒 푡 + 푐1 푒 푡 − 1 + ⋯ + 푐푛푐푒 푡 − 푛푐

⊤ 푑0 푡 is clearly 휽 = 푎0 … 푎0 푏0 … 푏0 correlated 푦 푡 = 흋 푡 ⊤휽 + 푑 푡 , 0 1 푛푎 1 푛푏 0 0 with 흋 푡 , 푑 푡 = 푒 푡 + 푐0푒 푡 − 1 + ⋯ + 푐0 푒 푡 − 푛 0 1 푛푐 푐 unless 퐶0 푧 = 1

30 /44 Estimate an ARX model from ARMAX generated data How can we design the IV in this case? We have two solutions:

• «double experiment» method

• «two-steps experiment» method

31 /44 Double experiment method

1° experiment → 푢 1 , 푢 2 , … , 푢 푁 , 푦 1 , 푦 2 , … , 푦 푁

퐵 푧; 휽 퐶 푧; 휽 푦 푡 = 0 푢 푡 − 1 + 0 푒 푡 푒 푡 ∼ WN 0, 휆2 퐴0 푧; 휽 퐴0 푧; 휽

2° experiment → 푢 1 , 푢 2 , … , 푢 푁 , 푦′ 1 , 푦′ 2 , … , 푦′ 푁

퐵 푧; 휽 퐶 푧; 휽 푦′ 푡 = 0 푢 푡 − 1 + 0 푒′ 푡 푒′ 푡 ∼ WN 0, 휆2 퐴0 푧; 휽 퐴0 푧; 휽 Remark In the two experiments only the inputs are the same; on the contrary, the outputs are different, due to a different noise realization

32 /44 Double experiment method We can design an IV as: 푦′ 푡 − 1 • 풛 푡 and 흋 푡 are strongly correlated, just differing 푦′ 푡 − 2 in the noise realization ⋮ 푦′ 푡 − 푛 풛 푡 = 푎 • 풛 푡 ⊥ 푑0 푡 assuming: 푢 푡 − 1 푢 푡 − 2 ✓ 푒 푡 ⊥ 푒′ 푡 → true if unpredictable white noise ✓ 푢 푡 ⊥ 푒 푡 → true in case of open-loop systems 푢 푡 − 푛푏 Advantage: we used two experiments with exactly corresponding inputs (variable with greatest interest) Disadvantage: it is not always possible to make a double experiment, i.e. in case of critical systems

33 /44 Two-steps method We build a new 푦ු 푡 signal: 퐵ෘ 푧 푦ු 푡 = 푢 푡 − 1 퐴ሙ 푧 퐵ෘ 푧 where is an asymptotically stable filter and 푢 푡 is a measured input. Then we set 퐴ෘ 푧

푦ු 푡 − 1 • The 푢 part is greatly correlated 푦ු 푡 − 2 ⋮ • 풛 푡 ⊥ 푑 푡 if 푒 푡 ⊥ 푢 푡 , since 푦ු 푡 is noiseless 푦ු 푡 − 푛 0 풛 푡 = 푎 푢 푡 − 1 푢 푡 − 2

푢 푡 − 푛푏

34 /44 Two-steps method Advantage: no double experiment is requested 퐵ෘ 푧 Disadvantage: many degrees of freedom in the filter choice. 퐴ෘ 푧

Choice of the filter

퐵ෘ 푧 • Simplest option: = 1 ⇒ 푦ු 푡 = 푢 푡 − 1 퐴ෘ 푧

퐵෠ 푧;휽෡ • Alternative option: use a PEM method to estimate from 푢 푡 , 푦 푡 푁 (which 퐴෠ 푧;휽෡ 푡=1

퐵 푧;휽 퐵෠ 푧;휽෡ will be an incorrect model but similar to 0 0 ). Then, get 푦ු 푡 = 푢 푡 퐴0 푧;휽0 퐴෠ 푧;휽෡

35 /44 Example (ARX model from ARMAX generated data) Assume that the system generating the data is an ARMAX(2,2,1)

0 0 0 0 푆: 푦 푡 = 푎1푦 푡 − 1 + 푎2푦 푡 − 2 + 푒 푡 + 푐1 푒 푡 − 1 + 푐2 푒 푡 − 2 + 푏1푢 푡 − 1

0 0 0 0 0 0 ⊤ ⊤ • 휽 = 푎1 푎2 푏1 푐1 푐2 = 0.2 − 0.5 1 0.5 0.75 • 푒 ⋅ = 푢 ⋅ = WN 0,1 , 푒 ⊥ 푢

We want to estimate an ARX(2,1) model

2 푀: 푦 푡 = 푎1푦 푡 − 1 + 푎2푦 푡 − 2 + 푏1푢 푡 − 1 + 휂 푡 휂 ⋅ ∼ WN 0, 휆 , 푢 ⋅ = WN 0,1 , 휂 ⊥ 푢

In order to obtain consistent estimates, we employ the showed IV approach with the double experiment method

See arx_iv.m MatLab file 36 /44 Example (ARX model from ARMAX generated data) Least squares Instrumental variables

See arx_iv.m MatLab file 37 /44 Outline

1. Introduction to error-in-variables problems

2. Least Squares revised

3. The instrumental variable method

4. Estimate an ARX model from ARMAX generated data

5. Application study: the VRFT approach for direct data driven control

6. Conclusions

38 /44 Model-reference cost Application study: VRFT 2 function 퐺 푧 푅 푧; 휽 What we would like to minimize: 퐽푀푅 휽 = − 푀 푧 ⋅ 푊 푧 1 + 퐺 푧 푅 푧; 휽 푊 푧 is frequency Campi, M. C., Lecchini, A., & Savaresi, S. M (2002) 2 푁 weight filter 1 2 What we can minimize instead: 퐽푁 휽 = ෍ 푢 푡 − 푅 푧; 휽 푒 푡 Virtual-reference 푉푅 푁 퐿 퐿 푡=1 cost function

Given a set of I/O measures 푢 푡 , 푦 푡 푡=1,…,푁 푇 푇 푅 푧; 휽 푒퐿 푡 = 휷 푧 푒퐿 푡 휽 = 흋 푡 휽 Compute: −1 • Filtered input 푢 푡 = 퐿 푧 푢 푡 • Virtual noisy reference 푟푣ҧ 푡 = 푀 푧 푦 푡 퐿 • noisy Regressor 흋 푡 = 휷 푧 푒 푡 • Filtered noisy virtual error 푒퐿 푡 = 퐿 푧 푟푣ҧ 푡 − 푦 푡 퐿 • Instrumental variable 풛 푡 ✓ Perform another experiment with same input 푢 푡 , 푦′ 푡 푊 푧 1−푀 푧 푀 푧 • 퐿 푧 = 1 −1 ′ 푡 훷푢 푧 2 ✓ Compute 풛 푡 = 휷 푧 퐿 푧 푀 푧 − 1 푦 = 휷 푧 푒′퐿 푡

푁 The filter 퐿 푧 is necessary to guarantee that 퐽푉푅 is a ∗ good approximation of 퐽푀푅 optimal controller 푅 does 39 /44 not belong to the class of chosen ones ℛ Application study: VRFT Noiseless data (100 Monte Carlo runs) Input: 512 samples of WGN with zero mean and variance 0.01

Controller class

휃 + 휃 푧−1 + 휃 푧−2 + 휃 푧−3 + 휃 푧−4 + 휃 푧−5 푅 푧; 휽 = 0 1 2 3 4 5 1 − 푧−1

Case 1: 퐿(푧) = 1

Not using the optimal prefilter leads to bad results

40 /44 Application study: VRFT Noiseless data (100 Monte Carlo runs)

1 Case 2: 퐿 푧 = 1 ⋅ 1 − 푀 푧 푀 푧 ⋅ 0.1

1 푊 푧 = 1, 훷푢 푧 2 = 0.1

The use of the optimal prefilter leads to accurate results

41 /44 Application study: VRFT 1 1 Case 3: 퐿 푧 = 1 ⋅ 1 − 푀 푧 푀 푧 ⋅ 푊 푧 = 1, 훷 푧 2 = 0.1 0.1 푢 Noisy data with Instrumental Noisy data with Least Squares Variables (requires a 2° experiment)

Bias at higher freqs Bias is removed

42 /44 Outline

1. Introduction to error-in-variables problems

2. Least Squares revised

3. The instrumental variable method

4. Estimate an ARX model from ARMAX generated data

5. Application study: the VRFT approach for direct data driven control

6. Conclusions

43 /44 Conclusions • Error-in-variables problems arise frequently in engineering and control. Properly tackling them requires specific techniques to obtain consistent estimates

• The instrumental variable methods are an approach to solve EIV problems, that consist in defining a new regressor variable to be used in place of the original one

• We focused specifically on the linear regression setting, and how to modify the least squares solution

• Other methods exist to solve EIV problems, such as: bias-compensation, generalized instrumental variable, covariance matching, total least squares

44 /44 References • T. Söderström, “Errors-in-Variables Methods in System Identification”, Springer, 2018. • Campi, M. C., Lecchini, A., & Savaresi, S. M. (2002). Virtual reference feedback tuning: a direct method for the design of feedback controllers. Automatica, 38(8), 1337-1346.

45 /44