Why a Leave-One-Out Residual Can Be Calculated Directly
An ordinary least-squares (OLS) residual measures the difference between an observed response and the fitted value from a model that used that observation in fitting. A leave-one-out residual asks a different question: how far is the observed response from the prediction made by a model fitted without that case? The second quantity is useful when examining how a case fares under a fit that did not use its response to estimate the coefficients.
Refitting the model once for every observation is possible, but it is unnecessary for OLS when the required rank condition holds. The hat matrix provides a direct identity: the leave-one-out residual is the ordinary residual divided by one minus the case’s hat value. This tutorial derives the identity and works through its use.
Model, Hat Values, and Deleted Residuals
Let \(\mathbf{y}\) be the \(n\)-vector of observed responses and let \(\mathbf{X}\) be the \(n \times p\) design matrix, including a column of ones if the model has an intercept. The \(i\)th row of \(\mathbf{X}\) is \(\mathbf{x}_i^\mathsf{T}\), where \(\mathbf{x}_i\) is a \(p\)-vector. The ordinary linear model notation is \(\mathbf{y}=\mathbf{X}\boldsymbol{\beta}+\boldsymbol{\varepsilon}\). For the algebra below, the essential conditions are that OLS is used and \(\mathbf{X}\) has full column rank. No normality or constant-variance assumption is needed for the identity itself.
The full-data OLS estimate is \(\hat{\boldsymbol{\beta}}=(\mathbf{X}^\mathsf{T}\mathbf{X})^{-1}\mathbf{X}^\mathsf{T}\mathbf{y}\). The fitted response vector is \(\hat{\mathbf{y}}=\mathbf{H}\mathbf{y}\), where \(\mathbf{H}=\mathbf{X}(\mathbf{X}^\mathsf{T}\mathbf{X})^{-1}\mathbf{X}^\mathsf{T}\) is the hat matrix. Its \(i\)th diagonal element, \(h_{ii}\), is the hat value for case \(i\). The ordinary residual is \(e_i=y_i-\hat{y}_i\).
For this deleted fit to have a unique OLS coefficient estimate, the design matrix with row \(i\) removed must still have full column rank. Under that condition, the leave-one-out identity is:
This is an exact algebraic result for the observed data. It is not an approximation, and it does not require a probability model for the errors.
Deriving the Identity
The derivation uses the OLS normal equations: the vector of OLS residuals is orthogonal to every column of the design matrix. Let \(\mathbf{X}_{-i}\) and \(\mathbf{y}_{-i}\) denote the design matrix and response vector after case \(i\) is removed. Let \(\mathbf{e}_{-i}\) be the vector of residuals for those cases under the full-data fit. Define the coefficient difference as \(\boldsymbol{\delta}=\hat{\boldsymbol{\beta}}-\hat{\boldsymbol{\beta}}_{(i)}\).
First, apply the full-data normal equations, \(\mathbf{X}^\mathsf{T}\mathbf{e}=\mathbf{0}\), and separate case \(i\)'s contribution. Then apply the deleted-fit normal equations. Together these give:
The second equation holds because the residuals for the remaining cases under the deleted fit are \(\mathbf{y}_{-i}-\mathbf{X}_{-i}\hat{\boldsymbol{\beta}}_{(i)}=\mathbf{e}_{-i}+\mathbf{X}_{-i}\boldsymbol{\delta}\). Substituting the first equation into the second yields:
The deleted residual for case \(i\) is its response minus its deleted-fit prediction. Since \(\hat{\boldsymbol{\beta}}=\hat{\boldsymbol{\beta}}_{(i)}+\boldsymbol{\delta}\), it follows that:
To connect this expression to \(h_{ii}\), set \(\mathbf{A}=\mathbf{X}_{-i}^\mathsf{T}\mathbf{X}_{-i}\) and \(q=\mathbf{x}_i^\mathsf{T}\mathbf{A}^{-1}\mathbf{x}_i\). Because deleting the row leaves full column rank, \(\mathbf{A}\) is invertible. Also, \(\mathbf{X}^\mathsf{T}\mathbf{X}=\mathbf{A}+\mathbf{x}_i\mathbf{x}_i^\mathsf{T}\). The rank-one inverse identity gives:
Multiplying on the left and right by \(\mathbf{x}_i^\mathsf{T}\) and \(\mathbf{x}_i\), respectively, shows that the full-data hat value is \(h_{ii}=q-q^2/(1+q)=q/(1+q)\). Therefore \(q=h_{ii}/(1-h_{ii})\), and \(1+q=1/(1-h_{ii})\). Substituting into the expression for \(d_i\) proves the identity. Since \(q\) is finite and nonnegative, \(h_{ii}=q/(1+q)<1\).
Using the Identity
The calculation requires only the full-data residual and hat value for the case of interest. The sign of \(d_i\) matches the sign of \(e_i\), because \(1-h_{ii}\) is positive when the rank condition holds. Its magnitude is at least as large as the ordinary residual’s magnitude, since \(0<1-h_{ii}\leq 1\). The difference can be small when the hat value is small and more substantial when the hat value is close to one.
Worked Example: A Deleted Residual in Simple Linear Regression
Suppose a hypothetical data set has four observations \((x,y)\): \((0,1)\), \((1,2)\), \((2,2)\), and \((3,5)\). Fit a simple linear regression with an intercept and calculate the leave-one-out residual for the observation with \(x=2\), without refitting.
The full-data means are \(\bar{x}=1.5\) and \(\bar{y}=2.5\). The slope is \(\sum (x_i-\bar{x})(y_i-\bar{y})/\sum (x_i-\bar{x})^2=6/5=1.2\), and the intercept is \(2.5-(1.2)(1.5)=0.7\). Thus, at \(x=2\), the fitted response is \(0.7+(1.2)(2)=3.1\), so the ordinary residual is \(e_i=2-3.1=-1.1\).
In simple linear regression with an intercept, \(h_{ii}=1/n+(x_i-\bar{x})^2/\sum (x_j-\bar{x})^2\). Here, \(n=4\), \(x_i=2\), and \(\sum (x_j-\bar{x})^2=5\), giving \(h_{ii}=1/4+(0.5)^2/5=0.30\). Deleting any one of these observations leaves at least two distinct \(x\)-values, so the deleted fit has full rank. The identity gives:
Thus the observation at \(x=2\) is about 1.571 response units below its prediction from the fit that excludes it. The calculation uses only the full-data residual and hat value.
Worked Example: An Intercept-Only Fit
Consider hypothetical response values of 8, 10, 12, 14, and 16 units, fitted with an intercept only. Find the leave-one-out residual for the observation with response 16.
An intercept-only OLS fit predicts the sample mean for every case. The full-data mean is \((8+10+12+14+16)/5=12\) units, so the ordinary residual for 16 is \(e_i=16-12=4\) units. With only an intercept in the design, every hat value is \(1/n\), so \(h_{ii}=1/5=0.20\).
Deleting one observation leaves four observations and a full-rank intercept-only design. Therefore:
As a check, the mean of the four remaining values is \((8+10+12+14)/4=11\) units, and the response 16 is \(16-11=5\) units above that deleted-fit prediction.
Worked Example: A Larger Adjustment at a High Hat Value
Suppose a hypothetical simple linear regression with an intercept uses five observations: \((0,3)\), \((1,3)\), \((2,8)\), \((3,13)\), and \((4,13)\). Calculate the leave-one-out residual for the observation at \(x=4\).
The responses equal \(2+3x\) plus deviations \(1,-2,0,2,-1\). These deviations sum to zero, and their products with the corresponding \(x\)-values sum to \(0-2+0+6-4=0\). They are therefore orthogonal to both the intercept and \(x\), so the full-data OLS line is \(\hat{y}=2+3x\). At \(x=4\), the fitted response is 14, giving the ordinary residual \(e_i=13-14=-1\) response unit.
The predictor mean is \(\bar{x}=2\), and \(\sum (x_j-\bar{x})^2=10\). The hat value at \(x=4\) is \(h_{ii}=1/5+(4-2)^2/10=0.60\). Deleting this endpoint leaves distinct predictor values and a full-rank intercept-and-slope design. Hence:
For verification, the remaining responses have means \(\bar{x}=1.5\) and \(\bar{y}=6.75\). Their slope is \(17.5/5=3.5\), and their intercept is \(6.75-(3.5)(1.5)=1.5\). The deleted-fit prediction at \(x=4\) is \(1.5+(3.5)(4)=15.5\), so the residual is \(13-15.5=-2.5\) units, as calculated from the identity.
Conditions and a Common Mistake
The rank condition matters. If deleting case \(i\) makes the remaining design matrix rank deficient, then the deleted OLS coefficients are not uniquely determined by the usual full-rank formula. In that situation, the derivation using \((\mathbf{X}_{-i}^\mathsf{T}\mathbf{X}_{-i})^{-1}\) does not apply; correspondingly, \(h_{ii}=1\), so the identity would have a zero denominator. Do not calculate \(e_i/(1-h_{ii})\) in that case and treat it as a finite deleted residual.
- Wrong reasoning: “The ordinary residual is the leave-one-out residual because both compare the observed response with a regression prediction.”
- Correction: The ordinary residual uses a fit that included the case. The leave-one-out residual uses a fit that excluded it, so the two are generally different. Under the stated rank condition, the exact conversion is \(d_i=e_i/(1-h_{ii})\).
- Another common error: Dividing by \(h_{ii}\) instead of \(1-h_{ii}\). The adjustment factor is the reciprocal of one minus the hat value.
The identity makes the relationship between residual size and leverage explicit: for the same ordinary residual, a larger hat value produces a larger absolute deleted residual. It is important to keep the quantities distinct, however. The identity calculates a leave-one-out residual; it does not by itself provide a standardized residual, a significance test, or a causal interpretation.
Check Your Understanding
Use the definitions and identity to answer these questions.
- In words, how does a leave-one-out residual differ from an ordinary OLS residual?
- A case has \(e_i=3\) response units and \(h_{ii}=0.25\). Calculate its leave-one-out residual and interpret the sign.
- Why does the identity require that deleting the case leave the design matrix full column rank?
- For an intercept-only model with \(n=8\), what is each case’s hat value? Explain briefly.
- Is a normality assumption required to establish the leave-one-out identity? State what kind of result the identity is.