Take three coordinates $(1,1)$, $(3,2)$ and $(4,3)$.
My calculator returns the linear regression line: $$y=0.6429x+0.2857$$ of the form $$y = ax +b$$ correct to four significant figures for constants $a$ and $b$.
How can I do this calculation by hand?
I've heard of least square fitting but I haven't learned how to do that and I'm not sure if it is the method or not.
Can someone point me in the right direction?
Also, please don't suggest I plot the points and draw a best fit line by eye and then get my line from the graph. I want to know what method calculators use to calculate the constants $a$ and $b$.
Best Answer
Linear regression is a very general technique, which in this case reduces to
$$\hat{a}=\dfrac{\displaystyle\sum_{i=1}^n(y_i-\bar{y})(x_i-\bar{x})}{\displaystyle\sum_{i=1}^n(x_i-\bar{x})^2},$$
$$\text{and }\hat{b}=\bar{y}-\hat{a}\bar{x},$$
where $\bar{y}=\dfrac{1}{n}\displaystyle\sum_{i=1}^ny_i,$ and $\bar{x}=\dfrac{1}{n}\displaystyle\sum_{i=1}^nx_i.$
In your case $y_i$'s are $1,2,3$ and $x_i$'s are $1,3,4$ for $i=1,2,3$ respectively.