Is there a way to speed up $Z(Z'Z)^{-1}Z'$ type matrices? I am implementing the expression below directly using a matrix language and my program frequently crashes while if I run OLS on them using a pre-fabricated command, it is not an issue.
Is there a tip you guys might have to compute these matrices efficiently?
The goal here (but that is just an aside) is to implement the following estimator \begin{eqnarray} (X' P X - \sum_{i=1}^{n} P_{ii} X_{i}X_{i}' - \alpha X'X)^{-1} (X' P_Z y - \sum_{i=1}^{n} P_{ii} X_{i} y_{i} - \alpha X' y) \end{eqnarray} Now, $\alpha$ is the smallest eigenvalue of $(\overline{X}'\overline{X})^{-1} (\overline{X}' P_Z \overline{X} - \sum_{i=1}^{n} P_{ii} \overline{X}_{i} \overline{X}'_{i})$ where $\overline{X} = [y,X]$.
I am pretty confident that once I have found an efficient way to compute the projections, I can easily implement the rest easily.
Thanks so much!