# When working in matrix form, why is the sum of squared residuals given by $e'e$?

Why is it that when calculating the sum of squared residuals in matrix form we use $e'e$ (where $e'$ is the transpose of $e$) instead of $e^2$?

In matrix notation, the residuals are typically written as an $n$ length column vector $\mathbf{e}$ where $n$ is the number of observations.

$$\mathbf{e} = \left[ \begin{array}{c} e_1 \\ e_2 \\ \ldots \\ e_n \end{array} \right]$$

Then:

$$\mathbf{e}'\mathbf{e} = \left[ \begin{array}{cccc} e_1 & e_2 & \ldots & e_n \end{array} \right] \left[ \begin{array}{c} e_1 \\ e_2 \\ \ldots \\ e_n \end{array} \right] = \sum_i e_i^2$$

In contrast, $\mathbf{e}\mathbf{e}$ is rather sloppy (arguably downright wrong) since you can't multiply an $n$ by 1 matrix by another $n$ by 1 matrix.

Notation note: I personally like the engineering convention that bold lowercase letters denote vectors and normal lowercase letters denote scalars; this notation reduces confusion about what's a vector and what's a scalar.

I understand now. It is because you want to find a scalar answer for the sum of squared residuals.

• so, would you like to remove the question? – Haitao Du Aug 9 '16 at 14:13
• @hxd1011 It's perfectly acceptable for a user to ask and answer their own question. The question can remain as it is. – Sycorax says Reinstate Monica Aug 9 '16 at 14:56
• Welcome to Cross Validated! You might want to expand your answer a little for those who are still confused. – Scortchi - Reinstate Monica Aug 9 '16 at 15:00