[R] In a SLR, Why Does the Hat Matrix Depend on the Weights?

Peter Dalgaard p.dalgaard at biostat.ku.dk
Fri Oct 19 22:28:07 CEST 2007


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



More information about the R-help mailing list