Measurement error analyses, fitting min/max slopes to data with error bars.

Click For Summary
SUMMARY

This discussion focuses on fitting linear regression lines to datasets with both vertical and horizontal error bars using MATLAB. The user seeks to incorporate individual measurement errors (\Delta x_i and \Delta y_i) into the regression analysis, specifically using weighted fitting techniques. The approach involves calculating weights based on the combined error for each point and utilizing MATLAB's lscov function for the regression. The user also addresses the challenge of estimating true errors in the fit when systematic errors dominate over random errors.

PREREQUISITES
  • Understanding of linear regression analysis
  • Familiarity with MATLAB programming, specifically the lscov function
  • Knowledge of error propagation in measurements
  • Concept of weighted least squares fitting
NEXT STEPS
  • Research "MATLAB weighted linear regression" for practical implementation
  • Explore "error propagation in linear regression" to understand systematic vs. random errors
  • Learn about "covariance matrix in regression analysis" for improved error estimation
  • Investigate "MATLAB error handling in regression" for robust fitting techniques
USEFUL FOR

Researchers, data analysts, and statisticians involved in experimental data analysis, particularly those working with datasets that include measurement errors and requiring precise regression modeling techniques.

deccard
Messages
29
Reaction score
0
I have measurement dataset (x_i,y_i) -pairs with error for each value \Delta x_i and \Delta y_i so that I can plot datapoints with vertical as well as horizontal errorbar. I want to fit linear regression line y=a_1 x + a_0 and also error lines to the data.

But how I take into account as I'm fitting regression line that each datapoint will have its error in x- and y-direction?

And what about the error lines so that I get min and max value of a_1, a_0. I could use standard deviation, but then again this does not take into account the errors \Delta x_i and \Delta y_i.

This picture enlightens my problem
http://www.chemistry.adelaide.edu.au/external/soc-rel/content/images/graph_er.png"

I'm interested only in mathematical ways to do this. I already know how to do this by hand. Especially any Matlab example would be greatly appreciated.
 
Last edited by a moderator:
Physics news on Phys.org
So you want to use the indidvidual error of each measurement as as well as their "standard deviation" (a measurement of how well they all lie on a straight line) to compute the error of your fitting parameters?

How did you do it by hand, maybe it is just a matter of converting it into Matlab code (or whatever)?
 
I have tried to figure this out by myself and I have managed to get the error for fitted regression line to data points with each its own error, but this still is not what i want.

So, again I have I have measurement dataset (x_i,y_i), i=1..k-pairs with error for each value \Delta x_i and \Delta y_i so that I can plot datapoints with vertical as well as horizontal errorbar. I'm going to use weighted fit to solve the regression line for the data.

I can use weights w_i=1/(\Delta y_i)^2 in order to find the solution vector S that will minimize (B - AS)^T diag(W)(B - AS), where
A is a k \times 2 matrix of columns of ones and x_ivalues,
B is a vector made of y_ivalues,
and respectively W is a vector made of w_ivalues.

This is basically what Matlab's function lscov does.

But before I can use the weights, I need to remember that I have also defined errors for x_i values. Thus I cannot directly use the weights w_i=1/(\Delta y_i)^2.

I'm get this around by actually solving first, "regular", non-weighted regression line with slope p. Because we are fitting straight linear line to data we actually can find out what a certain \Delta x_i error is going to be from y-axis point of view by multiplying it by the slope and so we get the total error for i:th point.

\sigma_i = \sqrt{\Delta y_i^2 +(p*\Delta x_i)^2}

and the weights

w_i=1/(\sigma_i)^2

The obvious flaw here is that we have to presume that the slope of weighted regression line is somewhat the same that it is for unweighted regression line. Any way to solve this?

And now the error estimates. For the previous fit we can get estimated standard error. Matlab defines it by

Code:
       X = inv(A'*inv(V)*A)*A'*inv(V)*B
       MSE = B'*(inv(V) - inv(V)*A*inv(A'*inv(V)*A)*A'*inv(V))*B./(M-N)
       S = inv(A'*inv(V)*A)*MSE
       STDX = sqrt(diag(S))

where V is covariance matrix and STDX is the estimated standard error.

Now comes the major problem. If I have regression fit that has relatively small residuals compared to the errors suggesting small random error and large systematic error. The error estimates will actually become smaller than they really are. How I'm going to find the true error for my fit?
Pere Callahan said:
So you want to use the indidvidual error of each measurement as as well as their "standard deviation" (a measurement of how well they all lie on a straight line) to compute the error of your fitting parameters?

How did you do it by hand, maybe it is just a matter of converting it into Matlab code (or whatever)?

I hope that the previous help to understand what I want. But yes, that is what I want.

Well actually by saying by hand I meant that I will draw the lines with ruler on real paper. So there is no way that I could convert that into Matlab code ;)
 

Similar threads

  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
Replies
24
Views
3K
Replies
28
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
8
Views
2K
  • · Replies 8 ·
Replies
8
Views
7K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 11 ·
Replies
11
Views
1K