From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Linear Fit Coefficients: NaN when using Bisquare

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 🙂

 

 

 

Download All
0 Kudos
Message 1 of 8
(3,325 Views)

Just graphing your data (picture), I wonder in what universe you think that the data should fit to a linear model. 😄

 

 

0 Kudos
Message 2 of 8
(3,319 Views)
Xy plots may give you the wrong intuition, try the time domain plots
0 Kudos
Message 3 of 8
(3,298 Views)

But you are not fitting time domain data!

Maybe you should use a linear x ramp instead.

0 Kudos
Message 4 of 8
(3,294 Views)

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.

0 Kudos
Message 5 of 8
(3,287 Views)

Here is X and Y vs. array index. Does not look very linear either.

 

 

0 Kudos
Message 6 of 8
(3,277 Views)

Dear Altenbach,

 

Thank you for the effort Smiley Happy

 

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?

0 Kudos
Message 7 of 8
(3,252 Views)

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.

Message 8 of 8
(3,244 Views)