Proposition.Let be a matrix that is symmetric () and idempotent (). Then the rank of is equal to the trace of . In fact, they are both equal to the sum of the eigenvalues of .

The proof is relatively straightforward. Since is real and symmetric, it is orthogonally diagonalizable, i.e. there is an orthogonal matrix () and a diagonal matrix such that (see here for proof).

Since is idempotent,

Since is a diagonal matrix, it implies that the entries on the diagonal must be zeros or ones. Thus, the number of ones on the diagonal (which is ) is equal to the sum of the diagonal (which is ).

Pingback: Asymptotic distribution of the Pearson chi-square statistic | Statistical Odds & Ends