Errors of the slope and intercept of a regression line

AI Thread Summary
To calculate the error on the slope and intercept of a regression line with varying y-value error bars, weighted least squares is recommended, using weights of 1/(error)^2. Resources such as Bevington's "Data Reduction and Error Analysis in the Physical Sciences" and "Numerical Recipes in C" provide detailed methodologies for determining fitting parameter errors. Additionally, the Wolfram MathWorld site offers equations for standard errors in slope and intercept. An alternative method involves drawing lines of best fit at maximum and minimum slopes based on the error bars, although this is less rigorous. Understanding these approaches can enhance the accuracy of regression analysis in the presence of error bars.
h_userd23
Messages
3
Reaction score
0
I have set of date with error bars of different length on my y values. I want to know what the error is on the slope and intercept of my line of best fit through this data. Is there a numerical way to calculate this that takes into account the fit of the regression line and the y error bars?
 
Physics news on Phys.org
h_userd23 said:
I have set of date with error bars of different length on my y values. I want to know what the error is on the slope and intercept of my line of best fit through this data. Is there a numerical way to calculate this that takes into account the fit of the regression line and the y error bars?

See: http://en.wikipedia.org/wiki/Weighted_least_squares#Weighted_least_squares

Weights are 1/(error)^2, where "error" is the uncertainty in the y-value
 
Thanks for the response, but how do you calculate the slope error from that?
 
h_userd23 said:
Thanks for the response, but how do you calculate the slope error from that?

The wiki entry is not very clear.

If you can pick up a copy of Bevington, "Data Reduction and Error Analysis in the Physical Sciences" there is a very nice discussion of calculating the errors on the fitting parameters for least-squares with weights. Another source is Press, Teukolsy, Vetterling and Flannery, "Numerical Recipes in C".

Look at http://mathworld.wolfram.com/LeastSquaresFitting.html for another discussion of this. (Eqs. 34, 35) give equations for the standard errors in the slope and intercept.
 
An alternative approach which may be acceptable is to draw lines of 'best fit' that have the maximum and minimum possible value for the slope. Although this is not as rigorous as the method shown in the post above it is an easy alternative (especially if you also have uncertainty in the independent variable). For example, take the first and last data points on the graph and draw the line which just nicks the error bars to form the greatest and least slope. You can show these as dotted lines on the graph as well.
 
Thanks everyone this has been a great help!
 
Back
Top