Re: [R] Why H1=1? (H's the hat matrix)
Dear Simon, > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of Simon Bonner > Sent: October-11-09 2:33 PM > To: Peng Yu > Cc: r-h...@stat.math.ethz.ch > Subject: Re: [R] Why H1=1? (H's the hat matrix) > > Another, less geometric, way to think about this: > > The fitted response for a linear model is a weighted average of the > observed responses. The i-th row of the hat matrix list the coefficients > of the average for the i-th fitted value. These values sum to 1 for each > row, and so H %*% 1=1. That's true if there's a constant column in X, or more generally if the 1 vector lies in the subspace spanned by the columns of X, but not in general. Best, John > > Cheers... > > - > Simon Bonner > Post-Doctoral Fellow > Department of Statistics, UBC > > www.simon.bonners.ca > > > On Sun, 2009-10-11 at 14:09 -0400, Gabor Grothendieck wrote: > > H projects vectors onto the range of X so any vector already in the > > range of X gets projected onto itself. > > > > On Sun, Oct 11, 2009 at 2:03 PM, Peng Yu wrote: > > > Suppose I have the following hat matrix: > > > > > > H=X(X'X)^{-1}X' > > > X is a n by p matrix, where n >= p and X_{i,1} = 1 > > > > > > I'm wondering why H1 = 1. (Here, 1 is column vector, whose each > > > element is the number 1) > > > > > > Thank you! > > > > > > __ > > > R-help@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. > > > > > > > __ > > R-help@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. > > > > __ > R-help@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. __ R-help@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.
Re: [R] Why H1=1? (H's the hat matrix)
Another, less geometric, way to think about this: The fitted response for a linear model is a weighted average of the observed responses. The i-th row of the hat matrix list the coefficients of the average for the i-th fitted value. These values sum to 1 for each row, and so H %*% 1=1. Cheers... - Simon Bonner Post-Doctoral Fellow Department of Statistics, UBC www.simon.bonners.ca On Sun, 2009-10-11 at 14:09 -0400, Gabor Grothendieck wrote: > H projects vectors onto the range of X so any vector already in the > range of X gets projected onto itself. > > On Sun, Oct 11, 2009 at 2:03 PM, Peng Yu wrote: > > Suppose I have the following hat matrix: > > > > H=X(X'X)^{-1}X' > > X is a n by p matrix, where n >= p and X_{i,1} = 1 > > > > I'm wondering why H1 = 1. (Here, 1 is column vector, whose each > > element is the number 1) > > > > Thank you! > > > > __ > > R-help@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. > > > > __ > R-help@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. > __ R-help@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.
Re: [R] Why H1=1? (H's the hat matrix)
Dear Peng, This seems a curious question to pose on r-help: The vector 1 is the first column of X, and hence lies in the subspace spanned by the columns of X. H projects any vector orthogonally onto the subspace spanned by X. Thus, if a vector, such as 1, lies in this subspace, it's projected onto itself. Regards, John > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of Peng Yu > Sent: October-11-09 2:03 PM > To: r-h...@stat.math.ethz.ch > Subject: [R] Why H1=1? (H's the hat matrix) > > Suppose I have the following hat matrix: > > H=X(X'X)^{-1}X' > X is a n by p matrix, where n >= p and X_{i,1} = 1 > > I'm wondering why H1 = 1. (Here, 1 is column vector, whose each > element is the number 1) > > Thank you! > > __ > R-help@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. __ R-help@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.
Re: [R] Why H1=1? (H's the hat matrix)
H projects vectors onto the range of X so any vector already in the range of X gets projected onto itself. On Sun, Oct 11, 2009 at 2:03 PM, Peng Yu wrote: > Suppose I have the following hat matrix: > > H=X(X'X)^{-1}X' > X is a n by p matrix, where n >= p and X_{i,1} = 1 > > I'm wondering why H1 = 1. (Here, 1 is column vector, whose each > element is the number 1) > > Thank you! > > __ > R-help@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. > __ R-help@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.
[R] Why H1=1? (H's the hat matrix)
Suppose I have the following hat matrix: H=X(X'X)^{-1}X' X is a n by p matrix, where n >= p and X_{i,1} = 1 I'm wondering why H1 = 1. (Here, 1 is column vector, whose each element is the number 1) Thank you! __ R-help@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.