Best Linear Predictor - problems with the derivation I'm studying econometrics from the Hansen's book (2022).
I'm trying to understand the mathematics behind the following steps:
Let $X=(1,X_2,...,X_k)$ be the vector of covariates, and $\beta =(\beta_1,\beta_2,...,\beta_k)$ be the vector of regression coefficients.


Why do we have in the expression $[2.19]$ in the right hand side, $E[XX']$? I was expecting $E[X'X]$.

This is because $\beta'X = X'\beta$ and associative law of matrix multiplication:
$$(\beta'X)^2 = (\beta'X)(\beta'X) = \beta'XX'\beta= \beta'(XX')\beta.$$
Now apply the linearity of expectation to get:
\begin{align*}
E[(Y - \beta'X)^2] = E[Y^2] - 2\beta'E[XY] + \beta'E[XX']\beta.
\end{align*}
