I'm working through Econometrics by Bruce Hansen, and I'm not sure how to get to his conditional variance proof on page 90.
Hansen says: For any $n \times r$ matrix $\mathbf{A} = \mathbf{A}(\mathbf{X})$: $\text{var}(\mathbf{A}^T\mathbf{y}|\mathbf{X}) = \text{var}(\mathbf{A}^T\mathbf{e}|\mathbf{X}) = \mathbf{A}^T\mathbf{D}\mathbf{A}$, where $D=\text{diag}(\sigma_1^2, ..., \sigma^2_n)$.
Why is this the case? I can see this step, but I'm not sure how to justify it from the full definition: $\text{var}(\mathbf{A}^T\mathbf{e}|\mathbf{X}) = \mathbf{A}^T\text{var}(\mathbf{e}|\mathbf{X})\mathbf{A} = \mathbf{A}^T\mathbf{D}\mathbf{A}$.
I.e. how do I get there with this: $\text{var}(\mathbf{Z}|\mathbf{X}) = \mathbb{E}[(\mathbf{Z} - \mathbb{E}[\mathbf{Z}|\mathbf{X}])(\mathbf{Z} - \mathbb{E}[\mathbf{Z}|\mathbf{X}])^T|\mathbf{X}], \mathbf{\hat\beta} = \mathbf{A}^T\mathbf{y}, \mathbf{A} = \mathbf{X}(\mathbf{X}^T\mathbf{X})^{-1}$
I tried but I kept on getting matrix dimensions that don't match up.