[Math] Determine if the matrix is idempotent

idempotentsinversematrices

I am dealing with an example to show that the matrix($M = I − X(X'X)^{−1}X'$) is idempotent. X is a matrix with T rows and k columns and I the unit matrix of dimension T. And then to determine the rank of this matrix by using the properties of the trace of the matrix.
1.
Idempotent means that matrix $A^2=A*A=A$

$$M = I − X(X'X)^{−1}X'$$
$$M = XX' − X(X'X)^{−1}X'$$
$$MM = (XX' − X(X'X)^{−1}X')(XX' − X(X'X)^{−1}X')$$
$$MM = (XX' − X(X'X)^{−1}X')(I − I)$$
-> MM is not idempotent

Is that correct?

2.
$$Tr(AB)=Tr(BA)$$
$$Tr(M)=Tr(I − X(X'X)^{−1}X') = Tr(I − I) = Tr(0) = 0$$

Are my assumptions correct?

UPDATE

$$Tr(A-B)=Tr(A) – Tr(B)$$
$$Tr(M)=Tr(I) − Tr(X(X'X)^{−1}X')) = Tr(I) − Tr(I) = Tr(0) or Tr(I)= Rank(n)$$
Is this correct?

Best Answer

  1. You've wrongly assumed that $XX'=I$. To prove that $M$ is idempotent, note that $Y^2=(X(X'X)^{−1}X')^2=X\underbrace{(X'X)^{−1}X'X}_{=I}(X'X)^{−1}X'=:Y$, so $M^2=(I-Y)^2=I-2Y+Y^2=I-Y=M$.
  2. Indeed $\operatorname{tr}(X(X'X)^{−1}X')=\operatorname{tr}(X'X(X'X)^{−1})=\operatorname{tr}(I)$, but the size of this $I$ is $k\times k$, while the $I$ in $\operatorname{tr}(I-X(X'X)^{−1}X')$ has size $T\times T$. So, no, the trace of $M$ is not zero in general, but $\operatorname{tr}(I_T)-\operatorname{tr}(I_k)=T-k$. To find the rank of $M$ using the trace, observe that (a) every eigenvalue of $M$ is either $0$ or $1$ (why?) and (b) $M$ is unitarily diagonalizable (again, why?). So, the rank is equal to the trace. (Why~y~y~~???)
Related Question