# Proving that $\mathbf{(H-\frac{1}{n}J_n)}$ is indempotent

I am trying to show that the matrix $$\mathbf{(H-\frac{1}{n}J_n)}$$ is idempotent where $$\mathbf{H}$$ is the Hat-matrix (Projection matrix) of linear regression and $$J_n$$ is the $$n\times n$$ matrix with $$1$$ in all its inputs. Taking :

$$\mathbf{(H-\frac{1}{n}J_n)(H-\frac{1}{n}J_n)= HH - H\frac{1}{n}J_n - \frac{1}{n}J_nH + \frac{1}{n}J_n\frac{1}{n}J_n}$$

Now, we know that $$\mathbf{H}$$ and $$\mathbf{\frac{1}{n}J_n}$$ are idempontent, thus :

$$\mathbf{(H-\frac{1}{n}J_n)(H-\frac{1}{n}J_n)=H-H\frac{1}{n}J_n - \frac{1}{n}J_nH +\frac{1}{n}J_n}$$

How would I continue now in order to show that the given matrix is idempontent ?

• The "hat matrix" should be redefined, It is not a usual name... – Jean Marie Nov 22 '18 at 19:08
• @JeanMarie It is the projection matrix. en.wikipedia.org/wiki/Projection_matrix – Rebellos Nov 22 '18 at 19:12
• @JeanMarie It's $X(X^TX)^{-1}X^T$, where $X$ is the matrix of regressors. It's called the hat matrix because when you multiply $y$ on the left by it, you get $\hat y$, that is, it "puts a hat on $y$", figuratively. – Jean-Claude Arbaut Nov 22 '18 at 19:15
• @Jean-Claude Arbaut Thank you for this precise explanation. Thank you as well to the OP. – Jean Marie Nov 22 '18 at 19:19
• Looks to me $H$ has to be the identity matrix for $H-\frac{1}{n}J_n$ to be idempotent. – StubbornAtom Nov 22 '18 at 19:26