The difference to hatvalues
is that leverage
does not
call influence
and therefore does not require residuals.
It is therefore simpler and more widely applicable.
The function uses the qr
decomposition of object
.
If necessary, it generate it.
The leverage is the squared Mahalanobis distance of the observation
from the center of the design X (model.matrix
) with
"covariance" X^T X. If there are weights (object$weights
),
the weighted center and "covariance" are used, and the distances are
multiplied by the weights.
To obtain the distances in the latter case, "de-weight" the leverages
by dividing them by the weights.