How does excel calculate the best fit line?

  • Thread starter Thread starter jsbxd9
  • Start date Start date
  • Tags Tags
    Excel Fit Line
Click For Summary
Excel calculates the best fit line using least squares regression, which minimizes the sum of the squares of the differences between observed and predicted values. The user is attempting to fit an equation to pump curve data by adjusting data points to achieve an R^2 value of 1, indicating a perfect fit. Each adjustment alters the best fit equation, particularly with higher-order equations, which increases accuracy but also variability. To automate this process, the user seeks to calculate the area under the curve and iteratively adjust data points to maintain the desired R^2 value. Suggestions include detailing the algorithm and using a math scripting program for implementation.
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
8K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 14 ·
Replies
14
Views
3K
Replies
10
Views
1K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 20 ·
Replies
20
Views
3K