Timedora

Evaluating Regression Models

A practical guide to measuring regression fit, diagnosing residual patterns, and distinguishing in-sample fit from predictive performance.

Residuals: Measuring and Diagnosing Fit

Residuals: measuring and diagnosing fit

A compares an observed response with the value predicted for that observation:

ei=yi−y^i.e_i = y_i - \hat{y}_i.

A positive means the observed response is above the fitted value; a negative one means it is below. The sum of squares (SSE) adds the squared residuals:

SSE=∑i=1nei2.SSE = \sum_{i=1}^{n} e_i^2.

Ordinary least squares chooses coefficients to minimize SSE in the training data. Squaring makes large errors count more heavily. For example, a twice as large contributes four times as much to SSE. SSE is a total, so it depends both on the response's units and on the number of observations; raw SSE is therefore not a scale-free measure for comparing arbitrary data sets.

For a linear regression with an intercept and kk predictors, the mean square ( MSE) is

MSEres=SSEn−k−1.MSE_{\text{res}} = \frac{SSE}{n-k-1}.

Its square root is the , an estimate of typical size in the response's units. Smaller variation means a closer fit to the training data, but it does not by itself show that the model is appropriate.

A -versus-fitted plot places fitted values on the horizontal axis and residuals on the vertical axis, with a reference line at zero. It can reveal structure that a single summary number hides. Scatter around zero without a clear pattern is broadly consistent with the model's form. Curvature may be a clue that a nonlinear relationship was missed; a spread that widens or narrows may be a clue of nonconstant error variance. These patterns are diagnostic clues, not automatic proof that assumptions hold. Use the plot alongside numerical measures rather than treating either as a complete verdict.

and Model Size

: fit relative to a baseline

For ordinary least-squares regression with an intercept, define total variation around the sample response mean as

SST=∑i=1n(yi−yˉ)2.SST = \sum_{i=1}^{n}(y_i-\bar{y})^2.

is

R2=1−SSESST.R^2 = 1 - \frac{SSE}{SST}.

It compares the model's squared variation with the variation around a simple baseline: predicting the same mean, yˉ\bar{y}, for every observation. The source example R2=0.72R^2=0.72 means that the fitted model accounts for 72% of the sample's response variation relative to that baseline. It does not mean that predictions are 72% accurate.

In a nested ordinary least-squares model, adding predictors cannot increase SSE: the expanded model can at least retain the earlier fit. Since SST is unchanged for the same response and observations, ordinary cannot decrease. It may therefore stay the same or rise even when an added predictor contributes little useful information.

accounts for model size:

Radj2=1−SSE/(n−k−1)SST/(n−1),R^2_{\text{adj}} = 1 - \frac{SSE/(n-k-1)}{SST/(n-1)},

where kk is the number of predictors and nn is the number of observations. The degrees-of-freedom adjustment penalizes model complexity, so can fall if a predictor's reduction in SSE does not offset the degrees of freedom it uses. It is useful for comparing models for the same response on the same observations, but it is not a direct measure of predictive accuracy on new data.

Predictive Performance and Its Limits

Evaluate predictions on held-out data

Training fit describes the data used to estimate the model. If the goal is to predict new observations, evaluate errors on a that was not used to fit or select the model. Cross-validation offers another approach: estimate performance across portions of the data held out from fitting in turn. These approaches assess predictive performance for the evaluation setting and data; they do not guarantee performance in a different setting.

Three common error measures emphasize different things:

  • MSE is the average squared prediction error. Squaring strongly penalizes large errors, and the result is in squared response units.

  • RMSE is the square root of MSE. It is in the response's units, making its error scale easier to relate to the quantity being predicted.

  • MAE is the average absolute prediction error. It is also in response units and is less affected by individual large errors than RMSE.

For the source's example of house prices predicted in dollars, an RMSE of $20,000 describes a typical error scale in dollars. It does not mean every prediction is within $20,000 of its observed price. Compare error measures on the same response scale and relevant evaluation data; lower held-out error generally indicates better predictive performance for that particular evaluation setting.

What fit measures cannot establish

In-sample SSE and describe fit to the data used for estimation; held-out errors estimate predictive performance on data similar to the evaluation data. Neither kind of measure proves that model assumptions are satisfied, that predictors cause the response, or that predictions will generalize to other populations or conditions. A high can coexist with systematic patterns or large prediction errors, especially when the response varies over a wide range. Check residuals and study design alongside numerical measures, and use held-out evaluation when prediction is the goal.

  • : The average squared prediction error.

  • : The square root of mean squared prediction error.

  • : The average absolute prediction error.