Tom La Bone
2007-Oct-19 19:47 UTC
[R] In a SLR, Why Does the Hat Matrix Depend on the Weights?
I understand that the hat matrix is a function of the predictor variable alone. So, in the following example why do the values on the diagonal of the hat matrix change when I go from an unweighted fit to a weighted fit? Is the function hatvalues giving me something other than what I think it is? library(ISwR) data(thuesen) attach(thuesen) fit <- lm(short.velocity ~ blood.glucose) summary(fit) hatvalues(fit) W <- 1/blood.glucose fit.w <- lm(short.velocity ~ blood.glucose,weights=W) summary(fit.w) hatvalues(fit.w) Thanks for the help. Tom [[alternative HTML version deleted]]
Tom La Bone
2007-Oct-19 20:22 UTC
[R] In a SLR, Why Does the Hat Matrix Depend on the Weights?
Because it does. I should have looked ahead a few chapters in the book before I asked the question. However, I can't seem to reproduce the values of the hat matrix given by R for the weighted fit example I gave. Any suggestions (other than looking ahead a few more chapters)? Tom [[alternative HTML version deleted]]
Peter Dalgaard
2007-Oct-19 20:28 UTC
[R] In a SLR, Why Does the Hat Matrix Depend on the Weights?
Tom La Bone wrote:> I understand that the hat matrix is a function of the predictor variable > alone. So, in the following example why do the values on the diagonal of the > hat matrix change when I go from an unweighted fit to a weighted fit? Is the > function hatvalues giving me something other than what I think it is? > > >It's a bit difficult to know what you might be thinking. The formula for the hat matrix is X inv(X'WX) X'W and I have some difficulty seeing how you might expect that _not_ to depend on W.... (I suspect that whatever source you used intended to say that the hat matrix does not depend on the observations, with no thought given to the possibility of a weighted analysis.)> library(ISwR) > > data(thuesen) > > attach(thuesen) > > > > fit <- lm(short.velocity ~ blood.glucose) > > summary(fit) > > hatvalues(fit) > > > > W <- 1/blood.glucose > > fit.w <- lm(short.velocity ~ blood.glucose,weights=W) > > summary(fit.w) > > hatvalues(fit.w) > > > > Thanks for the help. > > > > Tom > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907