Uncertainty of linear and non linear least-squares fit

Click For Summary

Discussion Overview

The discussion revolves around the uncertainties associated with linear and non-linear least-squares fitting in experimental data analysis. Participants explore methods for calculating uncertainties in parameters derived from linear and cubic fits, as well as the implications of measurement errors on these calculations.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant describes a linear relationship between displacement and voltage and seeks to relate fit errors to the derived equation for displacement.
  • Another participant suggests estimating parameters using a different form of the equation and introduces matrix notation for least squares estimation.
  • Disagreement arises regarding the relationship between parameters in linear fits, with one participant asserting that the inverse relationship does not hold and questioning the variance calculation.
  • A later reply clarifies the variance formula and discusses the separation of nonrandom and random parts in the model, emphasizing the role of mean squared error (MSE).
  • Another participant expresses confusion over discrepancies in uncertainty calculations between matrix methods and traditional methods, seeking clarification on the application of R-squared in non-linear fits.
  • Discussion includes a suggestion to define variance using the sum of squared errors (SSE) and a clarification that the term "nonlinear" refers to nonlinearity in parameters rather than the form of the equation.
  • Participants express a desire to compare results from MATLAB with theoretical calculations, indicating ongoing exploration of the topic.

Areas of Agreement / Disagreement

Participants do not reach consensus on the relationships between parameters in linear fits, the calculation of uncertainties, or the application of R-squared in non-linear fits. Multiple competing views remain, and the discussion is unresolved.

Contextual Notes

Participants note limitations in their calculations, including potential differences in assumptions and methods used for estimating variances. The discussion highlights the complexity of fitting models and the influence of measurement errors on uncertainty assessments.

Shaddyab
Messages
19
Reaction score
0
1) Linear fit

I am running an experiment to find the linear relation between displacement (X) and voltage reading (V) of the measurement, when fitting a linear line to my measured data, such that:

V= m*X + b;

Based on the following links http://en.wikipedia.org/wiki/Regression_analysis (under Linear regression)


d5c6eeaa7a53d17a89c4dc1f2ebfa3fd.png

3804d3bb6d5987b2855c20da49c50254.png

f8d7fac226210b447148f7cef1e5cd69.png


and
http://en.wikipedia.org/wiki/R-squared ( under Definitions)
9b67a43676735e465566d871deb925f1.png



I can find the The standard errors of 'm' and 'b' parameters, Sm and Sb, respectively. and R-squared

So the Uncertainty of my measurement is :

m -/+ Sm

and

b -/+ Sb

But I would like to use the fit in the following way :

x=(V-b)/m

How can I relate the fit error to this form of the equation ?


2) Non-Linear fit

In the second experiment I have the following cubic fit:

X= a3 * (V ^3) + a2 * (V ^2) + a1 * (V) + a0

How can I find the uncertainty of a3, a2, a1, and a0 ? because I could not find any reference for doing so.

Can I use the same formula I used in the linear case to find the R-squared here for the non-linear fit?
 
Physics news on Phys.org
1) Why don't you estimate x = a0 + a1 V, where a0 = -b/m and a1 = 1/m?
2) Using matrix notation, X = UA, where U = [V^3 V^2 V 1] and A = [a3 a2 a1 a0]'. Define Z = ((U'U)^-1)U'. The least squares estimator is A* = ZX, a 4x1 vector. Var(A*) = Z' Var(X) Z = (U'U)^-1 Var(X), which is a 4x4 matrix. The diagonal terms are variances; off-diagonal terms are covariances.
 
Last edited:
1)

I disagree with that:
if I fit a line as
V=m1 * X + b1

and

X= m2* V + b2;

Then

m2 IS NOT equal to 1/m1
and b2 is NOT equal to -b1/m2

you can run a simple Matlab code and see this.2)
Can you please re-write the equation to find the Var of A ( Var[A] ) I was not able to understand it.
is it
Var(A*) = Z' Var(X) Z ?
What does MSE means?
is (Z'Z)^-1 part of the equation?

Thank you
 
Last edited:
You are correct; m2 is not equal to 1/m1 and and b2 is not equal to -b1/m2. [However, the standardized coefficients m1/s.e.(m1) and m2/s.e.(m2) are equal, where "s.e." is the standard error of the coefficient. This topic came up before in this forum, see https://www.physicsforums.com/showthread.php?t=316155.] All of this is tangential to your main question, which is, "how do you incorporate measurement error of X into the overall error of the regression?" Sorry to send you in the wrong direction there.

Var(A*) = Var(ZX) = Z Var(X) Z' is the matrix equivalent of the formula Var(aX) = Var(X)a^2. When you make the substitution Z = ((U'U)^-1)U', Var(A*) simplifies to (U'U)^-1 Var(X). Note that as long as X is the dependent variable, it can be separated into a nonrandom part (UA) and a random part (the error, or the residual); the complete model is X = UA + error. Since UA is nonrandom, Var(X) = Var(error) = MSE.
 
Once again I would like to thank you for your valuable help.

I am using what you mentioned in your previous posts to solve the following system of equations for a very simple linear case. X= a1*V+a0
where,

X = UA
U = [V 1] and A = [a1 a0]'.
Defining Z = ((U'U)^-1)U'.
and solving the least squares estimator A = ZX.
I am comparing my results with what I get from 'polyfit' in Matlab, obviously I get the same result.

The problem is when I solve the following equation to find the uncertainty of a0 and a1

Var(A*) = Z' Var(X) Z = (U'U)^-1 Var(X)

The numbers here are NOT similar what I get from finding the uncertainty using the three equations I mentioned in my first post.

In addition, Can I use the same formula I used in the linear case ( X=a*V+b ) to find the R-squared for the non-linear fit ( X= a3 * (V ^3) + a2 * (V ^2) + a1 * (V) + a0 )


Thank you
 
Have you tried defining var X = SSE/(N-2)? Do you find a different result using the matrix formula?

What you are referring as the nonlinear fit is in fact linear, so yes, the same formula applies. The term nonlinear is reserved for nonlinearity in parameters, for example X = ab + V^b.
 
As I already mentioned, I am trying to run a very simple case of linear line (X= a1*V+a0) because I already know how to find the uncirtinty in a0 and a1 for this case ( based on the three equations that I have in my first post where var X = SSE/(N-2) )

While:

Var(A*) = Z' Var(X) Z = (U'U)^-1 Var(X)
is giving me a different result for the uncertainty in a0 and a1 .

I can post the MATLAB code if this could be on any help.
 

Similar threads

  • · Replies 28 ·
Replies
28
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 30 ·
2
Replies
30
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 16 ·
Replies
16
Views
3K
Replies
8
Views
2K
  • · Replies 26 ·
Replies
26
Views
3K