<p>Page 6 of Hayashi introduces the notations: <span class="math-container">$X$</span> is a <span class="math-container">$n\times K$</span> matrix, namely <span class="math-container">$n$</span> rows and <span class="math-container">$K$</span> columns, and <span class="math-container">$x_i$</span> is a <span class="math-container">$K\times1$</span> vector of regressors for observation <span class="math-container">$i$</span>. Thus,
<span class="math-container">$$\underset{(n\times K)}X = \begin{bmatrix}x_1'\\\vdots\\x_i'\\\vdots\\x_n'\end{bmatrix}$$</span></p>
<p>Note that <span class="math-container">$X'X$</span> is a <span class="math-container">$K\times K$</span> matrix. For each observation <span class="math-container">$i$</span>, <span class="math-container">$x_ix_i'$</span> is also a <span class="math-container">$K\times K$</span> matrix. Summing over all <span class="math-container">$n$</span> observations, we have <span class="math-container">$X'X = \sum_{i=1}^nx_ix_i'$</span>.</p>

CC BY-SA 4.0
2024-07-22T15:34:18.247Z
2024-07-22T15:34:18.247Z
Herr K.
<p>Let <span class="math-container">$X$</span> be a <span class="math-container">$3\times2$</span> matrix.</p>
<p>You can do <strong>row-partitioning</strong></p>
<p><span class="math-container">$$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$$</span></p>
<p>note that <span class="math-container">$x_i^\top$</span> is row <span class="math-container">$i$</span> written as a row vector and <span class="math-container">$x_i$</span> is row <span class="math-container">$i$</span> 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.</p>
<p>You get the sum of 3 matrices of dimension 2 <span class="math-container">$\times$</span> 2. Just as <span class="math-container">$X^\top X$</span> is <span class="math-container">$(3 \times 2)^\top (3 \times 2) = 2 \times 2$</span></p>
<p>Or you can do <strong>column-partitioning</strong></p>
<p><span class="math-container">$$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 &amp; x_1^\top x_2 \\ x_2^\top x_1 &amp; x_2^\top x_2\end{bmatrix}$$</span></p>
<p>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.</p>

CC BY-SA 4.0
2024-07-22T15:24:48.570Z
2024-07-23T07:05:29.123Z
2024-07-23T07:05:29.123Z
Jesper Hybel
<p>The question is verify that <span class="math-container">$X'X/n = \frac{1}{n} \sum_i x_i x_i'$</span> I'm gonna ignore the dividing by n. My problem is if <span class="math-container">$X$</span> is a <span class="math-container">$m \times n$</span> matrix then <span class="math-container">$X'X$</span> is a <span class="math-container">$n \times m$</span> matrix multiplied by a <span class="math-container">$m \times n$</span> matrix giving a <span class="math-container">$n \times n$</span> matrix. Whereas <span class="math-container">$x_i$</span> (I'm assuming) is the ith column vector so <span class="math-container">$x_i x_i'$</span> is a <span class="math-container">$m \times 1$</span> column vector multiplied by a <span class="math-container">$1 \times m$</span> row vector giving a <span class="math-container">$m \times m$</span> matrix. Then you sum up all i matrices still giving you a <span class="math-container">$m \times m$</span> matrix. Is this a typo? or am I missing something?</p>

CC BY-SA 4.0
2024-07-22T14:20:47.927Z
Perhaps you assume incorrectly  and xi is row. Normally your observational unit are indexed i and are rows in designmatrix.
Jesper Hybel
CC BY-SA 4.0
2024-07-22T14:43:48.953Z
Wouldn't that still just give me a scaler instead of a n by n matrix?
user49081
CC BY-SA 4.0
2024-07-22T15:41:31.943Z
No it would not see my answer.
Jesper Hybel
<econometrics>
Matrix multiplication notation in Hayashi Econometrics
user49081
# Matrix multiplication notation in Hayashi Econometrics

(Asked by: username_0 on 2024-07-22)

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?

**Tags:** econometrics
> **Comments:**
> **username_1**: Perhaps you assume incorrectly  and xi is row. Normally your observational unit are indexed i and are rows in designmatrix.  
> **username_0**: Wouldn't that still just give me a scaler instead of a n by n matrix?  
> **username_1**: No it would not see my answer.  

---

## 2 answers

### Answer by username_2 on 2024-07-22. Score: 1

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'$.


---

### Answer by username_1 on 2024-07-22. Score: 1

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.


---

