Skip to content

influence.measures(stats): hatvalues(model, ...)

3 messages · Sigmund Freud, Peter Ehlers, Viechtbauer Wolfgang (STAT)

#
Sigmund Freud wrote:
I can't see what the problem is. Using the LifeCycleSavings
example from ?influence.measures:

   lm.SR <- lm(sr ~ pop15 + pop75 + dpi + ddpi, data = LifeCycleSavings)
   X <- model.matrix(lm.SR)
   H <- X %*% solve(t(X) %*% X) %*% t(X)
   hats1 <- diag(H)
   hats2 <- hatvalues(lm.SR)
   all.equal(hats1, hats2)
   #[1] TRUE
In a nutshell, hatvalues are a measure of how unusual
a point is in predictor space, i.e. to what extent it
"sticks out" in one or more of the X-dimensions.

  -Peter Ehlers
#
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)