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?