Algorithm Search⌘K

Definitioncore

Leverage

Also called hat value, leverage score.

The i-th diagonal entry of the hat matrix, which measures how far x_i lies from the other predictors and how much y_i pulls its own fitted value.

The leverage of observation ii in a linear regression is the ii-th diagonal entry hiih_{ii} of the hat matrix. It depends only on the predictors, not on the response. It measures two things at once: how far the predictor row xix_i lies from the bulk of the rows, and how strongly yiy_i pulls its own fitted value, since hii=∂y^i/∂yih_{ii} = \partial\hat y_i/\partial y_i. A point with high leverage can move the fitted line a lot, but whether it does depends on its response; that combined effect is influence, measured by Cook's distance. In numerical linear algebra the same numbers are called leverage scores.

Definition

Let XX be an n×pn \times p design matrix of rank pp, with rows x1⊤,…,xn⊤x_1^\top, \dots, x_n^\top (the intercept, if any, is one of the pp columns). The leverage (or hat value) of observation ii is

hii=xi⊤(X⊤X)−1xi=∥qi∥2,h_{ii} = x_i^\top(X^\top X)^{-1}x_i = \lVert q_i\rVert^2,

where qi⊤q_i^\top is row ii of Q1Q_1 in a thin QR factorization X=Q1RX = Q_1R. The second form is how it is computed: O(np2)O(np^2) for the factorization and O(np)O(np) for all nn leverages.

Basic facts. From H=H⊤=H2H = H^\top = H^2 and tr⁡H=p\operatorname{tr} H = p:

  1. 0≤hii≤10 \le h_{ii} \le 1, because hii=∑jhij2≥hii2h_{ii} = \sum_j h_{ij}^2 \ge h_{ii}^2.
  2. ∑ihii=p\sum_i h_{ii} = p, so the average leverage is p/np/n.
  3. With an intercept, hii≥1/nh_{ii} \ge 1/n.
  4. hii=1h_{ii} = 1 if and only if hij=0h_{ij} = 0 for every j≠ij \ne i, which happens if and only if y^i=yi\hat y_i = y_i for every response vector. Then ei=0e_i = 0 always and Var⁡(ei)=σ2(1−hii)=0\operatorname{Var}(e_i) = \sigma^2(1 - h_{ii}) = 0; the model spends one parameter on fitting that point exactly. An indicator column for one observation does this, and so does a group of size 1 in a one-way layout.
  5. Var⁡(y^i)=σ2hii\operatorname{Var}(\hat y_i) = \sigma^2 h_{ii} and Var⁡(ei)=σ2(1−hii)\operatorname{Var}(e_i) = \sigma^2(1 - h_{ii}) when the errors are uncorrelated with variance σ2\sigma^2.

Distance form. With an intercept, write x~i\tilde x_i for row ii without its leading 1, xˉ\bar x for the mean of these rows, and SS for their sample covariance matrix (divisor n−1n - 1). Then

hii=1n+(x~i−xˉ)⊤S−1(x~i−xˉ)n−1=1n+MDi2n−1,h_{ii} = \frac1n + \frac{(\tilde x_i - \bar x)^\top S^{-1}(\tilde x_i - \bar x)}{n - 1} = \frac1n + \frac{\mathrm{MD}_i^2}{n - 1},

with MDi\mathrm{MD}_i the Mahalanobis distance of x~i\tilde x_i from xˉ\bar x. So leverage is a distance from the center of the predictor cloud, measured in the units of its own spread. The proof: centering the predictors does not change HH, and the centered design (1,X~c)(\mathbf 1, \tilde X_c) has orthogonal blocks, so H=1n11⊤+X~c(X~c⊤X~c)−1X~c⊤H = \frac1n\mathbf 1\mathbf 1^\top + \tilde X_c(\tilde X_c^\top\tilde X_c)^{-1}\tilde X_c^\top with X~c⊤X~c=(n−1)S\tilde X_c^\top\tilde X_c = (n - 1)S.

High leverage. A common rule flags hii>2p/nh_{ii} > 2p/n, twice the average (Hoaglin and Welsch 1978; Belsley, Kuh and Welsch use the same cutoff). Some authors use 3p/n3p/n for small nn. These are conventions, not tests. For a design whose rows (without the intercept) are iid multivariate normal, nn−1(hii−1n)\frac{n}{n-1}\big(h_{ii} - \frac1n\big) has the Beta(p−12,n−p2)\big(\frac{p-1}{2}, \frac{n-p}{2}\big) law, which shows how often the rule fires by chance, but designs are rarely random normal.

Examples and non-examples

Simple regression. For X=(1,x)X = (\mathbf 1, x), hii=1n+(xi−xˉ)2Sxxh_{ii} = \frac1n + \frac{(x_i - \bar x)^2}{S_{xx}} with Sxx=∑k(xk−xˉ)2S_{xx} = \sum_k (x_k - \bar x)^2. Leverage grows with the squared distance of xix_i from xˉ\bar x and is smallest, 1/n1/n, at xi=xˉx_i = \bar x.

A far point. For x=(1,2,3,4,5,10)x = (1, 2, 3, 4, 5, 10), n=6n = 6 and p=2p = 2, the leverages are 0.364,0.259,0.193,0.167,0.180,0.8360.364, 0.259, 0.193, 0.167, 0.180, 0.836, with sum 2. Only the last exceeds 2p/n=0.6672p/n = 0.667. Check by the distance form: xˉ=25/6\bar x = 25/6, the sample variance is 305/30305/30, so MD62=(35/6)2/(305/30)=3.347\mathrm{MD}_6^2 = (35/6)^2/(305/30) = 3.347 and h66=1/6+3.347/5=0.836h_{66} = 1/6 + 3.347/5 = 0.836.

High leverage without influence. Fit the first five points of that example with y=(2,3,5,4,6)y = (2, 3, 5, 4, 6): the line is y^=1.3+0.9x\hat y = 1.3 + 0.9x, which predicts 10.3 at x=10x = 10. If the sixth response is y6=10.3y_6 = 10.3, the six-point fit is the same line, e6=0e_6 = 0 and Cook's distance of the point is 0. Its leverage is still 0.836. If instead y6=4y_6 = 4, the line tilts to slope 0.177 and Cook's distance is 7.89. Leverage is potential; the response decides whether it is used.

A balanced design. In a one-way layout with ngn_g observations per group, every point in group gg has leverage 1/ng1/n_g. In a 2k2^k factorial design with all p=2kp = 2^k effects and rr replicates, every point has leverage 1/r1/r. Balanced designs have equal leverages, which is one reason they are robust.

Non-example: a large residual. A point with a large residual and leverage near 1/n1/n is an outlier in yy but has low leverage. It changes the intercept a little and the slope hardly at all.

Non-example: leverage in generalized linear models. For a generalized linear model fitted by iteratively reweighted least squares, the hat matrix is W1/2X(X⊤WX)−1X⊤W1/2W^{1/2}X(X^\top WX)^{-1}X^\top W^{1/2} at the fitted weights. Its diagonal depends on the fitted means, so it depends on yy, and a point far out in xx can have small leverage when its weight is small (a fitted probability near 0 or 1 in logistic regression).

  • Hat matrix. HH itself; leverage is its diagonal.
  • Studentized residual. Divides eie_i by an estimate of σ1−hii\sigma\sqrt{1 - h_{ii}}, so residuals of high-leverage points, which are small by construction, are scaled up.
  • Cook's distance and DFFITS. Combine leverage with the residual: Di=ri2phii1−hiiD_i = \frac{r_i^2}{p}\frac{h_{ii}}{1 - h_{ii}}.
  • Leave-one-out residual. ei/(1−hii)e_i/(1 - h_{ii}); the closed form of leave-one-out cross-validation for least squares uses it.
  • Leverage scores and coherence. In randomized numerical linear algebra, hiih_{ii} is the leverage score of row ii, and max⁡ihii\max_i h_{ii} is the coherence of the column space. Sampling rows with probability proportional to hiih_{ii} gives a small subproblem whose least squares solution approximates the full one; Drineas and coauthors show how to approximate all scores faster than a QR factorization.
  • Robust alternatives. Leverage uses the mean and covariance of the predictors, which are themselves pulled by a cluster of far points (masking). Robust distances from a minimum covariance determinant fit, or least trimmed squares, avoid this.

References

  1. David C. Hoaglin and Roy E. Welsch, The hat matrix in regression and ANOVA, The American Statistician 32(1), 1978, pp. 17 to 22, The whole paper (the bounds 0 <= h_ii <= 1, the average p/n and the rule of thumb 2p/n for high leverage)
  2. George A. F. Seber and Alan J. Lee, Linear Regression Analysis, second edition, Wiley, 2003, Section 10.2 (hat matrix diagonals) and Section 10.6.2 (high-leverage points)
  3. David A. Belsley, Edwin Kuh and Roy E. Welsch, Regression Diagnostics, Wiley, 1980, Chapter 2 (the diagonal of the hat matrix as a measure of leverage, and its cutoff 2p/n)
  4. Petros Drineas, Malik Magdon-Ismail, Michael W. Mahoney and David P. Woodruff, Fast approximation of matrix coherence and statistical leverage, Journal of Machine Learning Research 13, 2012, pp. 3475 to 3506, Section 1 (statistical leverage scores as the squared row norms of an orthonormal basis of the column space, and coherence as their maximum)

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/K2W5YS/text.yaml