# Determine if the matrix is idempotent?

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?

-
Why would $XX' = I$? That may not be true. –  johnny Mar 12 '13 at 11:09
I am struggeling to find rules to determine the solution of the above example? Do you have a link or sth? –  Le Chifre Mar 12 '13 at 11:18

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~~???)
THX!. ok to undestand it correctly, the right assumption is $XX=I$? btw why do you left the $I - ...$ out? –  Le Chifre Mar 12 '13 at 11:26
@maximus I haven't made any additional assumptions. Why would you think that I have assumed $XX=I$? The key is, the $Y$ as defined in my answer is idempotent, so it follows that $M=I-Y$ is also idempotent. –  user1551 Mar 12 '13 at 11:32
@maximus The previous line has shown that $Y^2=Y$. –  user1551 Mar 12 '13 at 13:10