1

Is there some sort of equation/formula that can be used to find the exact values of $m$ and $b$ in $y=mx+b$ of any data points for the line of best fit? I want to be able to do this manually, not with graphing tools.

I know with $2$ points, $y_1-y_0\over x_1-x_0$ will satisfy, but with $3$+ points, there must be some definite method of interpolation, no?

  • Read about linear regression in wikipedia: https://en.wikipedia.org/wiki/Linear_regression . Excel can do this for you too. – Ethan Bolker Jan 13 '16 at 20:16
  • I was too vague. I want to do this manually, not with graphing tools. – Jacob Wheeler Jan 13 '16 at 20:19
  • You can do the same calculation Excel would do. It is not working off the graph, it is working off the data points. It does the least squares estimation in Wikipedia and you can, too. Most numerical analysis texts have a more detailed description. – Ross Millikan Jan 13 '16 at 20:22
  • Yes, but I do not know how Excel would do it. I need a nice, clean formula for this. It would be extremely appreciated. – Jacob Wheeler Jan 13 '16 at 20:25
  • 1
    Visit http://stattrek.com/regression/linear-regression.aspx and scroll down to "In the unlikely event that you find yourself on a desert island without a computer ..." – Ethan Bolker Jan 14 '16 at 00:34

1 Answers1

2

In order to calculate the line of best fit you have to minimize the quantity $$\sum_i^N [y_i-mx_i-q]^2$$ with respect to the two parameters $m$ and $q$. The $y_i$ and $x_i $ are yours data. The first equation is $$2\sum_i^N[y_i-mx_i-q](-x_i)=0$$ while the second $$2\sum_i^N[y_i-mx_i-q](-1)=0.$$ Try to isolate $m$ and $q$ and remember to use $\sum_i^Nq=qN$ (relevant quantities are $\sum_i^nx_iy_i $, $\sum_i^nx_i $ and $\sum_i^nx_i^2$). This is the general method used also for a general fit given by $y=f_{a,b,c,\dots}(x)$ where $a,b,c,\dots$ are your parameters. Minimizing the function with respect to these parameters and setting to zero each times give you a set of equations in number equals to the number of parameters.

yngabl
  • 1,024
  • Note that the two equations come from setting the partial derivatives equal to zero. – littleO Sep 06 '16 at 20:20
  • It is true with gradient in place of partial derivatives alone. This is behind the line ''minimizing the function''. – yngabl Sep 06 '16 at 20:22