# Idempotency of difference of two idempotent matrices

Define

$$\mathbf{H}=\mathbf{X}\left(\mathbf{X}^{\prime}\mathbf{X}\right)^{-1}\mathbf{X}^{\prime}$$

where $\mathbf{X}$ is a design matrix of order $n \times k$

and

$$\overline{\mathbf{J}}=\frac{1}{n}\mathbf{J}=\frac{1}{n}\mathbf{1}\mathbf{1}^{\prime}$$

where $\mathbf{1}$ is a unit vector of order $n \times 1$.

Now $$\mathbf{H}\mathbf{H}=\mathbf{H}$$

and

$$\overline{\mathbf{J}}\overline{\mathbf{J}}=\overline{\mathbf{J}}$$

Thus both $\mathbf{H}$ and $\overline{\mathbf{J}}$ are idempotent matrices.

My question is whether $\mathbf{H}-\overline{\mathbf{J}}$ would be idempotent. If so then

$$\left(\mathbf{H}-\mathbf{\overline{\mathbf{J}}}\right)\mathbf{\left(\mathbf{H}-\mathbf{\overline{\mathbf{J}}}\right)}=\mathbf{H}-\mathbf{H\overline{\mathbf{J}}-\overline{\mathbf{J}}H}+\overline{\mathbf{J}}=\mathbf{H}-\mathbf{\overline{\mathbf{J}}-\overline{\mathbf{J}}}+\overline{\mathbf{J}}=\mathbf{H}-\overline{\mathbf{J}}$$

But I'm not able to show that

$$\mathbf{H\overline{\mathbf{J}}=\overline{\mathbf{J}}H}=\overline{\mathbf{J}}$$

I'd highly appreciate if you guide me to figure this. Thanks for your time and help.

Edited

$\mathbf{X}$ is a design matrix, has a widespread use in Statistics, see here.

-

## migrated from stats.stackexchange.comNov 12 '12 at 15:06

This question came from our site for people interested in statistics, machine learning, data analysis, data mining, and data visualization.

What you need is ${\bf H\bar J}+{\bf \bar JH}=2{\bf\bar J}$, but I think it is rarely going to hold, and much depends on ${\bf X}$. –  Berci Nov 12 '12 at 15:12
Might it have been intended that one of the columns of $\mathbf{X}$ is a column of $1$s? –  Michael Hardy Nov 12 '12 at 15:16
@MichaelHardy: You right, the first column of $\mathbf{X}$ is a a column of $\mathbf{1}$s. –  MYaseen208 Nov 12 '12 at 15:18

In view of the comments I'll construe the word "design" in the phrase "design matrix" to mean that one of the columns of $\mathbf{X}$ is a column of $1$s, although that usage is not universal.
Then the column space of $\mathbf{J}$ is a subspace of the column space of $\mathbf{X}$. The matrix $\mathbf{H}$ represents the projection onto the column space of $\mathbf{X}$. If $\mathbf{Y}\in\mathbb{R}^{n\times 1}$ then $\mathbf{HY}$ is the projection of $\mathbf{Y}$ onto the column space of $\mathbf{X}$, and $\mathbf{\overline{J}Y}$ is the projection of $\mathbf{Y}$ onto the column of $1$s.
Since the column space of $\mathbf{J}$ is a subspace of that of $\mathbf{X}$, the column space of $\mathbf{\overline{J}}$ is also a subspace of that of $\mathbf{X}$, and we have $\mathbf{H\overline{J}}=\mathbf{\overline{J}}$, i.e. the projection of a column of $\mathbf{\overline{J}}$ onto the column space of $\mathbf{X}$ is itself. Since $\mathbf{H}$ and $\mathbf{\overline{J}}$ are symmetric, we have $$\mathbf{H\overline{J}}=\mathbf{\overline{J}}\text{ and } \mathbf{\overline{J}H}=\mathbf{\overline{J}}.$$