File Exchange

## Total Least Squares with mixed and/or weighted disturbances

version 2.0.0.1 (8.04 KB) by
Generalized Total Least Squares with mixed and/or weighted disturbances

10 Downloads

Updated 01 Apr 2021

From GitHub

These functions calculates the solution for the generalized and/or mixed total least squares problem.

The total least squares problem, also known as errors in variables, solves the over-determined set of linear equations (A0+dA)X = (B0+dB), where covariance matrix of the unknown disturbances dA and dB is considered to be diagonal and denoted by E([dA dB]^T[dA dB]) = sigma_d.*I.

The mixed total least squares problem solves the over-determined set of linear equations [A1 A2]X = B, where A1 are the error-free variables, and A2 = A0 + dA2 and B = B0 + dB are the variables with disturbances.

The generalized total least squares problem solves the over-determined set of linear equations (A0 + dA)X = (B0 + dB), where the covariance matrix of the disturbances dA and dB is positive definite and given by sigma_d.*W = E([dA dB]^T[dA dB]).

### Cite As

Ivo Houtzager (2021). Total Least Squares with mixed and/or weighted disturbances (https://github.com/iwoodsawyer/gtls/releases/tag/v2.0.0.1), GitHub. Retrieved .

### Comments and Ratings (11)

Ivo Houtzager

The references are given in the help description of the functions.

matlabaaa

Regarding your codes, can you give the corresponding references?

SK

eashe

I have the same problem. Does anyone know a solution?

A S

Elliot is right. There must be something wrong with the code.
W = E([dA dB][dA dB]^T) implies that W must be (m+n)*(m+n) where A is m*n, B is n*p. But in the code we have:
R = chol(W);
[U,V,Z,C,S] = gsvd([A B],R)
which implies that number of columns of R and therefore W should be the same as that of [A B]. This implies that W should be n+p. That is why in the example the size of W is 6 (m=1000, n=4, p=2).

Elliot Broussard

Dear Ivo,

Thank you for this toolbox.

I would like to use the function "wtls" and I have a issue computing the weigh matrix W. In my case, the error dA depends on the line of the matrix A = A0+dA. I know the standart deviation of the error for each line of A. Thoses errors are considered uncorrelated, wich means that W should be diagonal.

Considering my reading, I though the weight matrix was a m by m diagonal matrix, with m the number of equations (1000 in the examples provided). In the wtls function, the weigh matrix should be n by n, with n the number of parameters to be determined.

Could you please explain how to compute W in the case that each line has a different standart deviation disturbance.

I thank you in advance.

Elliot

Sergio Herrera

Thank you, I works perfect.

Ivo Houtzager

Dear Segio,

Try to look at the singular values which are calculated in the function tls. Plot the singular values using semilogy(s,'x'). Look if there is a big gap between the singular values. Choose tol geater than the singular values which are not dominant in the plot, but smaller than the dominant singular values.

Ivo

Sergio Herrera

Dear Ivo,
I try tls(A,B), and I am getting the same results with my implementation, But I don't understand the third argument varargin, I understand is the tolerance, but how can this be determine? from the data?

Sergio Herrera

Dear Ivo,
I try tls(A,B), and I am getting the same results with my implementation, But I don't understand the third argument varargin, I understand is the tolerance, but how can this be determine? from the data?

Louie Law

##### MATLAB Release Compatibility
Created with R2012b
Compatible with any release
##### Platform Compatibility
Windows macOS Linux
##### Acknowledgements

Inspired by: QR/RQ/QL/LQ factorizations

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!