11-04-2013 11:11 AM
Dear LabVIEWer,
I am trying to linear fit a Y vector to X vector. When using the "Least Square"method, I get a proper output for slope, intercept and the error code=0.
BUT, when I use "Least Absolute Residual method", I am getting NaN values for slope and intercept with error code=-20055.
AND, when I use "Bisqaure method", I am getting NaN values for slope and intercept with error code=0.
The concerned program is LabVIEW 2013, NI_AALPro.lvlib: Linear Fit Coefficients.vi (I have also attached it for your perusal).
Thank you for your help, in advance 🙂
11-04-2013 11:26 AM - edited 11-04-2013 11:27 AM
Just graphing your data (picture), I wonder in what universe you think that the data should fit to a linear model. 😄
11-04-2013 12:15 PM
11-04-2013 12:18 PM
But you are not fitting time domain data!
Maybe you should use a linear x ramp instead.
11-04-2013 12:47 PM
celestiallylvd1 wrote:I am trying to linear fit a Y vector to X vector...
you probably need to tell us what you mean by that.
Your VI (with the default data shown) tries to fit Y vs. X linearly.
Do you want to fit y vs. array index? X vs. array index? Or something else?
Show us how you display the data where a linear fit would look like a reasonable match.
11-04-2013 01:14 PM - edited 11-04-2013 01:15 PM
11-05-2013 02:28 AM
Dear Altenbach,
Thank you for the effort
As you can see, Y= 0.5 * X for most data points. Least Squares method comes close to that answer (slope=0.43, intercept=0.015). Now, a Bisquare algorithm is supposed to give better results as it by definition ignores outliers.
IRRESPECTIVE of this, I am not supposed to get NaN for any VALID data when erro code=0. Don't you think it is a bug in LabVIEW?
11-05-2013 03:00 AM - edited 11-05-2013 03:08 AM
Unfortunately, the inner code is inside a dll, thus I cannot really see what's going on. But yes, I agree that the behavior for absolute and bisqaure does not look right.
To make an example, I recommend NOT to gut the linear fit VI and use only part of the inner code. Just hook you controls and indicators to the plain linear fit function to keep things more reproducible.
Problem 1: least absolute residual: NaN/NaN, Error -20055: Analysis: The number of categories or samples must be greater than one.
( error description does not sound appropriate for this scenario!)
Problem 2: bisquare: NaN/NaN, error=0 (??). I agree, this is also unexpected.
Hopefully someone from NI can investigate. I'll post a link in the monthly bug thread.