In regression model, $H=X(X^TX)^{-1}X^T$ is a hat matrix (so it is symmetric and idempotent), then we have
$$\text{tr}(H^2)=\text{tr}(H)=\text{rank}(H)=\text{rank}(X),$$
We can conclude that $\sum_{i=1}^nh_{ii} = \sum_{i=1}^n\sum_{j=1}^nh_{ij}^2$, but how can we conclude that
$h_{ii} = \sum^n_{j=1}h_{ij}^2$?
Best Answer
I get the answer now. That is because $H=H^2$ and it is symmetric, so we have $h_{ii}=\sum_{j=1}^nh_{ij}h_{ji}=\sum_{j=1}^nh_{ij}^2$.