I have question about a specific step describing how to do linear regression with the least squares method. In the textbook, it says that you need to find $\triangle x$ and $\triangle y$ (which are $x - \bar{x}$ and $y - \bar{y}$) then you multiply each one together, and find $\Sigma \triangle x \triangle y$. You then go on to divide this by $ \Sigma (\triangle x)^{2} $
$\frac {\Sigma \triangle x \triangle y}{\Sigma (\triangle x)^{2}} $
Which is the slope of the linear regression line
I'm guessing multiplying $\triangle x$ and $\triangle y$ means you're finding the area of the square the actual coordinates make
but then $(\triangle x)^{2}$ means you're finding the supposed, or standard size of what the squares should be? (based on the x values you have)
then the slope is the ratio between them, giving you the line of best fit
Am I understanding this correctly?
Derivation
We wish to find the slope $m$ from the following linear equations. Keep in mind that each equation has its error $\epsilon$
$$ \Delta y_{i} = m\Delta x_{i}+\epsilon_{i} $$
When we do least square regression, we select $m$ that minimize the sum of squared errors:
$$ \begin{aligned} \sum_{i}\epsilon_{i}^{2}&=\sum_{i}\left(\Delta y_{i}-m\Delta x_{i}\right)^{2} \\ &= m^{2}\sum_{i}\left(\Delta x_{i}\right)^{2}-2m\sum_{i}\Delta x_{i}\Delta y_{i}+\sum_{i}\left(\Delta y_{i}\right)^{2} \end{aligned} $$
Notice that the RHS is a quadratic polynomial in $m$ with positive first coefficient. The $m$ that minimize the quadratic equation is given by:
$$ m=\frac{\sum_{i}\Delta x_{i}\Delta y_{i}}{\sum_{i}\left(\Delta x_{i}\right)^{2}} $$
Some Intuition
Multiply the initial linear equation by $\Delta x_{i}$ and sum for all values of $i$:
$$ \sum_{i}\Delta x_{i}\Delta y_{i}=m\sum_{i}\left(\Delta x_{i}\right)^{2}+\sum_{i}\Delta x_{i}\epsilon_{i} $$
When we substitute the $m$ values we obtain
$$ 0=\sum_{i}\Delta x_{i}\epsilon_{i} $$
One interpretation is: the least square regression choose the slope such that the errors $\epsilon$ are uncorrelated with the regressors $\Delta x$.