Tutorials › Introduction to Statistics › Residual Standard Error as Typical Fit Error

Residuals and Transformations · Tutorial 280 of 996

Residual Standard Error as Typical Fit Error

Calculate residual standard error and interpret what it says about the typical size of a fitted line’s errors.

Intermediate 10 min read

What You'll Learn

  • Define residual standard error for a least-squares line with an intercept.
  • Calculate it from residuals, their squared sum, and the sample size.
  • Explain why its degrees of freedom are \(n-2\).
  • Interpret its size in the response variable’s units.
  • Distinguish residual standard error from mean absolute error and other standard errors.
  • Recognize when comparisons of residual standard errors are meaningful.

Why Summarize Residual Size?

A fitted regression line gives a predicted response for each predictor value, but observed responses will generally not fall exactly on that line. The residuals show the vertical differences between the observed and predicted responses. A useful summary of their overall size is the residual standard error: it describes the typical vertical distance between observed responses and the fitted line, in the response variable’s units.

A residual standard error is not an average of the absolute residuals, and it is not the standard error of a slope estimate. It is based on the sum of squared residuals, adjusted for the two coefficients estimated when fitting a simple linear regression line with an intercept. That adjustment is essential to the calculation and to its interpretation.

Definition and Model

Suppose the data consist of \(n\) paired observations \((x_i,y_i)\), and a least-squares regression line with an intercept has been fitted. For observation \(i\), the fitted response is \(\hat{y}_i\), and the residual is the observed response minus the fitted response.

Definition: The residual standard error for a simple least-squares regression line with an intercept is $$ s_e=\sqrt{\frac{\sum_{i=1}^{n}(y_i-\hat{y}_i)^2}{n-2}} =\sqrt{\frac{\sum_{i=1}^{n}e_i^2}{n-2}}, $$ where \(e_i=y_i-\hat{y}_i\). The sum \(\sum e_i^2\) is the residual sum of squares, and \(n-2\) is the residual degrees of freedom. The value \(s_e\) has the same units as the response \(y\).

The formula applies to ordinary least-squares regression of one response on one predictor when the line includes an intercept and the predictor values are not all identical. The fitted line estimates two coefficients: an intercept and a slope. If there are too few observations to leave residual degrees of freedom, the formula cannot provide this estimate.

For interpreting residual standard error as an estimate of the underlying error scale, a common model is \(Y_i=\beta_0+\beta_1x_i+\varepsilon_i\). It assumes that the mean response is linear in \(x_i\), that errors have mean zero, that errors are independent across observations, and that they have a common variance \(\sigma^2\). A normal error distribution is not required to calculate residual standard error or describe the fitted residuals. It is needed for some exact small-sample inferential procedures, which are not the purpose of this summary.

Worked Example: Calculating Residual Standard Error

Suppose a hypothetical data set relates hours of practice \(x\) to a performance score \(y\). The five observed pairs are \((1,11),(2,15),(3,16),(4,19),(5,19)\). Find the least-squares line and its residual standard error.

The means are \(\bar{x}=3\) hours and \(\bar{y}=16\) points. The slope is $$ b_1=\frac{\sum (x_i-\bar{x})(y_i-\bar{y})}{\sum (x_i-\bar{x})^2} =\frac{20}{10}=2\text{ points per hour}. $$ The intercept is \(b_0=\bar{y}-b_1\bar{x}=16-2(3)=10\) points. Thus the fitted line is \(\hat{y}=10+2x\).

For each observation, subtract the fitted score from the observed score. The fitted scores are \(12,14,16,18,20\), so the residuals are \(-1,1,0,1,-1\) points. Therefore, $$ \sum e_i^2=(-1)^2+1^2+0^2+1^2+(-1)^2=4\text{ points}^2. $$ There are \(n=5\) observations, so the residual degrees of freedom are \(5-2=3\). The residual standard error is $$ s_e=\sqrt{\frac{4}{3}}=1.155\text{ points}. $$

In this hypothetical data set, observed scores are typically about 1.155 points vertically from the fitted line. This describes a scale of deviations, not a promise that every score lies within 1.155 points of its prediction.

Why Divide by \(n-2\)?

The denominator accounts for estimating the intercept and slope from the same observations whose residuals are then measured. A brief justification shows why these two fitted coefficients lead to \(n-2\) residual degrees of freedom.

Under the model above, write the observations as a vector \(Y=X\beta+\varepsilon\), where \(X\) has one column of ones and one column of predictor values, and \(\beta\) contains the intercept and slope. When the predictor varies, those columns are linearly independent. Least-squares fitted values are \(HY\), where \(H=X(X^\mathsf{T}X)^{-1}X^\mathsf{T}\); hence the residual vector is \(e=(I-H)Y=(I-H)\varepsilon\). The last equality holds because \(HX=X\), so fitting removes the part \(X\beta\).

If the errors have mean zero and common variance \(\sigma^2\), with zero covariance between distinct errors, then $$ E\!\left[\sum e_i^2\right] =E\!\left[\varepsilon^\mathsf{T}(I-H)\varepsilon\right] =\sigma^2\operatorname{tr}(I-H) =\sigma^2(n-2). $$ Here \(H\) projects onto the two-dimensional space spanned by the intercept and predictor columns, so its trace is 2; the trace of \(I-H\) is therefore \(n-2\). This gives \(s_e^2=\sum e_i^2/(n-2)\) as an unbiased estimate of the error variance \(\sigma^2\). The square root \(s_e\) estimates the error standard deviation; it is not generally an exactly unbiased estimate of \(\sigma\).

Interpreting the Size in Context

The response units are part of the interpretation. An \(s_e\) of 2.4 seconds means a typical vertical discrepancy of about 2.4 seconds in the response, not 2.4 units of the predictor. If the response is measured in dollars, the residual standard error is in dollars; if it is measured in milligrams, the result is in milligrams.

“Typical” refers to the scale of the residuals, with larger residuals receiving extra weight because they are squared. Residual standard error is not the mean absolute residual and does not mean that every observation is within \(s_e\) of the line. Nor does it by itself say how unusual one particular residual is: that residual must be considered in relation to the data and model.

Worked Example: Interpreting Residual Standard Error in Score Units

A hypothetical instructor fits a least-squares line to predict quiz score, in points, from study time, in hours. There are six students, and the fitted line is \(\hat{y}=50+3x\). The observed scores at study times \(1,2,3,4,5,6\) hours are \(52,58,58,61,67,67\) points.

The fitted scores are \(53,56,59,62,65,68\) points. Subtracting fitted scores from observed scores gives residuals \(-1,2,-1,-1,2,-1\) points. Their squared sum is $$ \sum e_i^2=1+4+1+1+4+1=12\text{ points}^2. $$ With \(n=6\), the residual degrees of freedom are \(6-2=4\), and $$ s_e=\sqrt{\frac{12}{4}}=\sqrt{3}=1.732\text{ points}. $$

The fitted line’s residuals have a typical vertical size of about 1.732 quiz points in this data set. The interpretation concerns differences in score, not uncertainty measured in hours of study. The calculation alone does not establish that the model is appropriate; the linear pattern, independence, and spread conditions should be considered for the setting.

Comparing Residual Standard Errors Carefully

A smaller residual standard error indicates a smaller residual scale in the data used for fitting. Comparisons are clearest when candidate lines use the same response variable, response units, and observations. If the response is expressed in a different unit, the numerical residual standard error changes by the same unit conversion. If the response scales differ substantially, the raw values are not directly comparable as measures of relative fit.

Even when the same observations and units are used, a smaller residual standard error describes in-sample residuals. By itself, it does not establish that a model is appropriate, explain why the responses vary, or guarantee accurate predictions for new observations. Residual patterns and the context of the measurements still matter.

Worked Example: Comparing Two Residual Scales

Two candidate fitted lines are used on the same hypothetical 12 observations to predict reaction time, measured in milliseconds. Line A has residual sum of squares \(88\text{ ms}^2\), and Line B has residual sum of squares \(132\text{ ms}^2\). Calculate and compare their residual standard errors.

Both lines have \(12-2=10\) residual degrees of freedom. For Line A, $$ s_{e,A}=\sqrt{\frac{88}{10}}=\sqrt{8.8}=2.966\text{ ms}. $$ For Line B, $$ s_{e,B}=\sqrt{\frac{132}{10}}=\sqrt{13.2}=3.633\text{ ms}. $$

On these same observations and in the same units, Line A has the smaller residual scale: about 2.966 ms compared with 3.633 ms for Line B. This comparison does not show that Line A is a suitable model or will predict future reaction times better. Those conclusions require more than comparing the two residual standard errors.

Common Mistakes

  • Using \(n\) or \(n-1\) in the denominator. For a simple least-squares line with an intercept, use \(n-2\), because two coefficients were fitted.
  • Calling the result an average absolute error. The calculation squares residuals, averages their squared size using residual degrees of freedom, and takes a square root. It is not the arithmetic mean of \(|e_i|\).
  • Reporting the predictor’s units. Residuals measure vertical differences, so residual standard error uses the response variable’s units.
  • Claiming every point is within one residual standard error of the line. It is a typical scale, not a bound on individual residuals.
  • Confusing residual standard error with a coefficient’s standard error. Residual standard error summarizes the response-scale error in the fitted line; a coefficient’s standard error describes uncertainty in an estimated coefficient.
Key takeaway: For a simple least-squares regression line with an intercept, calculate residual standard error as \(\sqrt{\sum e_i^2/(n-2)}\). Interpret it as the typical vertical residual scale in response-variable units, while checking whether the regression model is appropriate for the data.

Check Your Understanding

Answer these questions using the definitions and calculations in this tutorial.

  1. A fitted line has residual sum of squares \(45\text{ kg}^2\) from \(n=7\) observations. What is its residual standard error, and what are its units?
  2. Why is the residual degrees of freedom \(n-2\) for a simple regression line with an intercept?
  3. In context, what does a residual standard error of 4.2 seconds mean? What does it not mean?
  4. Explain why residual standard error is not the mean absolute residual.
  5. Two lines are fitted to different response variables, one measured in centimeters and one in kilograms. Why is directly comparing their residual standard errors potentially misleading?