In deriving the linear regression solution, we will be taking a closer look at how we “solve” the common linear regression, i.e., finding in .
I mention “common,” because there are actually several ways you can get an estimate for based on assumptions of your data and how you can correct for various anomalies. “Common” in this case specifically refers to ordinary least squares. For this specific case, I assume you already know the punch line, that is, . But, what we’re really interested in is how to get to that point.
The crux is that you’re trying to find a solution that minimizes the sum of the squared errors, i.e., . We can find the minimum by taking the derivative and setting it to zero, i.e., .
Observe that . As such, .
Working it out,
By setting the derivative to zero and solving for , we can find the that minimizes the sum of squared errors.
Without too much difficulty, we saw how we arrived at the linear regression solution of . The general path to that derivation is to recognize that you’re trying to minimize the sum of squared errors (), which can be done by finding the derivative of , setting it to zero, and then solving for .