[R] influence.measures(stats): hatvalues(model, ...)

Viechtbauer Wolfgang (STAT)
Sun, 08 Nov 2009 13:01:51 -0000

Not sure what you mean.

yi <- c(2,3,2,4,3,6)
xi <- c(1,4,3,2,4,5)

res <- lm(yi ~ xi)
hatvalues(res)

X <- cbind(1, xi)
diag( X%*%solve(t(X)%*%X)%*%t(X) )

Same result.

Best,

--
Wolfgang Viechtbauer                        http://www.wvbauer.com/
Department of Methodology and Statistics    Tel: +31 (0)43 388-2277
School for Public Health and Primary Care   Office Location:
Maastricht University, P.O. Box 616         Room B2.01 (second floor)
6200 MD Maastricht, The Netherlands         Debyeplein 1 (Randwyck)
________________________________________
From: r-help-bounces at r-project.org [r-help-bounces at r-project.org] On
Behalf Of Sigmund Freud [ss_freud_56 at yahoo.com]
Sent: Sunday, November 08, 2009 8:14 AM
To: r-help at r-project.org
Subject: [R]  influence.measures(stats): hatvalues(model, ...)

Hello:

I am trying to understand the method 'hatvalues(...)', which returns
something similar to the diagonals of the plain vanilla hat matrix
[X(X'X)^(-1)X'], but not quite.

A Fortran programmer I am not, but tracing through the code it looks like
perhaps some sort of correction based on the notion of 'leave-one-out'
variance is being applied.

Whatever the difference, in simulations 'hatvalues' appears to perform
much better in the context of identifying outiers using Cook's Distance than
the diagonals of the plain vanilla hat matrix. (As in
http://en.wikipedia.org/wiki/Cook's_distance).

Would prefer to understand a little more when using this method. I have
downloaded the freely available references cited in the help and am in the
process of digesting them. If someone with knowledge could offer a pointer on
the most efficient way to get at why 'hatvalues' does what it does, that
would be great.

Thanks,
Jean Yarrington
Independent consultant.