Calculates leverage, that is, how far away the regressor values of an observation are from those of the other observations using $$ h_{ii} = x_{i}^{T} \left( \mathbf{X}^{T} \mathbf{X} \right)^{-1} x_{i} $$ where \(x_{i}^{T}\) is the \(i\)th row of the \(\mathbf{X}\) matrix. Note that \( \mathbf{X} \left( \mathbf{X}^{T} \mathbf{X} \right)^{-1} \mathbf{X}^{T} \) is the projection matrix (or hat matrix) \(\mathbf{P}\) and \(h_{ii}\) is the diagonal of \(\mathbf{P}\).
.h(P = NULL, X = NULL)
P | Numeric matrix The projection matrix. |
---|---|
X |
|
Returns leverage.
If P = NULL
, P
is computed with X
as a required argument.
X
is ignored if P
is provided.
Ivan Jacob Agaloos Pesigan