Leverag

From Eigenvector Research Documentation Wiki
Jump to navigation Jump to search

Purpose

Calculates sample leverage.

Synopsis

lev = leverag(x,rinv)

Description

LEVERAG calculates the sample leverage according to

lev(i,1) = x(i,:)\*inv(x'\*x)\*x(i,:)'

Note that the leverage calculation should include a term for calculation of the offset (e.g. see Draper, N. and Smith, H., "Applied Regression Analysis, Second Edition", John Wiley & Sons, New York, N.Y., 1981), but the above formula contains the salient information. This, in effect, assumes that the data have been mean centered and the constant term related to estimating the offset has been ignored. If x'\*x is replaced by x'\*x/(m-1) where m is the number of rows of x, and x has been mean centered then this is the equation for Hotelling's T2 statistic.

Note that if x is not of full rank then inv(x'\*x) won't exist, or if x is nearly rank deficient then calculation of the inverse will be unstable. In these cases, the scores from principal components analysis can be used.

If the optional input rinv is supplied then the leverage is calculated as

lev(i,1) = x(i,:)\*rinv\*x(i,:)'

Note too that the leverage reported in a PLS or PCR model is based on the model's scores, not mean-centered preprocessed x. Use leverag(model.loads{1,1}) to match model.detail.leverage. The model.detail.leverage will only match leverage from applying the leverag function to mean-centered pre-processed x if the model is full rank.

See Also

doptimal, figmerit, pcr, pls