Tutorials › Exam SRM - Statistics for Risk Modeling › Standardized Residuals and Unequal Residual Variances

Exam SRM · Regression Diagnostics · Tutorial 87 of 926

Standardized Residuals and Unequal Residual Variances

See why OLS residuals have leverage-dependent variance and learn how raw, standardized, and studentized residuals differ as diagnostic comparisons.

Intermediate 9 min read

What You'll Learn

  • Derive the variance of an OLS residual from the hat matrix and the constant-variance error assumption
  • Interpret why high-leverage observations have smaller residual variance under the usual linear model
  • Distinguish raw residuals from residuals standardized using a known or estimated scale
  • Explain how studentized residuals use an observation-specific scale estimate
  • Identify when leverage-based standardization is undefined or inappropriate
  • Calculate residual comparisons and recognize common scaling errors

Why Residuals Need Scaling

A raw residual is the difference between an observed response and its fitted value. Its size is measured in the units of the response, which makes it easy to interpret, but not always easy to compare across observations. In ordinary least squares (OLS), the variability of a residual depends on the observation's leverage. Thus, even when the regression errors have a common variance, raw residuals do not all have the same variance.

Scaling a residual by an appropriate estimate of its standard deviation makes comparisons more meaningful. The choice of scale matters: using the common-error formula when error variances differ can produce a misleading comparison. This tutorial derives the leverage adjustment and distinguishes raw, standardized, and studentized residuals.

Model and assumptions: Let \(Y=X\beta+\varepsilon\), where \(Y\) is an \(n\)-vector, \(X\) is a fixed \(n\times p\) design matrix of full column rank, and \(\beta\) is a \(p\)-vector. For the leverage-based residual-variance formula, assume \(E[\varepsilon\mid X]=0\) and \(\operatorname{Var}(\varepsilon\mid X)=\sigma^2 I\). Normality is not needed for the variance formula. When using the usual residual standard error \(s=\sqrt{\operatorname{SSE}/(n-p)}\), also require \(n>p\).

The OLS fitted-value vector is \(\hat Y=HY\), where \(H=X(X^\mathsf{T}X)^{-1}X^\mathsf{T}\) is the hat matrix. The residual vector is \(e=Y-\hat Y\), and its \(i\)th component is \(e_i=y_i-\hat y_i\). The diagonal entry \(h_{ii}\) is the leverage of observation \(i\). For a full-column-rank design, \(0\leq h_{ii}\leq 1\).

Deriving the Residual Variance

Because the fitted values come from the same responses used to calculate residuals, the residual \(e_i\) is not simply the original error \(\varepsilon_i\). In vector form, \(e=(I-H)Y\). Since \(HX=X\), the model's mean component is removed:

$$ e=(I-H)(X\beta+\varepsilon)=(I-H)\varepsilon. $$

The hat matrix is symmetric and idempotent, so \(I-H\) is also symmetric and idempotent. Applying the covariance rule for a linear transformation gives the residual covariance matrix:

$$ \operatorname{Var}(e\mid X) =(I-H)\operatorname{Var}(\varepsilon\mid X)(I-H)^\mathsf{T} =\sigma^2(I-H)^2 =\sigma^2(I-H). $$

The \(i\)th diagonal element of this matrix is \(\sigma^2(1-h_{ii})\). This gives the result below.

Theorem: Under the fixed-design assumptions \(E[\varepsilon\mid X]=0\) and \(\operatorname{Var}(\varepsilon\mid X)=\sigma^2 I\), the OLS residual has mean zero and variance $$ E[e_i\mid X]=0,\qquad \operatorname{Var}(e_i\mid X)=\sigma^2(1-h_{ii}). $$ If, in addition, the errors are normally distributed, then for each observation with \(h_{ii}<1\), \(e_i/[\sigma\sqrt{1-h_{ii}}]\) has a standard normal marginal distribution. If \(h_{ii}=1\), the residual variance is zero and this standardized quotient is undefined.

The factor \(1-h_{ii}\) explains why residuals from high-leverage observations tend to vary less under the model: the fitted value at such a point is more strongly tied to its observed response. This does not mean that a high-leverage observation is necessarily well behaved or that its raw residual should be ignored. It means only that its residual's model-based variance differs.

Raw, Standardized, and Studentized Residuals

A raw residual is \(e_i\), in the response's original units. If \(\sigma\) were known, dividing \(e_i\) by its model-based standard deviation would give the standardized residual \(e_i/[\sigma\sqrt{1-h_{ii}}]\), defined only when \(h_{ii}<1\). Usually \(\sigma\) is unknown. When \(n>p\), it is commonly estimated using the residual standard error \(s=\sqrt{\operatorname{SSE}/(n-p)}\), where \(\operatorname{SSE}=\sum_{i=1}^n e_i^2\). The resulting full-model standardized residual is

$$ r_i=\frac{e_i}{s\sqrt{1-h_{ii}}}. $$

This form adjusts for the different residual variances implied by leverage and uses one estimate of the error scale for all observations. In common regression terminology, a studentized residual divides a residual by an estimated standard deviation rather than by a known one. One widely used version estimates the scale after omitting the observation being assessed; it is often called an externally studentized residual. Terminology can vary across references, so identify the scale used in any formula. The exact leave-one-out calculation and related variants are separate topics; the key distinction here is that the scale is estimated, and may be tailored to the observation.

The full-model quantity \(r_i\) is also called an internally studentized residual in some references. In those sources, “standardized” and “studentized” are not used consistently as separate labels. For an unambiguous calculation, state the numerator and denominator explicitly: raw residual, full-model scale with leverage adjustment, or an observation-specific scale. A leave-one-out scale requires enough observations and a full-rank design after the observation is omitted; for the usual residual degrees-of-freedom estimate, \(n>p+1\) is required.

QuantityDefinitionWhat is scaled?
Raw residual\(e_i=y_i-\hat y_i\)Nothing; it remains in response units
Standardized using known \(\sigma\)\(e_i/[\sigma\sqrt{1-h_{ii}}]\), for \(h_{ii}<1\)Model-based residual standard deviation
Full-model standardized residual\(e_i/[s\sqrt{1-h_{ii}}]\), for \(n>p\) and \(h_{ii}<1\)Estimated full-model residual standard deviation
Studentized residualResidual divided by an estimated standard deviation; a common version uses a scale estimated without observation \(i\)An estimated scale, potentially specific to the observation

Worked Example: Calculating Leverage-Adjusted Residuals

A hypothetical simple linear regression with an intercept uses \(x=(0,1,2,3)\) and observed responses \(y=(2,3,5,4)\). Suppose the model assumptions for the variance calculation hold, and take the true error standard deviation to be \(\sigma=2\). Calculate the fitted line, raw residuals, leverage values, residual standard deviations, and full-model standardized residuals.

Method. Fit the OLS line, use \(h_{ii}=1/n+(x_i-\bar x)^2/S_{xx}\), then apply the residual-variance formula. This calculation avoids comparing raw residuals as though their variances were identical.

First, \(\bar x=(0+1+2+3)/4=1.5\), \(\bar y=(2+3+5+4)/4=3.5\), and \(S_{xx}=(-1.5)^2+(-0.5)^2+(0.5)^2+(1.5)^2=5\). The cross-product sum is \((-1.5)(-1.5)+(-0.5)(-0.5)+(0.5)(1.5)+(1.5)(0.5)=4\). Thus the slope is \(4/5=0.8\), and the intercept is \(3.5-(0.8)(1.5)=2.3\). The fitted values are \((2.3,3.1,3.9,4.7)\), giving raw residuals \((-0.3,-0.1,1.1,-0.7)\).

The leverage at \(x=0\) and \(x=3\) is \(1/4+(1.5)^2/5=0.70\). At \(x=1\) and \(x=2\), it is \(1/4+(0.5)^2/5=0.30\). Therefore the residual standard deviations under the stated model are \(2\sqrt{0.30}=1.0954\) at the two high-leverage points and \(2\sqrt{0.70}=1.6733\) at the other two points.

To calculate the estimated-scale version, the residual sum of squares is \(0.09+0.01+1.21+0.49=1.80\). Here \(n=4\), \(p=2\), so \(n>p\) and \(s=\sqrt{1.80/(4-2)}=\sqrt{0.90}=0.9487\). The denominators \(s\sqrt{1-h_{ii}}\) are \(\sqrt{0.90(0.30)}=0.5196\) for observations 1 and 4, and \(\sqrt{0.90(0.70)}=0.7937\) for observations 2 and 3. Dividing each raw residual by its denominator gives, in order, \(-0.5774\), \(-0.1260\), \(1.3856\), and \(-1.3472\).

Check. The raw residuals sum to zero, and their cross-product with the centered predictor is \(0.45+0.05+0.55-1.05=0\), as required by OLS with an intercept. The calculated standardized residuals use their respective leverage adjustments, not a common denominator.

What Changes When Error Variances Are Unequal?

The leverage formula requires \(\operatorname{Var}(\varepsilon\mid X)=\sigma^2 I\): errors are uncorrelated and share one variance. If instead \(\operatorname{Var}(\varepsilon\mid X)=\Omega\), the general covariance calculation is

$$ \operatorname{Var}(e\mid X)=(I-H)\Omega(I-H). $$

Its \(i\)th diagonal element is not generally \(\sigma^2(1-h_{ii})\), so dividing by \(s\sqrt{1-h_{ii}}\) does not in general produce residuals with comparable variances. Standardization does not repair an incorrect variance model. The following example shows the difference even in an intercept-only regression.

Worked Example: Residual Variances With Unequal Error Variances

Suppose three independent responses are modeled by an intercept only, with error variances \(1,4,1\), respectively. Find the variance of each OLS residual and compare it with the equal-variance leverage formula.

Method. Use \(\Omega=\operatorname{diag}(1,4,1)\) in \((I-H)\Omega(I-H)\). The mistake to avoid is inserting one common \(\sigma^2\) when the three error variances are different.

For an intercept-only model with \(n=3\), every fitted value is the sample mean, so every entry of \(H\) is \(1/3\). Thus \(I-H\) has diagonal entries \(2/3\) and off-diagonal entries \(-1/3\). For the first residual, the variance is the sum of the squared row entries multiplied by the corresponding error variances: \((2/3)^2(1)+(-1/3)^2(4)+(-1/3)^2(1)=4/9+4/9+1/9=1\). For the second residual it is \((-1/3)^2(1)+(2/3)^2(4)+(-1/3)^2(1)=1/9+16/9+1/9=2\). By symmetry, the third residual variance is \(1\).

All three leverages equal \(1/3\), but the residual variances are \(1,2,1\). There is no single common \(\sigma^2\) that makes the formula \(\sigma^2(1-h_{ii})\) yield these three values. The residual variances must instead be calculated using the actual covariance structure \(\Omega\).

Check. The row weights for each residual sum to zero, consistent with residuals being deviations from the fitted sample mean. The variance calculation uses squared weights and the respective error variances; it does not average those variances as if they were equal.

Comparing Full-Model and Observation-Specific Scaling

When a residual is scaled using the full-model estimate \(s\), observation \(i\) contributes to the estimate of \(s\). A studentized version may instead use a scale estimate that excludes observation \(i\). Such a scale can differ from \(s\), so the resulting value can differ even though the residual and leverage adjustment are unchanged. This distinction is useful when comparing how unusual a residual looks relative to the fitted model's estimated error scale. It does not, by itself, establish that an observation is influential or that a model assumption is violated.

Worked Example: Comparing Two Estimated Scales

In a hypothetical regression with \(n=8\) observations and \(p=2\) fitted coefficients, observation \(i\) has raw residual \(e_i=0.90\) and leverage \(h_{ii}=0.36\). The full-model residual standard error is \(s=0.75\). Suppose a valid leave-one-out fit has residual standard error \(s_{(i)}=0.60\). Calculate the full-model standardized residual and the externally studentized residual.

Method. Use the same leverage adjustment \(\sqrt{1-h_{ii}}\) for both quantities, changing only the scale estimate. This avoids confusing a change in scale with a change in the residual.

The leverage factor is \(\sqrt{1-0.36}=\sqrt{0.64}=0.80\). The full-model denominator is \(0.75(0.80)=0.60\), so the full-model standardized residual is \(0.90/0.60=1.50\). The leave-one-out denominator is \(0.60(0.80)=0.48\), so the externally studentized residual is \(0.90/0.48=1.875\).

Check. The second value is larger because its estimated scale is smaller, while \(e_i\) and \(h_{ii}\) are unchanged. Since \(n=8>p+1=3\), there are more than \(p\) observations after deletion, permitting a residual-degree-of-freedom estimate if the reduced design remains full rank.

Common Mistakes and Practical Interpretation

A common error is to divide \(e_i\) by \(s\) alone and call the result a leverage-adjusted standardized residual. That calculation ignores the factor \(\sqrt{1-h_{ii}}\). For example, in the first worked example, the first observation would give \(-0.3/0.9487=-0.3162\) if divided by \(s\) alone, rather than the correct full-model standardized value \(-0.5774\). The correction is to use \(e_i/[s\sqrt{1-h_{ii}}]\), provided \(n>p\) and \(h_{ii}<1\).

Two boundary conditions also matter. If \(h_{ii}=1\), then the model-based residual variance is zero; the residual is zero under the stated model and division by its standard deviation is undefined. Do not report a standardized value for that observation using this formula. Separately, full column rank alone does not guarantee that \(s\) exists: the residual standard error requires \(n>p\), because its denominator is \(n-p\).

Finally, unequal variances or correlated errors invalidate the simple leverage-based residual variance. A large standardized residual can flag a response that is unusual relative to a specified scale, but interpretation depends on whether that scale is appropriate. Residual scaling is one diagnostic aid, not a substitute for checking the model assumptions.

Key takeaway: Under constant, uncorrelated error variance, \(\operatorname{Var}(e_i\mid X)=\sigma^2(1-h_{ii})\). Raw residuals retain response units; standardized residuals divide by a leverage-adjusted scale; studentized residuals use an estimated scale, often one tailored to the observation. Check the assumptions and the conditions for each denominator before comparing values.

Check Your Understanding

Work each problem by naming the scale and assumptions being used. Answers are included for checking.

  1. In a full-rank regression, an observation has \(h_{ii}=0.25\) and the errors satisfy the constant-variance model with \(\sigma=3\). Find the model-based standard deviation of its raw residual. (Answer: \(3\sqrt{0.75}=2.5981\), approximately.)
  2. A regression has \(n=12\), \(p=4\), \(\operatorname{SSE}=32\), \(e_i=-2\), and \(h_{ii}=0.36\). Calculate \(s\) and the full-model standardized residual. (Answer: \(s=\sqrt{32/8}=2\), and \(-2/[2\sqrt{0.64}]=-1.2500\).)
  3. For an observation with \(e_i=1.2\), \(h_{ii}=0.19\), and \(s=0.80\), calculate the full-model standardized residual. (Answer: \(1.2/[0.80\sqrt{0.81}]=1.6667\).)
  4. For an intercept-only model with two independent errors having variances \(1\) and \(9\), calculate the variance of the first residual. (Answer: With \(I-H\) having row \((1/2,-1/2)\), the variance is \((1/2)^2(1)+(1/2)^2(9)=2.5000\).)
  5. A regression has \(n=9\), \(p=3\), \(e_i=-1.5\), \(h_{ii}=0.75\), full-model \(s=1.00\), and a valid leave-one-out scale \(s_{(i)}=0.75\). Find both the full-model standardized residual and the externally studentized residual. (Answer: The leverage factor is \(0.5\); the values are \(-1.5/(1.00)(0.5)=-3.0000\) and \(-1.5/(0.75)(0.5)=-4.0000\).)
Clinical Biostats