LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

esd of linear fit

Solved!
Go to solution

Hi

I have some "simple" questions.

I am trying to fit a straight line, I have done this many times in the past. However for this data (see below) Igor gives me a slope of 254.3 +/- 11.6

In labview, see attached vi, with the same data I get 254.3 (ok !)  with delta slope = 0

Why delta slope is "0" ? As one can see from the data, there is some space between lower and upper limits.

 

Also, is there a labview vi that gives the slope and the esd of the slope if X and Y arrays have some esd ? (I suspect "ponderation" is to be used, but it is not to me clear how exactly )

thanks for any idea

 

0 Kudos
Message 1 of 7
(2,822 Views)

An interesting question/problem.  I tried it, and tried playing with it, and learned some things (always a good thing!).  Here are some observations:

  • You are using the "standard model" of fitting data where X (the independent variable) is assumed to be known, and Y is the "unknown" measured quantity with some variability.
  • Your data are "unsorted in X", which should make no difference when estimating slopes, but definitely affects plotting (as I'm sure you realized when your Plot 0 had "funny lines", fixed by plotting them as points).  This may also have an impact when you plot the Confident Bounds.
  • Your data look like they fit a quadratic better than a linear function.  I was surprised to see that the Upper and Lower bounds did not "contain" the data points in your plot, but did in mine.  Then I noticed I left the default Confidence Interval at 95% -- when I narrowed it as you did, I got your fit.
  • Note that you plot the Bounds as lines, but they are also unsorted, so the "lines" may be doubled in places.  Points are safer.
  • So why is Delta-Slope zero?  [Delta-Intercept is not zero.]  I don't know, but I'll try to find out on Monday.

Bob Schor

0 Kudos
Message 2 of 7
(2,795 Views)

Hi

Thanks for your answer. The order of the arrays is not important (just funny for graphing), anyway I ordered them.

Note that RMSE is not 0 though (see modified version)

Regards

0 Kudos
Message 3 of 7
(2,791 Views)

I can't "see" inside the code NI is using, so I'm uncertain as to the reason for this value.  One (strong) possibility is that with only 5 points, there are not enough data to make a sensible estimate of the upper and lower limit for a linear fit.  Try generating a 10-point set and see if that gives you a reasonable number.  Two points determine an "exact" line, three allow you to have "error", but if you want to put a measure on the Error, you need more than a single sample (which means more points) ...

 

Bob Schor

0 Kudos
Message 4 of 7
(2,785 Views)

Hi

Thanks for yuour answer, althtough I don't agree with it. Matthematically, even with 3 points one can calculate a esd of a slope (it has one degree of libherty). Igor and Origin can calculate that, why not LV ???

Anyway, I put 2 more points :

Igor gives a slope of 279.07 with 16.1 esd

LV gives 287. with delta 4.9 E-17 !! (Funny thing, the intercept and its delta is similar for both programs !)

What I am doing wrong ? I have calculate slopes before in LV and all was OK.

For testing with my data, I attached the code here.

Thanks

0 Kudos
Message 5 of 7
(2,773 Views)
Solution
Accepted by nitad54448

You are running into conditioning problems, because your inputs are poorly scaled. Multiply your x-values with 1E9 and you get a nonzero value and then calculate the scaled value back later. (And no, higher order polynomial would make conditioning even worse (e.g. ~1e-18 for the quadratic terms).

 

betterscaling.png

 

 

 

Message 6 of 7
(2,760 Views)

Hi

That must be it. Thanks !

(Just a thought : how come Igor -treating the same data- does not have the same conditioning problem ?? Maybe they are adjusting the X values internally ?)

Anyway, that solves my problem

thanks again

N

0 Kudos
Message 7 of 7
(2,755 Views)