| Goal: |
|
Note that this section requires knowledge of calculus.
Assume we have data from a random variable and from a random variable such that is paired with , for . Writing these as pairs, we have
The goal is to find and in . For each point , for , we can calculate the error obtained by using such a formula. That is, for each point, we have
Note that could be positive or negative based on whether the value of is an overestimate or an underestimate. The line of best fit will be the line that incurs the least amount of error at each point. So we care more about the error being closer to zero than the sign. By squaring the error, we can then remedy this.5959Absolute value would also do this, but differentiability becomes an issue.
Our problem is now to find the slope and intercept, and , that minimize the sum of squared errors. That is,
We do this by letting
Calculus techniques state that we want to find critical values first, then check to see if they satisfy conditions for local extrema. First, we find any critical values. Finding the partials with respect to and , respectively, we have
and
Setting each of them equal to zero, we obtain
| (14.5) |
and
| (14.6) |
So, Eqs. (14.5) and (14.6) are the values of and that form a critical value . Let’s check if this point is a relative minimum. In order for this to happen, we check to see if the following conditions, regarding the second partial derivatives, hold.
;
.
Indeed, we have
Clearly,
In addition,
Hence, given by Eqs. (14.5) and (14.6), respectively, minimize the squared errors. These formulas are the intercept and slope as in Eqs. (14.3) and (14.2).6060We leave it to the reader to determine why the last line is positive.