How does excel calculate the best fit line?

In summary, the algorithm is to move the data points around to get the best fit curve, calculate the area under the curve between each data point, and use that to get an accurate curve.
  • #1
jsbxd9
6
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
  • #2
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?
 
  • #3
Thank you for your reply, that may work.
 
  • #5
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?
 
  • #6
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.
 

Related to How does excel calculate the best fit line?

1. How does Excel determine the best fit line?

Excel uses a statistical method called linear regression to determine the best fit line. This method calculates the line of best fit by minimizing the sum of the squares of the differences between the actual data points and the predicted values of the line.

2. What is the equation for the best fit line in Excel?

The equation for the best fit line in Excel is y = mx + b, where m is the slope of the line and b is the y-intercept. This equation is automatically calculated by Excel when you use the "Add Trendline" feature.

3. Can I customize the best fit line in Excel?

Yes, you can customize the best fit line in Excel by changing the type of trendline (linear, exponential, etc.), adding a label or equation to the line, or changing the line's color and style. You can also manually adjust the slope and intercept values of the line.

4. How accurate is the best fit line in Excel?

The accuracy of the best fit line in Excel depends on the quality and quantity of the data being analyzed. Generally, the more data points you have, the more accurate the line will be. However, it is important to note that the best fit line is an approximation and may not perfectly represent the data.

5. Can I use the best fit line in Excel to make predictions?

Yes, the best fit line in Excel can be used to make predictions by plugging in a value for x into the equation y = mx + b. This will give you the predicted y-value for that particular x-value. However, it is important to keep in mind that these predictions are based on the assumption that the relationship between x and y is linear.

Similar threads

  • Set Theory, Logic, Probability, Statistics
Replies
2
Views
672
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
4
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
6
Views
882
Replies
27
Views
3K
  • Calculus
Replies
5
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
20
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
3
Views
1K
  • STEM Educators and Teaching
Replies
5
Views
846
  • MATLAB, Maple, Mathematica, LaTeX
Replies
14
Views
2K
Back
Top