4.5

4.5 | 2 ratings Rate this file 87 Downloads (last 30 days) File Size: 14.76 KB File ID: #31109
image thumbnail

Total Least Squares Method

by Ivo Petras

 

19 Apr 2011 (Updated 09 Oct 2011)

Mathematical method known as total least squares or orthogonal regression or error-in-variables.

| Watch this File

File Information
Description

We present a Matlab toolbox which can solve basic problems related to the Total Least Squares (TLS) method in the modeling. By illustrative examples we show how to use the TLS method for solution of:
- linear regression model
- nonlinear regression model
- fitting data in 3D space
- identification of dynamical system

This toolbox requires another two functions, which are already published in Matlab Central File Exchange. Those functions will be installed to computer via supporting install package 'requireFEXpackage' included in TLS package. For more details see ReadMe.txt file.

Authors: Ivo Petras, Dagmar Bednarova, Tomas Skovranek, and Igor Podlubny
(Technical University of Kosice, Slovakia)

Detailed description of the functions, examples and demos can be found at the link:

Ivo Petras and Dagmar Bednarova: Total Least Squares Approach to Modeling: A Matlab Toolbox, Acta Montanistica Slovaca, vol. 15, no. 2, 2010, pp. 158-170.
(http://actamont.tuke.sk/pdf/2010/n2/8petras.pdf)

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
fminsearchbnd, fminsearchcon, Orthogonal Linear Regression in 3D-space by using Principal Components Analysis

Required Products Statistics Toolbox
MATLAB release MATLAB 7.11 (2010b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (5)
10 Jun 2011 Oleg Nazarevych

??? Undefined function or variable "Yhat".

Error in ==> fit_2D_data at 49
alpha = atan(abs((Yhat-YData)./(Xhat-XData)));
 

27 Aug 2011 Charles Nelatury

Works great!

08 Oct 2011 trison

Thank you very much for you sharing with your package on TLS.
I tested it, and found some mistakes on function [Err, P] = orm(X, Y, order).
They were listed the following:
line 21 kx=length(X); instead of kx=length(Xdata);
line 22 ky=length(Y); instead of ky=length(Ydata);
line 28 P = R/(Q'.*X.^order); When matlab run it, matlab always sent an Error message"
Matrix dimensions must agree".
And the followed line 29 30 may meet the same Error. But I can not get your mean and have not any advise.

10 Jan 2012 Martin

Hi Ivo!

I used numerFminS.m which works very well.

I just want to suggest a minor correction: When you replace 'model' with 'fun' in lines 65 and 77, you can make use of the 'fun' parameter and need no longer rely on the 'model.m'-file. I think that's what you intended anyway, when you created the 'fun' parameter.

Cheers,

Martin

25 Mar 2012 Alex Vaughan

Lovely code. I found one bug, which I believe is the same as the one Martin points out; his fix didn't work for me, though. In numerFminS, the 'fun' parameter is never used, and the fit is always evaluated based on whatever is in model.m. This can be fixed as:

- 65: [yy]=model(xdata, a);
+ 65: [yy] = @(xdata,a)fun(xdata,a)

Following this, I can then call the function without using model.m as:

fun = @(a,x)(a(1) .* ( x.^a(2) ) ./ (x.^a(2) + a(3).^a(2))); %or whatever.
[ErrTLS,P_TLS] = numerFminS( fun , 3 , lowerBounds, upperBounds, x, y)

Cheers,
Alex

Please login to add a comment or rating.
Updates
09 Oct 2011

Updated function orm(). Fixed error discovered by 'Trison'.

Tag Activity for this File
Tag Applied By Date/Time
total least squares Ivo Petras 19 Apr 2011 11:47:24
orthogonal regression Ivo Petras 19 Apr 2011 11:47:24
errorinvariables Ivo Petras 19 Apr 2011 11:47:24
svd Ivo Petras 19 Apr 2011 11:47:24
qr Ivo Petras 19 Apr 2011 11:47:24
pca Ivo Petras 19 Apr 2011 11:47:24

Contact us at files@mathworks.com