# Matrix algebraic manipulation

The textbook referenced below (1) doesn't detail the algebraic manipulation that leads to the following result. Could you please help me understand why the result holds?

Let $\vec{j}$ be the $n \times 1$ vector with all its elements equal to one, $I$ be the $n \times n$ identity matrix and $\bar{z} = \frac{1}{n} \sum z_i$ . Now $$\sum (z_i - \bar{z}) ^2 = z^T M z$$ where the matrix $M$ is defined by $$M = I - \frac{1}{n} \vec{j} \ \vec{j}^T.$$

Reference:

(1) Heij, De Boer, Franses, Kloek, Van Dijk. Econometric Methods with Applications in Business and Economics, Oxford University Press.

## 1 Answer

By the definition of $\vec{j}$ it follows that $\bar{z} = (1/n)\vec{j}^T\!z$. Let $e_i$ denote the $n$-vector of all zeroes with a $1$ in the $i$th coordinate. Then $z_i = e_i^Tz$ and

\begin{align*} \sum_i (z_i - \bar{z})^2 &= \sum_i \left[(e_i - (1/n)\vec{j})^Tz\right]^2 = \sum_i z^T(e_i - (1/n)\vec{j})(e_i - (1/n)\vec{j})^Tz\\ &= z^T\left(\sum_i (e_i - (1/n)\vec{j})(e_i - (1/n)\vec{j})^T\right)z \end{align*}

Since

$$(e_i - (1/n)\vec{j})(e_i- (1/n)\vec{j})^T = e_ie_i^T - (1/n)e_i\vec{j}^T - (1/n)\vec{j}e_i^T + (1/n)^2\vec{j}\,\vec{j}^T$$

and $\sum_i e_i = \vec{j}$ and $\sum_i e_ie_i^T = I$, we have

$$\sum_i (e_i - (1/n)\vec{j})(e_i - (1/n)\vec{j})^T = I - (1/n)\vec{j}\,\vec{j}^T - (1/n)\vec{j}\,\vec{j}^T + (1/n) \vec{j}\,\vec{j}^T = I - (1/n)\vec{j}\,\vec{j}^T$$

Hence

$$\sum_i (z_i - \bar{z})^2 = z^T\left(I - (1/n)\vec{j}\,\vec{j}^T\right)z$$

• Thank you very much. The definition and use of e_i was very ingenious! – toliveira Sep 28 '15 at 17:44