MIT 18.650 — Lecture 23
Linear Regression I
Definition. In regression, our goal is to develop a model that, given a feature vector or predictor , outputs an estimate for a response variable . The model's behavior is to be calibrated according to a training set .
Remark. Regression is like those puzzles that ask, “Given that , , and , what does equal?” In this case, the training set is , and we seek the response variable to the feature vector .
The scope of possible models is way too large; we need to make some assumptions about the relationship between and .
§ Linear Regression MLE
Linear regression is driven by the following assumption.
Assumption. The distribution of is .
The standard deviation is the same constant for all values of .
The mean function is linear; that is, for some .
Our regression model will thus also be a linear function . So the goal of linear regression will be to construct a good point estimate of the true parameter .

Remark. When we assume that the standard deviation is constant for all values of , we are using homoscedastic regression, as opposed to heteroscedastic regression.
We have a model —that is, a collection of PDFs , each on the space . We should pick the PDF that makes the training data look as likely to have occurred as possible.
In other words, given the data , we'll just make our point estimate the MLE. (Recall Lecture 9.)
Theorem. (MLE = LS) The MLE minimizes squared-error training loss; that is,
Proof: The log likelihood is:
To maximize the log likelihood, we minimize the bracketed expression on the RHS, which is the squared-error training loss.
Remark. Suppose we instead said the distribution of was —that is, suppose we performed heteroscedastic regression and did not assume the standard deviation was constant.
Then the MLE becomes the parameter that minimizes the sum of squares of z-scores; check for yourself. Note, however, that this MLE is not practical to compute, as the training data tells us nothing about z-scores because we do not know .
This is the reason why squared error is such a common loss function for regression: it's a natural consequence of seeking out the MLE assuming a Gaussian model.
§ Least Squares Loss
Definition. All training data is to be summarized in an column vector and an matrix .
Then the squared error rewrites as , where .
Theorem. (Least Squares Solution) The LS (least squares) solution (also the MLE) is .
Proof: The gradient of the squared error is:
Setting this equal to zero yields the promised result.
Remark. When setting to zero, we can't just set to zero, because isn't necessarily invertible.
Note, furthermore, that may not be well-defined, as may not be invertible. As the next section may make more clear, it is possible that there are multiple LS solutions, all equally valid according to the limited training data provided.
However, at least one candidate for always exists; the minimum loss has to be achieved by something.
And so is the -dimensional vector that holds the coefficients to our linear regression via .
§ Interpreting the LS Solution
We now do some linear algebra to interpret the vector .
Theorem. (LS = Projection Coefficients) The vector is the projection of onto the column space of .
Proof: It's clear that lives in the column space of ; it is true for any vector that:
It remains to verify that is perpendicular to this column space; algebraically, that . And, well, the proof of this lives within the very derivation of itself, right in the body of the “Least Squares Solution” proof.
An equivalent statement of the above is that the linear regression via is such that:
Indeed, must live in the column space of , and the closest point from to this column space is the projection.
And really, the above statement should have been predictable from the very beginning. The squared distance between and is exactly the squared-error training loss, so minimizing this loss is equivalent to making and as close as possible.
In that sense, the vector is just symbolic notation for the coefficients of the weighted sum of the columns of that lands as close to as possible.