| model | Train.MSE | Test.MSE |
|---|---|---|
| Linear | 0.677 | 1.281 |
| Quintic | 0.086 | 0.326 |
| Poly | 0.071 | 1.822 |

Linear Regression
Grayson White
Stat 243
Week 2 | Fall 2026
Today:
Next Week:
| model | Train.MSE | Test.MSE |
|---|---|---|
| Linear | 0.677 | 1.281 |
| Quintic | 0.086 | 0.326 |
| Poly | 0.071 | 1.822 |

Suppose we consider a variety of model shapes to predict \(Y\), with each model of increasing flexibility / complexity.
The U-curve for test MSE is a result of competition between two sources of error in a model
Expected test MSE can be decomposed as the sum of 3 quantities: \[ \mathrm{E} \left[ ( y_0 - \hat{f}(x_0))^2 \right] = \left[\mathrm{Bias}(\hat{f}(x_0))\right]^2 + \mathrm{Var}(\hat{f}(x_0)) + \mathrm{Var}(\epsilon) \]
Here \(\mathrm{E} \left[ ( y_0 - \hat{f}(x_0))^2 \right]\) denotes expected test MSE at \(x_0\), if many models for \(f\) were built using a variety of random training data sets containing \(x_0\)
Total expected test MSE is obtained by averaging across all possible \(x_0\) in the test set.
A proof is given in Section 7.3 of The Elements of Statistical Learning.
To minimize \(\mathrm{MSE}\), we need to simultaneously minimize both variance and bias.

Q: What happens as we pick more complex models?
As complexity increases, we tend to “overfit” model to training data.
Bias decreases and variance increases
We want a sufficiently complex model that doesn’t overfit training data.
If \(Y\) depends on only 1 predictor \(X\), then the linear model reduces to
\[ y = f(x) = \beta_0 + \beta_1 x + \epsilon \]
In reality, the relationship \(f\) between \(Y\) and \(x_1, \dots, x_p\) may not be linear
But many functions can be well-approximated by linear ones (especially when inputs are restricted to a small range)
But even if \(f\) is truly linear, we still have problems: We do not know the parameters of the linear model.
\[ \hat{y} = \hat{f}(x_1,~\cdots,~x_p) = \hat{\beta}_0 + \hat{\beta}_1 x_1 + \dots + \hat{\beta}_px_p \]
Consider the relationship between a state’s high school grad rate \(y\) and its poverty rate \(x\).

Consider the relationship between a state’s high school grad rate \(y\) and its poverty rate \(x\).


\[ \hat{y} = 90 - 0.4 \cdot 14 = 84.4 \]
\[\begin{align*} \hat{y} &= \hat{\beta}_0 + \hat{\beta}_1 \times x_{povertyrate} \\ &= 90 - 0.4 \times x_{povertyrate} \end{align*}\]
We need to be precise and careful when interpreting estimated coefficients!
Intercept: We expect/predict \(y\) to be \(\hat{\beta}_0\) on average when \(x = 0\).
Slope: For a one-unit increase in \(x\), we expect/predict \(y\) to change by \(\hat{\beta}_1\) units on average.
These interpretations are non-specific to the context of our model, but when we are interpreting coefficients, we always need to interpret the coefficients in context
\[\begin{align*} \hat{y} &= \hat{\beta}_0 + \hat{\beta}_1 \times x_{povertyrate} \\ &= 90 - 0.4 \times x_{povertyrate} \end{align*}\]
Intercept: We expect/predict a state’s graduation rate to be 90% on average when their poverty rate is 0.
Slope: For a one-unit increase in poverty rate, we expect/predict the graduation rate of a state to decrease by 0.4% on average.

Residuals are the leftover variation in the data after accounting for model fit.
Each observation \((X_i, Y_i)\) has its own residual \(e_i\), which is the difference between the observed (\(Y_i\)) and predicted (\(\hat{Y}_i\)) value: \[e_i = Y_i - \hat{Y}_i\]

To visualize the degree of accuracy of a linear model, we use residual plots:

To visualize the degree of accuracy of a linear model, we use residual plots:

In many cases, it is more convenient to look at the residual plot of residuals vs fitted values (instead of vs \(X\))

Since
\[ \hat{\beta}_1 = \frac{\sum_{i=1}^n (x_i - \bar{x})(y_i - \bar{y})}{\sum_{i=1}^n(x_i - \bar{x})^2} \qquad \hat{\beta}_0 = \bar{y} - \hat{\beta}_1 \bar{x} \]
minimizes the RSS, the least squares regression line has the lowest training MSE among all linear models.
The following (closely related) measures are used to assess accuracy of a linear model:
Residual Standard Error (RSE or \(\hat \sigma\)) \[ \hat \sigma = \textrm{RSE} = \sqrt{\frac{1}{n-p - 1}\textrm{RSS}} = \sqrt{\frac{n}{n-p-1}} \textrm{RMSE} \]
RSE is an estimate of the standard deviation \(\sigma\) of model error \(\epsilon\)
RSE measures the typical size of model errors
Note that \(p = 1\) for simple linear regression.
The following (closely related) measures are used to assess accuracy of a linear model:
The coefficient of determination \(R^2\) \[ R^2 = 1- \frac{\sum_{i=1}^n(y_i - \hat y_i)^2}{\sum_{i=1}^n(y_i - \bar y)^2} = 1 - \frac{\textrm{RSS}}{\textrm{TSS}} \]
\(R^2\) is the proportion of variation in the response explained by the model.
\[\begin{align*} \mbox{adj} R^2 &= 1- \frac{\sum_{i=1}^2 (y - \hat{y})^2}{\sum_{i=1}^n (y - \bar{y})^2} \left(\frac{n - 1}{n - p - 1} \right) = 1 - \frac{\textrm{RSS}}{\textrm{TSS}} \left(\frac{n - 1}{n - p - 1} \right) \end{align*}\]
where \(p\) is the number of explanatory variables in the model.
The following (closely related) measures are used to assess accuracy of a linear model:
\[ R^2 = 1- \frac{\sum_{i=1}^n(y_i - \hat y_i)^2}{\sum_{i=1}^n(y_i - \bar y)^2} = 1 - \frac{\textrm{RSS}}{\textrm{TSS}} \]
\[\begin{align*} \mbox{adj} R^2 &= 1- \frac{\sum_{i=1}^2 (y - \hat{y})^2}{\sum_{i=1}^n (y - \bar{y})^2} \left(\frac{n - 1}{n - p - 1} \right) = 1 - \frac{\textrm{RSS}}{\textrm{TSS}} \left(\frac{n - 1}{n - p - 1} \right) \end{align*}\]
where \(p\) is the number of explanatory variables in the model.