Leverage (statistics)

From HandWiki
Revision as of 18:58, 6 February 2024 by John Stpola (talk | contribs) (fix)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Short description: Statistical term

In statistics and in particular in regression analysis, leverage is a measure of how far away the independent variable values of an observation are from those of the other observations. High-leverage points, if any, are outliers with respect to the independent variables. That is, high-leverage points have no neighboring points in [math]\displaystyle{ \mathbb{R}^{p} }[/math] space, where [math]\displaystyle{ {p} }[/math] is the number of independent variables in a regression model. This makes the fitted model likely to pass close to a high leverage observation.[1] Hence high-leverage points have the potential to cause large changes in the parameter estimates when they are deleted i.e., to be influential points. Although an influential point will typically have high leverage, a high leverage point is not necessarily an influential point. The leverage is typically defined as the diagonal elements of the hat matrix.

Definition and interpretations

Consider the linear regression model [math]\displaystyle{ {y}_i = \boldsymbol{x}_i^{\top}\boldsymbol{\beta}+{\varepsilon}_i }[/math], [math]\displaystyle{ i=1,\, 2,\ldots,\, n }[/math]. That is, [math]\displaystyle{ \boldsymbol{y} = \mathbf{X}\boldsymbol{\beta}+\boldsymbol{\varepsilon} }[/math], where, [math]\displaystyle{ \mathbf{X} }[/math] is the [math]\displaystyle{ n\times p }[/math] design matrix whose rows correspond to the observations and whose columns correspond to the independent or explanatory variables. The leverage score for the [math]\displaystyle{ {i}^{th} }[/math] independent observation [math]\displaystyle{ \boldsymbol{x}_i }[/math] is given as:

[math]\displaystyle{ h_{ii}= \left[ \mathbf{H} \right]_{ii} = \boldsymbol{x}_i ^{\top} \left( \mathbf{X}^{\top} \mathbf{X} \right)^{-1}\boldsymbol{x}_i }[/math], the [math]\displaystyle{ {i}^{th} }[/math] diagonal element of the ortho-projection matrix (a.k.a hat matrix) [math]\displaystyle{ \mathbf{H} = \mathbf{X} \left( \mathbf{X}^{\top} \mathbf{X} \right)^{-1} \mathbf{X}^{\top} }[/math].

Thus the [math]\displaystyle{ {i}^{th} }[/math] leverage score can be viewed as the 'weighted' distance between [math]\displaystyle{ \boldsymbol{x}_i }[/math] to the mean of [math]\displaystyle{ \boldsymbol{x}_i }[/math]'s (see its relation with Mahalanobis distance). It can also be interpreted as the degree by which the [math]\displaystyle{ {i}^{th} }[/math] measured (dependent) value (i.e., [math]\displaystyle{ y_i }[/math]) influences the [math]\displaystyle{ {i}^{th} }[/math] fitted (predicted) value (i.e., [math]\displaystyle{ \widehat{y\,}_i }[/math]): mathematically,

[math]\displaystyle{ h_{ii} = \frac{\partial\widehat{y\,}_i}{\partial y_i} }[/math].

Hence, the leverage score is also known as the observation self-sensitivity or self-influence.[2] Using the fact that [math]\displaystyle{ {\boldsymbol \widehat{y}}={\mathbf H}{\boldsymbol y} }[/math] (i.e., the prediction [math]\displaystyle{ {\boldsymbol \widehat{y}} }[/math] is ortho-projection of [math]\displaystyle{ {\boldsymbol y} }[/math] onto range space of [math]\displaystyle{ \mathbf{X} }[/math]) in the above expression, we get [math]\displaystyle{ h_{ii}= \left[ \mathbf{H} \right]_{ii} }[/math]. Note that this leverage depends on the values of the explanatory variables [math]\displaystyle{ (\mathbf{X}) }[/math] of all observations but not on any of the values of the dependent variables [math]\displaystyle{ (y_i) }[/math].

Properties

  1. The leverage  [math]\displaystyle{ h_{ii} }[/math] is a number between 0 and 1, [math]\displaystyle{ 0 \leq h_{ii} \leq 1 . }[/math] Proof: Note that [math]\displaystyle{ \mathbf{H} }[/math] is idempotent matrix ([math]\displaystyle{ \mathbf{H}^2=\mathbf{H} }[/math]) and symmetric ([math]\displaystyle{ h_{ij}=h_{ji} }[/math]). Thus, by using the fact that [math]\displaystyle{ \left[ \mathbf{H}^2 \right]_{ii}= \left[ \mathbf{H} \right]_{ii} }[/math], we have [math]\displaystyle{ h_{ii}=h_{ii}^2+\sum_{j\neq i}h_{ij}^2 }[/math]. Since we know that [math]\displaystyle{ \sum_{j\neq i}h_{ij}^2 \geq 0 }[/math], we have [math]\displaystyle{ h_{ii} \geq h_{ii}^2 \implies 0 \leq h_{ii} \leq 1 }[/math].
  2. Sum of leverages is equal to the number of parameters [math]\displaystyle{ (p) }[/math] in [math]\displaystyle{ \boldsymbol{\beta} }[/math] (including the intercept). Proof: [math]\displaystyle{ \sum_{i=1}^n h_{ii} =\operatorname{Tr}(\mathbf{H}) =\operatorname{Tr}\left(\mathbf{X} \left( \mathbf{X}^{\top} \mathbf{X} \right)^{-1} \mathbf{X}^{\top}\right) =\operatorname{Tr}\left(\mathbf{X}^{\top} \mathbf{X} \left(\mathbf{X}^{\top} \mathbf{X} \right)^{-1} \right) =\operatorname{Tr}(\mathbf{I}_p)=p }[/math].

Determination of outliers in X using leverages

Large leverage [math]\displaystyle{ { h_{ii}} }[/math] corresponds to an [math]\displaystyle{ { {\boldsymbol {x}}_{i}} }[/math] that is extreme. A common rule is to identify [math]\displaystyle{ { {\boldsymbol {x}}_{i}} }[/math] whose leverage value [math]\displaystyle{ {h}_{ii} }[/math] is more than 2 times larger than the mean leverage [math]\displaystyle{ \bar{h}=\dfrac{1}{n}\sum_{i=1}^{n}h_{ii}=\dfrac{p}{n} }[/math] (see property 2 above). That is, if [math]\displaystyle{ h_{ii}\gt 2\dfrac{p}{n} }[/math], [math]\displaystyle{ { {\boldsymbol {x}}_{i}} }[/math] shall be considered an outlier. Some statisticians prefer the threshold of [math]\displaystyle{ 3p/{n} }[/math] instead of [math]\displaystyle{ 2p/{n} }[/math].

Relation to Mahalanobis distance

Leverage is closely related to the Mahalanobis distance (proof[3]). Specifically, for some [math]\displaystyle{ n\times p }[/math] matrix [math]\displaystyle{ \mathbf{X} }[/math], the squared Mahalanobis distance of [math]\displaystyle{ { {\boldsymbol {x}}_{i}} }[/math] (where [math]\displaystyle{ {\boldsymbol {x}}_{i}^{\top} }[/math]is [math]\displaystyle{ {i}^{th} }[/math] row of [math]\displaystyle{ \mathbf{X} }[/math]) from the vector of mean [math]\displaystyle{ \widehat{\boldsymbol{\mu}}=\sum_{i=1}^n \boldsymbol{x}_i }[/math] of length [math]\displaystyle{ p }[/math], is [math]\displaystyle{ D^2(\boldsymbol{x}_{i}) = (\boldsymbol{x}_{i} - \widehat{\boldsymbol{\mu}})^{\top} \mathbf{S}^{-1} (\boldsymbol{x}_{i}-\widehat{\boldsymbol{\mu}}) }[/math], where [math]\displaystyle{ \mathbf{S} = \mathbf{X}^{\top}\mathbf{X} }[/math] is the estimated covariance matrix of [math]\displaystyle{ { {\boldsymbol {x}}_{i}} }[/math]'s. This is related to the leverage [math]\displaystyle{ h_{ii} }[/math] of the hat matrix of [math]\displaystyle{ \mathbf{X} }[/math] after appending a column vector of 1's to it. The relationship between the two is:

[math]\displaystyle{ D^2(\boldsymbol{x}_{i}) = (n - 1)(h_{ii} - \tfrac{1}{n}) }[/math]

This relationship enables us to decompose leverage into meaningful components so that some sources of high leverage can be investigated analytically.[4]

Relation to influence functions

In a regression context, we combine leverage and influence functions to compute the degree to which estimated coefficients would change if we removed a single data point. Denoting the regression residuals as [math]\displaystyle{ \widehat{e}_i = y_i- \boldsymbol{x}_i^{\top}\widehat\boldsymbol{\beta} }[/math] , one can compare the estimated coefficient [math]\displaystyle{ \widehat\boldsymbol{\beta} }[/math] to the leave-one-out estimated coefficient [math]\displaystyle{ \widehat\boldsymbol{\beta}^{(-i)} }[/math] using the formula [5][6]

[math]\displaystyle{ \widehat\boldsymbol{\beta} - \widehat\boldsymbol{\beta}^{(-i)} = \frac{(\mathbf{X}^{\top}\mathbf{X})^{-1}\boldsymbol{x}_i\widehat{e}_i}{1-h_{ii}} }[/math]

Young (2019) uses a version of this formula after residualizing controls.[7] To gain intuition for this formula, note that [math]\displaystyle{ \frac{\partial \hat{\beta}}{\partial y_i} = (\mathbf{X}^{\top}\mathbf{X})^{-1}\boldsymbol{x}_i }[/math] captures the potential for an observation to affect the regression parameters, and therefore [math]\displaystyle{ (\mathbf{X}^{\top}\mathbf{X})^{-1}\boldsymbol{x}_i\widehat{e}_i }[/math] captures the actual influence of that observations' deviations from its fitted value on the regression parameters. The formula then divides by [math]\displaystyle{ (1-h_{ii}) }[/math] to account for the fact that we remove the observation rather than adjusting its value, reflecting the fact that removal changes the distribution of covariates more when applied to high-leverage observations (i.e. with outlier covariate values). Similar formulas arise when applying general formulas for statistical influences functions in the regression context.[8][9]

Effect on residual variance

If we are in an ordinary least squares setting with fixed [math]\displaystyle{ \mathbf{X} }[/math] and homoscedastic regression errors [math]\displaystyle{ \varepsilon_i, }[/math] [math]\displaystyle{ \boldsymbol{y}=\mathbf{X}\boldsymbol{\beta}+\boldsymbol{\varepsilon}; \ \ \operatorname{Var}(\boldsymbol{\varepsilon})=\sigma^2\mathbf{I} }[/math], then the [math]\displaystyle{ {i}^{th} }[/math] regression residual, [math]\displaystyle{ e_i=y_i-\widehat{y}_i }[/math] has variance

[math]\displaystyle{ \operatorname{Var}(e_i)=(1-h_{ii})\sigma^2 }[/math].

In other words, an observation's leverage score determines the degree of noise in the model's misprediction of that observation, with higher leverage leading to less noise. This follows from the fact that [math]\displaystyle{ \mathbf{I}-\mathbf{H} }[/math] is idempotent and symmetric and [math]\displaystyle{ \widehat{\boldsymbol{y}}=\mathbf{H}\boldsymbol{y} }[/math], hence, [math]\displaystyle{ \operatorname{Var}(\boldsymbol{e})=\operatorname{Var}((\mathbf{I}-\mathbf{H})\boldsymbol{y}) =(\mathbf{I}-\mathbf{H})\operatorname{Var}(\boldsymbol{y})(\mathbf{I}-\mathbf{H})^\top = \sigma^2 (\mathbf{I}-\mathbf{H})^2=\sigma^2(\mathbf{I}-\mathbf{H}) }[/math].

The corresponding studentized residual—the residual adjusted for its observation-specific estimated residual variance—is then

[math]\displaystyle{ t_i = {e_i\over \widehat{\sigma} \sqrt{1-h_{ii}\ }} }[/math]

where [math]\displaystyle{ \widehat{\sigma} }[/math] is an appropriate estimate of [math]\displaystyle{ \sigma }[/math].

Partial leverage

Partial leverage (PL) is a measure of the contribution of the individual independent variables to the total leverage of each observation. That is, PL is a measure of how [math]\displaystyle{ h_{ii} }[/math] changes as a variable is added to the regression model. It is computed as:

[math]\displaystyle{ \left(\mathrm{PL}_j\right)_i = \frac{\left(\mathbf{X}_{j\bullet[j]}\right)_i^2}{\sum_{k=1}^n\left(\mathbf{X}_{j\bullet[j]}\right)_k^2} }[/math]

where [math]\displaystyle{ j }[/math] is the index of independent variable, [math]\displaystyle{ i }[/math] is the index of observation and [math]\displaystyle{ \mathbf{X}_{j\bullet[j]} }[/math] are the residuals from regressing [math]\displaystyle{ \mathbf{X}_{j} }[/math] against the remaining independent variables. Note that the partial leverage is the leverage of the [math]\displaystyle{ {i}^{th} }[/math] point in the partial regression plot for the [math]\displaystyle{ {j}^{th} }[/math] variable. Data points with large partial leverage for an independent variable can exert undue influence on the selection of that variable in automatic regression model building procedures.

Software implementations

Many programs and statistics packages, such as R, Python, etc., include implementations of Leverage.

Language/Program Function Notes
R hat(x, intercept = TRUE) or hatvalues(model, ...) See [1]
Python (x * np.linalg.pinv(x).T).sum(-1) See [2]

See also

References

  1. Everitt, B. S. (2002). Cambridge Dictionary of Statistics. Cambridge University Press. ISBN 0-521-81099-X. 
  2. Cardinali, C. (June 2013). "Data Assimilation: Observation influence diagnostic of a data assimilation system". https://www.ecmwf.int/sites/default/files/elibrary/2013/16938-observation-influence-diagnostic-data-assimilation-system.pdf. 
  3. Prove the relation between Mahalanobis distance and Leverage?
  4. Kim, M. G. (2004). "Sources of high leverage in linear regression model (Journal of Applied Mathematics and Computing, Vol 16, 509–513)". arXiv:2006.04024 [math.ST].
  5. Miller, Rupert G. (September 1974). "An Unbalanced Jackknife" (in EN). Annals of Statistics 2 (5): 880–891. doi:10.1214/aos/1176342811. ISSN 0090-5364. https://projecteuclid.org/euclid.aos/1176342811. 
  6. Hiyashi, Fumio (2000). Econometrics. Princeton University Press. pp. 21. 
  7. Young, Alwyn (2019). "Channeling Fisher: Randomization Tests and the Statistical Insignificance of Seemingly Significant Experimental Results". The Quarterly Journal of Economics 134 (2): 567. doi:10.1093/qje/qjy029. https://academic.oup.com/qje/article/134/2/557/5195544. 
  8. Chatterjee, Samprit; Hadi, Ali S. (August 1986). "Influential Observations, High Leverage Points, and Outliers in Linear Regression" (in EN). Statistical Science 1 (3): 379–393. doi:10.1214/ss/1177013622. ISSN 0883-4237. https://projecteuclid.org/euclid.ss/1177013622. 
  9. "regression - Influence functions and OLS". https://stats.stackexchange.com/q/8344.