How does excel calculate the best fit line?

  • Context: Undergrad 
  • Thread starter Thread starter jsbxd9
  • Start date Start date
  • Tags Tags
    Excel Fit Line
Click For Summary

Discussion Overview

The discussion revolves around how Excel calculates the best fit line for data points, particularly in the context of hydraulic modeling with pump curves. Participants explore the iterative process of fitting equations to data points and the implications of adjusting these points on the resulting best fit curve.

Discussion Character

  • Exploratory
  • Technical explanation
  • Mathematical reasoning

Main Points Raised

  • One participant describes the need for an iterative solution to fit an equation to pump curve data points in Excel, noting that moving data points affects the best fit equation.
  • Another participant suggests searching for "least squares regression" as a potential method for fitting the data.
  • A participant questions the approach of moving data points to achieve a better fit, suggesting that if the data is not linear, a different curve fitting method might be more appropriate.
  • One participant explains their method of adjusting dynamic head values to ensure the R² value equals 1, indicating a desire to automate this process using the area under the curve.
  • Another participant advises the need to describe the fitting process in mathematical steps and suggests using a math script program for implementation.

Areas of Agreement / Disagreement

Participants express differing views on the appropriateness of moving data points to achieve a better fit, with some suggesting alternative fitting methods. The discussion remains unresolved regarding the best approach to automate the fitting process.

Contextual Notes

Participants have not fully defined the assumptions behind their methods, and there are unresolved mathematical steps regarding the iterative fitting process and the implications of achieving an R² value of 1.

jsbxd9
Messages
5
Reaction score
0
Background: I am working with pump curves in a hydraulic model. The model is written on excel. In the model pump curves are defined using tested flows vs. dynamic head (ft). The problem I am having is an iterative solution to fit an equation to the data points. Once the first equation is fit to the data points I skew them slightly to induce the R^2 value to 1. Each time I move a data point the best fit equation changes respectively with the order of the equation. The higher the order, the more accurate, hence the more the equation changes each time a data point is moved.

All in all I need to find how excel models the best fit line and comes up with the equation they use so I can experiment with a macro to do the iterative process. Can anyone help?
 
Physics news on Phys.org
Welcome to PF;
Google for "least squares regression".

Am I reading this right:
You move data around to get a better fit?
If your data is not supposed to be a line, why not fit a different curve?
 
Thank you for your reply, that may work.
 
Simon:

When the data is moved around for all the points the 'new' best fit curve is automatically calculated with excel. That curve is then used, by me, to calculate the dynamic head by inputting the flow. The solution to the equation is then subtracted from the dynamic head that was changed to ensure the r^2 value is equivalent to 1. It is a way to check the accuracy of the curve.

I want to automate this system by using the area under the curve between each data point (dynamic head). When the data point is changed to make r^2 = 1 then the curve will slightly change. The next area calculated should use the new curve and make the data point equivalent to the respective curve. Iterating this a couple times throughout all data points should make an accurate curve.

Any suggestions?
 
You need to be able to describe the process in a series of steps in math.
Write out the algorithm ... use a math script program to implement it.
 

Similar threads

  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 4 ·
Replies
4
Views
8K
  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 20 ·
Replies
20
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K