Why Residual Size Needs Context
A residual is the difference between an observed response and the response predicted by a fitted regression model. Its sign and size can reveal that an observation is poorly described by the model. But a raw residual, measured in the response's units, does not by itself say how unusual that discrepancy is. Residual variability depends in part on where an observation sits in the predictor space, so comparisons based only on raw residual size can be misleading.
This tutorial compares raw residuals with two scaled versions: standardized residuals and studentized residuals. These quantities help identify responses that warrant investigation. They do not, on their own, establish that a case is influential, that the model is wrong, or that an observation should be removed.
Model and Residual Definitions
Let \(n\) observations be fitted by an ordinary least-squares linear regression with \(p\) estimated coefficients, including an intercept when the model has one. Write the response vector as \(y\), the design matrix as \(X\), and assume \(X\) has full column rank. The fitted values are \(\hat{y}=Hy\), where \(H=X(X^\mathsf{T}X)^{-1}X^\mathsf{T}\) is the hat matrix. For observation \(i\), write \(e_i=y_i-\hat{y}_i\) for its residual and \(h_{ii}\) for the \(i\)th diagonal element of \(H\), called its leverage.
For the scaled-residual results below, use the regression model \(y=X\beta+\varepsilon\), with fixed \(X\), independent errors having mean zero and common variance \(\sigma^2\). For exact \(t\)-distribution results, also assume the errors are normally distributed. The residual mean square is \(s^2=\mathrm{SSE}/(n-p)\), where \(\mathrm{SSE}=\sum_{j=1}^n e_j^2\), and \(s\) estimates the error standard deviation \(\sigma\).
The diagonal leverage values satisfy \(0\le h_{ii}\le 1\). A leverage value of one is possible even when \(X\) has full column rank and the model includes an intercept. Whenever a formula below divides by \(1-h_{ii}\), it therefore requires the additional condition \(h_{ii}<1\) for the observation being assessed. In a full-rank design, this is equivalent to deleting that observation without losing full column rank.
Worked Example: Finding Raw Residuals
Suppose, hypothetically, that a model predicts weekly energy use for five buildings from a centered outdoor-temperature measure \(x\). The recorded responses \(y\), in hundreds of kilowatt-hours, are shown below. The fitted model is \(\hat{y}=10+2x\).
| Building | \(x\) | Observed \(y\) | Fitted \(\hat{y}\) | Residual \(e=y-\hat{y}\) |
|---|---|---|---|---|
| A | -2 | 8 | 6 | 2 |
| B | -1 | 5 | 8 | -3 |
| C | 0 | 12 | 10 | 2 |
| D | 1 | 9 | 12 | -3 |
| E | 2 | 16 | 14 | 2 |
For building B, for example, \(e_B=5-8=-3\). Its observed weekly use is 3 hundred kilowatt-hours below the model's fitted value. Building D has the same residual, while A, C, and E each have a residual of 2 hundred kilowatt-hours. These are discrepancies in the response's units; comparing their absolute values alone does not account for how uncertain each fitted response is.
Why Residuals Have Different Variability
Under the stated model, \(\hat{y}=Hy\) and the residual vector is \(e=(I-H)y=(I-H)\varepsilon\), because \((I-H)X\beta=0\). The hat matrix is symmetric and idempotent, so \(I-H\) is also symmetric and idempotent. The residual vector therefore has mean zero and covariance matrix \(\sigma^2(I-H)\). In particular, the variance of an individual residual depends on its leverage:
This result explains why raw residuals do not all have the same natural scale. A high-leverage observation has a smaller residual variance under the model, while a lower-leverage observation has a larger one. The statement concerns residual variability under the assumed model; it does not mean that high leverage makes an observation harmless.
Dividing by the estimated residual standard deviation for that observation gives the internally standardized residual:
Many introductory sources call this a standardized residual; it is also called an internally studentized residual. Its denominator uses \(s\) computed from the full fit, including observation \(i\). The adjustment by \(\sqrt{1-h_{ii}}\) accounts for the residual's model-based variance, while \(s\) estimates the unknown error scale.
Worked Example: Standardizing a Residual
Use the hypothetical five-building data above. The predictor values are \(-2,-1,0,1,2\), and the fitted model has an intercept and a slope. The sum of squared residuals is
There are \(n=5\) observations and \(p=2\) fitted coefficients, so \(s^2=30/(5-2)=10\), or \(s=\sqrt{10}\approx3.162\) hundred kilowatt-hours. For a simple linear regression with an intercept, \(h_{ii}=1/n+(x_i-\bar{x})^2/\sum_j(x_j-\bar{x})^2\). Here \(\bar{x}=0\) and \(\sum_j(x_j-\bar{x})^2=10\), so building B, with \(x=-1\), has \(h_{BB}=1/5+1/10=0.3\).
Its internally standardized residual is
The negative sign retains the direction of the discrepancy. The value \(-1.134\) expresses building B's residual in estimated residual-standard-deviation units, adjusted for its leverage. It is not a statement that the building is definitely an outlier.
Studentizing by Leaving the Case Out
The internally standardized residual uses a scale estimate that includes the case being assessed. An observation with a large residual contributes to \(\mathrm{SSE}\), and can increase \(s\), making its own internally standardized residual smaller. An externally studentized residual instead estimates the error scale after deleting observation \(i\) and refitting the model.
Provided \(h_{ii}<1\), deleting observation \(i\) leaves the design matrix full rank, and the deleted residual sum of squares can be written as \(\mathrm{SSE}_{(i)}=\mathrm{SSE}-e_i^2/(1-h_{ii})\). Define \(s_{(i)}^2=\mathrm{SSE}_{(i)}/(n-p-1)\). When \(n-p-1>0\), the externally studentized residual is
The deleted fit estimates the response for observation \(i\) without using its observed response. Its prediction error is \(e_i/(1-h_{ii})\); the corresponding prediction standard error is \(s_{(i)}/\sqrt{1-h_{ii}}\). Their ratio is the same \(t_i\) shown above. Under the fixed-design normal-error model, this statistic has a \(t\) distribution with \(n-p-1\) degrees of freedom when the required deletion and scale conditions hold. Without normal errors, it can still be used as a diagnostic scale comparison, but that exact reference distribution is not justified.
Worked Example: Calculating an Externally Studentized Residual
For building B in the same hypothetical example, \(e_B=-3\), \(h_{BB}=0.3\), and \(\mathrm{SSE}=30\). The design has full rank after deleting B, and \(n-p-1=2>0\). First calculate the deleted sum of squares:
Thus \(s_{(B)}^2=17.143/2\approx8.571\), and \(s_{(B)}\approx2.928\) hundred kilowatt-hours. The externally studentized residual is
This is the discrepancy for building B scaled using an error estimate that does not include B. Under the normal-error assumptions, its single-case reference distribution is \(t\) with 2 degrees of freedom. That small number of degrees of freedom also reminds us that an apparently large value should be interpreted with the available sample size and the purpose of the diagnostic in mind.
What Residual Size Can and Cannot Establish
A large absolute standardized or studentized residual is evidence that the response is unusual relative to the fitted model. As a rough screening convention, values with absolute size above 2 may merit a closer look, and values above 3 are often treated as stronger flags. These are not universal decision boundaries. The model, sample size, error assumptions, and consequences of a false flag all matter. When many observations are screened, some may look unusual by chance, so a threshold should not be treated as a stand-alone formal test.
The word evidence matters. A flagged response might reflect a recording or measurement error, a legitimate but unusual case, a predictor or group omitted from the model, or a pattern showing that the model does not describe the data adequately. The residual alone cannot tell which explanation applies. Check the record and the data-collection context, and assess whether the model is appropriate before drawing conclusions.
Most importantly, an unusual response is not automatically an influential observation. A residual describes the vertical discrepancy between an observed response and a fitted response. Influence concerns how much the fitted model changes when a case is removed. A case can have a large residual without substantially changing the fitted coefficients; a high-leverage case can affect a fit even with a small residual. Residual size alone does not settle that question.
Worked Example: A Leverage-One Case
Consider a hypothetical regression with \(n=3\) observations, an intercept, and predictor values \(x=(0,1,1)\). The two columns of the design matrix are the intercept column \((1,1,1)^\mathsf{T}\) and the predictor column \((0,1,1)^\mathsf{T}\). They are linearly independent, so the full design matrix has rank \(p=2\).
The vector \((1,0,0)^\mathsf{T}\) is itself the first design-matrix column minus the predictor column. It is therefore in the column space of \(X\). Projection onto that space leaves this vector unchanged, which means the first diagonal element of the projection matrix is \(h_{11}=1\). This demonstrates that full rank and an intercept do not guarantee \(h_{ii}<1\).
In this example, deleting observation 1 leaves two identical predictor values and cannot support estimation of both an intercept and slope: the remaining design matrix has rank 1 rather than 2. The formula \(e_1/[s\sqrt{1-h_{11}}]\) has a zero denominator, and the deleted-fit studentized residual is not defined. The correct response is not to force a scaled-residual calculation; this case does not meet the conditions required for that calculation.
Common Mistake
Wrong reasoning: “This observation has the largest raw residual, so it must be the most unusual case and must be driving the regression.” The first part ignores that residual variability depends on leverage; the second confuses an unusual response with influence.
Correction: Start with the raw residual to see the discrepancy in context and response units. Then use an internally standardized or externally studentized residual, when its conditions are satisfied, to compare the discrepancy with an estimated residual scale. Treat a large scaled value as a reason to investigate, not as proof of error or influence. Assessing how the fit changes when cases are deleted is a separate question.
Check Your Understanding
Try these questions using the definitions and conditions above.
- If an observed response is below its fitted value, what is the sign of its raw residual, and what units does that residual have?
- Why can two raw residuals of the same size represent different levels of unusualness?
- What is the difference between the error-scale estimate used in an internally standardized residual and the one used in an externally studentized residual?
- Which additional design condition is needed for a residual formula that divides by \(1-h_{ii}\), and what does failure of that condition imply for deleting the case?
- Why does a large studentized residual not, by itself, establish that an observation is influential?