# Total least squares

﻿
Total least squares
The bivariate (Deming regression) case of Total Least Squares. The red lines show the error in both x and y. This is different from the traditional least squares method which measures error parallel to the y axis. The case shown, with deviations measured perpendicularly, arises when x and y have equal variances.

Total least squares, also known as errors in variables, rigorous least squares, or (in a special case) orthogonal regression, is a least squares data modeling technique in which observational errors on both dependent and independent variables are taken into account. It is a generalization of Deming regression, and can be applied to both linear and non-linear models.

## Linear model

### Background

In the least squares method of data modeling, the objective function, S,

$S=\mathbf{r^TWr},$

is minimized, where r is the vector of residuals and W is a weighting matrix. In linear least squares the model contains equations which are linear in the parameters appearing in the parameter vector $\boldsymbol\beta$, so the residuals are given by

$\mathbf{r=y-X\boldsymbol\beta}.$

There are m observations in y and n parameters in β with m>n. X is a m×n matrix whose elements are either constants or functions of the independent variables, x. The weight matrix, W, is, ideally, the inverse of the variance-covariance matrix, $\mathbf M_y$, of the observations, y. The independent variables are assumed to be error-free. The parameter estimates are found by setting the gradient equations to zero, which results in the normal equations [note 1]

$\mathbf{X^TWX\boldsymbol\beta=X^T Wy}$

### Allowing observation errors in all variables

Now, suppose that both x and y are observed subject to error, with variance-covariance matrices $\mathbf M_x$ and $\mathbf M_y$ respectively. In this case the objective function can be written as

$S=\mathbf{r_x^TM_x^{-1}r_x+r_y^TM_y^{-1}r_y}$

where $\mathbf r_x\,$ and $\mathbf r_y\,$ are the residuals in x and y respectively. Clearly these residuals cannot be independent of each other, but they must be constrained by some kind of relationship. Writing the model function as $\mathbf{f(r_x,r_y,\boldsymbol\beta)}$, the constraints are expressed by m condition equations.[1]

$\mathbf{F=\Delta y -\frac{\partial f}{\partial r_x} r_x-\frac{\partial f}{\partial r_y} r_y -X\Delta\boldsymbol\beta=0}$

Thus, the problem is to minimize the objective function subject to the m constraints. It is solved by the use of Lagrange multipliers. After some algebraic manipulations,[2] the result is obtained.

$\mathbf{X^TM^{-1}X\Delta \boldsymbol\beta=X^T M^{-1} \Delta y}$, or alternatively $\mathbf{X^TM^{-1}X \boldsymbol\beta=X^T M^{-1} y}$

Where M is the variance-covariance matrix relative to both independent and dependent variables.

$\mathbf{M=K_xM_xK_x^T+K_yM_yK_y^T;\ K_x=-\frac{\partial f}{\partial r_x},\ K_y=-\frac{\partial f}{\partial r_Y}}$

### Example

In practice these equations are easy to use. When the data errors are uncorrelated, all matrices M and W are diagonal. Then, take the example of straight line fitting.

$f(x_i,\beta)=\alpha + \beta x_i\!$

It is easy to show that, in this case

$M_{ii}=\sigma^2_{y,i}+\beta^2 \sigma^2_{x,i}$

showing how the variance at the ith point is determined by the variances of both independent and dependent variables and by the model being used to fit the data. The expression may be generalized by noting that the parameter β is the slope of the line.

$M_{ii}=\sigma^2_{y,i}+\left(\frac{dy}{dx}\right)^2_i \sigma^2_{x,i}$

An expression of this type is used in fitting pH titration data where a small error on x translates to a large error on y when the slope is large.

### Algebraic point of view

First of all it is necessary to note that the TLS problem does not have a solution in general, which was already shown in[3] The following considers the simple case where a unique solution exists without making any particular assumptions.

The computation of the TLS using singular value decomposition is described in standard texts.[4] We can solve the equation

AX = B

for X where A is m-by-n and B is m-by-k.

That is, we seek to find X that minimizes error matrices E and F for A and B respectively. That is,

$\mathrm{argmin}_{E,F} \| [E\; F] \|_F, \qquad (A+E) X = B+F$

where $[E\; F]$ is the augmented matrix with E and F side by side and $\|\cdot\|_F$ is the Frobenius norm, the square root of the sum of the squares of all entries in a matrix and so equivalently the square root of the sum of squares of the lengths of the rows or columns of the matrix.

This can be rewritten as

$[(A+E) \; (B+F)] \begin{bmatrix} X\\ -I_k\end{bmatrix} = 0$.

where Ik is the $k\times k$ identity matrix. The goal is then to find $[E\; F]$ that reduces the rank of $[A\; B]$ by k. Define [U][Σ][V] * to be the singular value decomposition of the augmented matrix $[A\; B]$.

$[A\; B] = [U_A\; U_B] \begin{bmatrix}\Sigma_A &0 \\ 0 & \Sigma_B\end{bmatrix}\begin{bmatrix}V_{AA} & V_{AB} \\ V_{BA} & V_{BB}\end{bmatrix}^* = [U_A\; U_B] \begin{bmatrix}\Sigma_A &0 \\ 0 & \Sigma_B\end{bmatrix} \begin{bmatrix} V_{AA}^* & V_{BA}^* \\ V_{AB}^* & V_{BB}^*\end{bmatrix}$

where V is partitioned into blocks corresponding to the shape of A and B.

The rank is reduced by setting some of the singular values to zero. That is, we want

$[(A+E)\; (B+F)] = [U_A\; U_B] \begin{bmatrix}\Sigma_A &0 \\ 0 & 0_{k\times k}\end{bmatrix}\begin{bmatrix}V_{AA} & V_{AB} \\ V_{BA} & V_{BB}\end{bmatrix}^*$

so by linearity,

$[E\; F] = -[U_A\; U_B] \begin{bmatrix}0_{n\times n} &0 \\ 0 & \Sigma_B\end{bmatrix}\begin{bmatrix}V_{AA} & V_{AB} \\ V_{BA} & V_{BB}\end{bmatrix}^*$.

We can then remove blocks from the U and Σ matrices, simplifying to

$[E\; F] = -U_B\Sigma_B \begin{bmatrix}V_{AB}\\V_{BB}\end{bmatrix}^*= -[A\; B] \begin{bmatrix}V_{AB}\\V_{BB}\end{bmatrix}\begin{bmatrix}V_{AB}\\ V_{BB}\end{bmatrix}^*$.

This provides E and F so that

$[(A+E) \; (B+F)] \begin{bmatrix}V_{AB}\\ V_{BB}\end{bmatrix} = 0$.

Now if VBB is nonsingular, which is not always the case (note that the behavior of TLS when VBB is singular is not well understood yet), we can then right multiply both sides by $-V_{BB}^{-1}$ to bring the bottom block of the right matrix to the negative identity.

$[(A+E) \; (B+F)] \begin{bmatrix} -V_{AB} V_{BB}^{-1} \\ -V_{BB} V_{BB}^{-1}\end{bmatrix} = [(A+E) \; (B+F)] \begin{bmatrix} X\\ -I_k\end{bmatrix} = 0$

and so

$X=-V_{AB} V_{BB}^{-1}$.

[5]

A naive GNU Octave implementation of this is:

function X = tls(xdata,ydata)

m       = length(ydata)       %number of x,y data pairs
A       = [ones(m,1) xdata];
B       = ydata;
n       = size(A,2);          % n is the width of A (A is m by n)
C       = [A B];              % C is A augmented with B.
[U S V] = svd(C,0);           % find the SVD of C.
VAB     = V(1:n,1+n:end);     % Take the block of V consisting of the first n rows and the n+1 to last column
VBB     = V(1+n:end,1+n:end); % Take the bottom-right block of V.
X       = -VAB/VBB;
end


The above described way of solving the problem, provided by nonsingularity of matrix VBB, can be slightly extended by so called classical TLS algorithm.[6]

### Computation

The standard implemenation of classical TLS algorithm is available through Netlib, see also.[7][8] All modern implementations based, for example, on solving a sequence of ordinary least squares problems, approximate the matrix X introduced by Van Huffel and Vandewalle. It is worth noting, that this X is, however, not the TLS solution in many cases.[9][10]

## Non-linear model

For non-linear systems similar reasoning shows that the normal equations for an iteration cycle can be written as

$\mathbf{J^TM^{-1}J\Delta \boldsymbol\beta=J^T M^{-1} \Delta y}.$

## Geometrical interpretation

When the independent variable is error-free a residual represents the "vertical" distance between the observed data point and the fitted curve (or surface). In total least squares a residual represents the distance between a data point and the fitted curve measured along some direction. In fact, if both variables are measured in the same units and the errors on both variables are the same, then the residual represents the shortest distance between the data point and the fitted curve, that is, the residual vector is perpendicular to the tangent of the curve. For this reason, this type of regression is sometimes called "two dimensional Euclidean regression" (Stein, 1983) .[11]

A serious difficulty arises if the variables are not measured in the same units. First consider measuring distance between a data point and the curve - what are the measurement units for this distance? If we consider measuring distance based on Pythagoras' Theorem then it is clear that we shall be adding quantities measured in different units, and so this leads to meaningless results. Secondly, if we rescale one of the variables e.g., measure in grams rather than kilograms, then we shall end up with different results (a different curve). To avoid this problem of incommensurability it is sometimes suggested that we convert to dimensionless variables—this may be called normalization or standardization. However there are various ways of doing this, and these lead to fitted models which are not equivalent to each other. One approach is to normalize by known ( or estimated ) measurement precision thereby minimizing the Mahalanobis distance from the points to the line, providing a maximum-likelihood solution.[citation needed]

## Scale invariant methods

In short, total least squares does not have the property of units-invariance (it is not scale invariant). For a meaningful model we require this property to hold. A way forward is to realise that residuals (distances) measured in different units can be combined if multiplication is used instead of addition. Consider fitting a line: for each data point the product of the vertical and horizontal residuals equals twice the area of the triangle formed by the residual lines and the fitted line. We choose the line which minimizes the sum of these areas. Nobel laureate Paul Samuelson proved that it is the only line which possesses a set of certain desirable properties which includes scale invariance and invariance under interchange of variables (Samuelson, 1942).[12] This line has been rediscovered in different disciplines and is variously known as the reduced major axis, the geometric mean functional relationship (Draper and Smith, 1998),[13] least products regression, diagonal regression, line of organic correlation, and the least areas line. Tofallis (2002) [14] has extended this approach to deal with multiple variables.

## Notes

1. ^ An alternative form is $\mathbf{X^TWX\boldsymbol\Delta \boldsymbol\beta=X^T W \boldsymbol\Delta y}$, where $\boldsymbol\Delta \boldsymbol\beta$ is the parameter shift from some starting estimate of $\boldsymbol\beta$ and $\boldsymbol\Delta \mathbf y$ is the difference between y and the value calculated using the starting value of $\boldsymbol\beta$

## References

1. ^ W.E. Deming, Statistical Adjustment of Data, Wiley, 1943
2. ^ P. Gans, Data Fitting in the Chemical Sciences, Wiley, 1992
3. ^ G. H. Golub and C. F. Van Loan, An analysis of the total least squares problem. Numer. Anal., 17, 1980, pp. 883-893.
4. ^ Gene H. Golub and Charles F. Van Loan (1996). Matrix Computations (3rd ed.). The Johns Hopkins University Press.  pp 596.
6. ^ S. Van Huffel and J. Wandewalle, The Total Least Squares Problems: Compational Aspects and Analysis. SIAM Pulications, Philadelphia PA, 1991.
7. ^ S. Van Huffel, Documented Fortran 77 programs of the extended classical total least squares algorithm, the partial singular value decomposition algorithm and the partial total least squares algorithm, Internal Report ESAT-KUL 88/1, ESAT Lab., Dept. of Electrical Engineering, Katholieke Universiteit Leuven, 1988.
8. ^ S. Van Huffel, The extended classical total least squares algorithm, J. Comput. Appl. Math., 25, pp. 111-119, 1989.
9. ^ M. Plešinger, The Total Least Squares Problem and Reduction of Data in AX ≈ B. Doctoral Thesis, TU of Liberec and Institute of Computer Science, AS CR Prague, 2008. Ph.D. Thesis
10. ^ I. Hnětynková, M. Plešinger, D. M. Sima, Z. Strakoš, and S. Van Huffel, The total least squares problem in AX ≈ B. A new classification with the relationship to the classical works. Submitted to SIMAX, 2010.
11. ^ Yaakov (J) Stein. Two Dimensional Euclidean Regression.
12. ^ Paul A. Samuelson (1942). "A Note on Alternative Regressions". Econometrica (The Econometric Society) 10 (1): 80–83. doi:10.2307/1907024. JSTOR 1907024.
13. ^ Draper, NR and Smith, H. Applied Regression Analysis, 3rd edition,pp.92-96. 1998
14. ^ Model fitting for multiple variables by minimising the geometric mean deviation Downloadable from: http://papers.ssrn.com/sol3/papers.cfm?abstract_id=1077322

### Others

• I. Hnětynková, M. Plešinger, D. M. Sima, Z. Strakoš, and S. Van Huffel, The total least squares problem in AX ≈ B. A new classification with the relationship to the classical works. Submitted to SIMAX, 2010, preprint
• M. Plešinger, The Total Least Squares Problem and Reduction of Data in AX ≈ B. Doctoral Thesis, TU of Liberec and Institute of Computer Science, AS CR Prague, 2008. Ph.D. Thesis
• I. Markovsky and S. Van Huffel, Overview of total least squares methods. Signal Processing, vol. 87, pp. 2283–2302, 2007. preprint
• C. C. Paige, Z. Strakoš, Core problems in linear algebraic systems. SIAM J. Matrix Anal. Appl. 27, 2006, pp. 861–875.
• S. Van Huffel and P. Lemmerling, Total Least Squares and Errors-in-Variables Modeling: Analysis, Algorithms and Applications. Dordrecht, The Netherlands: Kluwer Academic Publishers, 2002.
• S. Jo and S. W. Kim, Consistent normalized least mean square filtering with noisy data matrix. IEEE Trans. Signal Processing, vol. 53, no. 6, pp. 2112–2123, Jun. 2005.
• R. D. DeGroat and E. M. Dowling, The data least squares problem and channel equalization. IEEE Trans. Signal Processing, vol. 41, no. 1, pp. 407–411, Jan. 1993.
• S. Van Huffel and J. Vandewalle, The Total Least Squares Problems: Compational Aspects and Analysis. SIAM Pulications, Philadelphia PA, 1991.
• T. Abatzoglou and J. Mendel, Constrained total least squares, in Proc. IEEE Int. Conf. Acoust., Speech, Signal Process. (ICASSP’87), Apr. 1987, vol. 12, pp. 1485–1488.
• P. de Groen An introduction to total least squares, in Nieuw Archief voor Wiskunde, Vierde serie, deel 14, 1996, pp. 237–253 arxiv.org.
• G. H. Golub and C. F. Van Loan, An analysis of the total least squares problem. SIAM J. on Numer. Anal., 17, 1980, pp. 883–893.
• Perpendicular Regression Of A Line at MathPages

Wikimedia Foundation. 2010.

### Look at other dictionaries:

• Least squares — The method of least squares is a standard approach to the approximate solution of overdetermined systems, i.e., sets of equations in which there are more equations than unknowns. Least squares means that the overall solution minimizes the sum of… …   Wikipedia

• Least-squares spectral analysis — (LSSA) is a method of estimating a frequency spectrum, based on a least squares fit of sinusoids to data samples, similar to Fourier analysis. [cite book | title = Variable Stars As Essential Astrophysical Tools | author = Cafer Ibanoglu |… …   Wikipedia

• least squares method — A method of estimating cost behaviour in which observed cost levels for various activity levels are plotted on a graph and the line of best fit is calculated (see linear regression). The regression line can then be used to forecast the total… …   Accounting dictionary

• Ordinary least squares — This article is about the statistical properties of unweighted linear regression analysis. For more general regression analysis, see regression analysis. For linear regression on a single variable, see simple linear regression. For the… …   Wikipedia

• Linear least squares — is an important computational problem, that arises primarily in applications when it is desired to fit a linear mathematical model to measurements obtained from experiments. The goals of linear least squares are to extract predictions from the… …   Wikipedia

• Ordinary Least Squares — Die Regressionsanalyse ist ein statistisches Analyseverfahren. Ziel ist es, Beziehungen zwischen einer abhängigen und einer oder mehreren unabhängigen Variablen festzustellen. Allgemein wird eine metrische Variable Y betrachtet, die von einer… …   Deutsch Wikipedia

• Linear least squares (mathematics) — This article is about the mathematics that underlie curve fitting using linear least squares. For statistical regression analysis using least squares, see linear regression. For linear regression on a single variable, see simple linear regression …   Wikipedia

• Non-linear least squares — is the form of least squares analysis which is used to fit a set of m observations with a model that is non linear in n unknown parameters (m > n). It is used in some forms of non linear regression. The basis of the method is to… …   Wikipedia

• Linear least squares/Proposed — Linear least squares is an important computational problem, that arises primarily in applications when it is desired to fit a linear mathematical model to observations obtained from experiments. Mathematically, it can be stated as the problem of… …   Wikipedia

• Hollywood Squares — Infobox Television show name = Hollywood Squares caption = The Hollywood Squares title screen (1966 1981) genre = Comedy/Quiz creator = Merrill Heatter and Bob Quigley developer = presenter = Peter Marshall (1966 1981) Jon Bauman (1983 1984) John …   Wikipedia