# Matrix multiplication notation in Hayashi Econometrics

The question is verify that $$X'X/n = \frac{1}{n} \sum_i x_i x_i'$$ I'm gonna ignore the dividing by n. My problem is if $$X$$ is a $$m \times n$$ matrix then $$X'X$$ is a $$n \times m$$ matrix multiplied by a $$m \times n$$ matrix giving a $$n \times n$$ matrix. Whereas $$x_i$$ (I'm assuming) is the ith column vector so $$x_i x_i'$$ is a $$m \times 1$$ column vector multiplied by a $$1 \times m$$ row vector giving a $$m \times m$$ matrix. Then you sum up all i matrices still giving you a $$m \times m$$ matrix. Is this a typo? or am I missing something?

• Perhaps you assume incorrectly and xi is row. Normally your observational unit are indexed i and are rows in designmatrix. Commented Jul 22 at 14:20
• Wouldn't that still just give me a scaler instead of a n by n matrix? Commented Jul 22 at 14:43
• No it would not see my answer. Commented Jul 22 at 15:41

Page 6 of Hayashi introduces the notations: $$X$$ is a $$n\times K$$ matrix, namely $$n$$ rows and $$K$$ columns, and $$x_i$$ is a $$K\times1$$ vector of regressors for observation $$i$$. Thus, $$\underset{(n\times K)}X = \begin{bmatrix}x_1'\\\vdots\\x_i'\\\vdots\\x_n'\end{bmatrix}$$

Note that $$X'X$$ is a $$K\times K$$ matrix. For each observation $$i$$, $$x_ix_i'$$ is also a $$K\times K$$ matrix. Summing over all $$n$$ observations, we have $$X'X = \sum_{i=1}^nx_ix_i'$$.

Let $$X$$ be a $$3\times2$$ matrix.

You can do row-partitioning

$$X^\top X = \begin{bmatrix}x^\top_1\\x^\top_2\\x^\top_3\end{bmatrix}^\top\begin{bmatrix}x^\top_1\\x^\top_2\\x^\top_3\end{bmatrix} = [x_1\ x_2 \ x_3] \begin{bmatrix}x^\top_1\\x^\top _2\\x^\top_3\end{bmatrix} = \sum_i x_i x^\top_i$$

note that $$x_i^\top$$ is row $$i$$ written as a row vector and $$x_i$$ is row $$i$$ written as column vector. The convention is therefore that non-transposed vectors are column-form (but may still be a row in the original design matrix) whereas transposed vectors are row-form.

You get the sum of 3 matrices of dimension 2 $$\times$$ 2. Just as $$X^\top X$$ is $$(3 \times 2)^\top (3 \times 2) = 2 \times 2$$

Or you can do column-partitioning

$$X^\top X = \begin{bmatrix}x_1 \ \ x_2\end{bmatrix}^\top\begin{bmatrix}x_1 \ \ x_2\end{bmatrix} = \begin{bmatrix}x^\top_1 \\ x^\top_2\end{bmatrix}\begin{bmatrix}x_1 \ \ x_2\end{bmatrix} = \begin{bmatrix}x_1^\top x_1 & x_1^\top x_2 \\ x_2^\top x_1 & x_2^\top x_2\end{bmatrix}$$

The first approach gives you the matrix multiplication as a sum of outer products the other approach gives you the matrix product as a matrix of inner products.