Linear Algebra
1 Vectors
Column vectors are the default convention in these notes and in most statistics textbooks. They are also called \(p \times 1\) matrices.
The transpose operation converts a column vector to a row vector, or more generally, swaps the rows and columns of a matrix (Definition 12).
The dot product \(\tilde{x}\cdot \tilde{y}\) is a linear combination of the entries of \(\tilde{y}\), with coefficients \(x_1, \ldots, x_p\). It is also the standard inner product on \(\mathbb{R}^p\); “inner product” is the general notion, of which the dot product is one example.
See also the definitions in
“Linear combination” can also refer to weighted sums of vectors, or in other words matrix-vector multiplication.
The dot-product has a different generalization for two matrices; see wikipedia for more.
Proof. \[ \begin{aligned} \tilde{x}\cdot \tilde{y} &= \sum_{i=1}^px_i y_i && \text{(definition of the dot product)} \\ &= \sum_{i=1}^py_i x_i && \text{(products of numbers are symmetric)} \\ &= \tilde{y}\cdot \tilde{x} && \text{(definition of the dot product)} \end{aligned} \]
1.1 Special vectors
The zero vector is the additive identity for vector addition: \(\tilde{x}+ \tilde{0}= \tilde{x}\) for any vector \(\tilde{x}\) of the same length.
The dot product \(\tilde{1} \cdot \tilde{x}= \sum_{i=1}^p x_i\) is the sum of all entries of \(\tilde{x}\).
They are also called unit vectors or standard basis vectors.
Proof. Writing the dot product componentwise:
\[ \begin{aligned} \tilde{e}_j \cdot \tilde{x} &= \sum_{i=1}^{p} (\tilde{e}_j)_i\, x_i && \text{(definition of the dot product)} \\&= \sum_{i=1}^{p} \begin{cases} 1 \cdot x_i & \text{if } i = j \\ 0 \cdot x_i & \text{if } i \neq j \end{cases} && \text{(definition of } \tilde{e}_j \text{)} \\&= x_j && \text{(only the } i = j \text{ term is nonzero)} \end{aligned} \]
1.2 Orthogonality
Orthogonality generalizes the geometric notion of perpendicularity to arbitrary dimensions.
The indicator vectors \(\tilde{e}_1, \tilde{e}_2, \ldots, \tilde{e}_p\) (Definition 7) form an orthonormal set.
Hutchinson’s Linear Function Basics (24 min) covers dot products and the Euclidean norm, and goes on to hyperplanes and level sets (Hutchinson, n.d.). The login for the video site is posted on Canvas.
2 Matrices
The entry in row \(i\) and column \(j\) is denoted \(a_{ij}\) or \((\mathbf{A})_{ij}\). A column vector of length \(p\) is a special case: a \(p \times 1\) matrix. A row vector of length \(p\) is a \(1 \times p\) matrix.
2.1 Matrix transpose
2.2 Matrix addition
2.3 Scalar multiplication
2.4 Matrix multiplication
Matrix multiplication is only defined when the number of columns in \(\mathbf{A}\) equals the number of rows in \(\mathbf{B}\).
Matrix multiplication is not commutative in general: \(\mathbf{A}\mathbf{B} \neq \mathbf{B}\mathbf{A}\).
Proof. Entry \((i, j)\) of each side, from Definition 16:
\[ \begin{aligned} \mathopen{}\left[(\mathbf{A}\mathbf{B})\mathbf{C}\right]\mathclose{}_{ij} &= \sum_{t=1}^{l} (\mathbf{A}\mathbf{B})_{it}\, c_{tj} && \text{(definition of } (\mathbf{A}\mathbf{B})\mathbf{C} \text{)} \\ &= \sum_{t=1}^{l} \mathopen{}\left(\sum_{s=1}^{k} a_{is}\, b_{st}\right)\mathclose{} c_{tj} && \text{(definition of } \mathbf{A}\mathbf{B} \text{)} \\ &= \sum_{s=1}^{k} a_{is} \mathopen{}\left(\sum_{t=1}^{l} b_{st}\, c_{tj}\right)\mathclose{} && \text{(distribute and swap the finite sums)} \\ &= \sum_{s=1}^{k} a_{is}\, (\mathbf{B}\mathbf{C})_{sj} && \text{(definition of } \mathbf{B}\mathbf{C} \text{)} \\ &= \mathopen{}\left[\mathbf{A}(\mathbf{B}\mathbf{C})\right]\mathclose{}_{ij} && \text{(definition of } \mathbf{A}(\mathbf{B}\mathbf{C}) \text{)} \end{aligned} \]
2.5 Matrix-vector multiplication
Matrix-vector multiplication is a generalization of the dot product. Each entry of the result is a dot product of a row of \(\mathbf{A}\) with the vector \(\tilde{x}\).
2.6 Transposes of sums and products
Proof. Entry \((i, j)\) of each side:
\[ \begin{aligned} \mathopen{}\left[{(\mathbf{A} + \mathbf{B})}^{\top}\right]\mathclose{}_{ij} &= (\mathbf{A} + \mathbf{B})_{ji} && \text{(definition of the transpose)} \\ &= a_{ji} + b_{ji} && \text{(definition of matrix addition)} \\ &= ({\mathbf{A}}^{\top})_{ij} + ({\mathbf{B}}^{\top})_{ij} && \text{(definition of the transpose)} \\ &= \mathopen{}\left[{\mathbf{A}}^{\top} + {\mathbf{B}}^{\top}\right]\mathclose{}_{ij} && \text{(definition of matrix addition)} \end{aligned} \]
Proof. Entry \((i, j)\) of each side:
\[ \begin{aligned} \mathopen{}\left[{(\mathbf{A}\mathbf{B})}^{\top}\right]\mathclose{}_{ij} &= (\mathbf{A}\mathbf{B})_{ji} && \text{(definition of the transpose)} \\ &= \sum_{s=1}^{k} a_{js}\, b_{si} && \text{(definition of matrix multiplication)} \\ &= \sum_{s=1}^{k} ({\mathbf{B}}^{\top})_{is}\, ({\mathbf{A}}^{\top})_{sj} && \text{(definition of the transpose; reorder each product)} \\ &= \mathopen{}\left[{\mathbf{B}}^{\top}\,{\mathbf{A}}^{\top}\right]\mathclose{}_{ij} && \text{(definition of matrix multiplication)} \end{aligned} \]
The order of the factors reverses when transposing a product.
2.7 Rank
An \(n \times p\) matrix whose rank is \(p\), so that all of its columns are linearly independent, is said to have full column rank; that can only happen when \(p \le n\), because more than \(n\) vectors of length \(n\) are never linearly independent.
2.8 Outer product
The dot product \({\tilde{u}}^{\top}\tilde{v}\) (Example 4) needs two vectors of the same length and gives a number. The outer product \(\tilde{u}\,{\tilde{v}}^{\top}\) takes vectors of any two lengths and gives a matrix (Banerjee and Roy 2014, chap. 1, p. 11).
Proof. Column \(j\) of \(\tilde{u}\,{\tilde{v}}^{\top}\) has entries \(u_1 v_j, \ldots, u_m v_j\), so it is the vector \(v_j \tilde{u}\).
The rank is at least one. Because \(\tilde{v} \neq \tilde{0}\), some entry \(v_j\) is nonzero. Then column \(j\), \(v_j \tilde{u}\), is a nonzero vector, and a single nonzero vector is linearly independent (Definition 18): \(c\,(v_j \tilde{u}) = \tilde{0}\) forces \(c = 0\).
The rank is at most one. Take any two columns \(j \neq k\). If \(v_j = v_k = 0\), both columns are \(\tilde{0}\), and \(1 \cdot(v_j \tilde{u}) + 1 \cdot(v_k \tilde{u}) = \tilde{0}\). Otherwise, use the coefficients \(c_j = v_k\) and \(c_k = -v_j\), which are not both zero:
\[ \begin{aligned} v_k\,(v_j \tilde{u}) - v_j\,(v_k \tilde{u}) &= (v_k v_j - v_j v_k)\,\tilde{u} && \text{(collect the scalar multiples of } \tilde{u} \text{)} \\ &= 0 \cdot\tilde{u} && \text{(multiplication of numbers is commutative)} \\ &= \tilde{0} && \text{(a zero multiple of a vector is } \tilde{0}\text{)} \end{aligned} \]
Either way, every pair of columns has a combination with coefficients that are not all zero and that equals \(\tilde{0}\). Now take any set of two or more columns. It contains a pair \(j \neq k\). Use that pair’s coefficients for columns \(j\) and \(k\), and the coefficient \(0\) for every other column in the set. This combination equals \(\tilde{0}\), and its coefficients are not all zero, so the set is not linearly independent (Definition 18). The largest linearly independent set of columns therefore has one column.
3 Special Matrices
See also Definition 13 for the zero matrix.
Covariance matrices and information matrices are symmetric.
Diagonal matrices are denoted \(\mathbf{D} = \text{diag}(d_1, d_2, \ldots, d_p)\), where \(d_1, \ldots, d_p\) are the diagonal entries.
Proof. Multiply \(\mathbf{A}\mathbf{B}\) by the candidate inverse on the right:
\[ \begin{aligned} (\mathbf{A}\mathbf{B})(\mathbf{B}^{-1}\mathbf{A}^{-1}) &= \mathbf{A}(\mathbf{B}\mathbf{B}^{-1})\mathbf{A}^{-1} && \text{(matrix multiplication is associative)} \\ &= \mathbf{A}\,\mathbf{I}_p\,\mathbf{A}^{-1} && \text{(definition of } \mathbf{B}^{-1} \text{)} \\ &= \mathbf{A}\mathbf{A}^{-1} && \text{(identity matrix)} \\ &= \mathbf{I}_p && \text{(definition of } \mathbf{A}^{-1} \text{)} \end{aligned} \]
and on the left:
\[ \begin{aligned} (\mathbf{B}^{-1}\mathbf{A}^{-1})(\mathbf{A}\mathbf{B}) &= \mathbf{B}^{-1}(\mathbf{A}^{-1}\mathbf{A})\mathbf{B} && \text{(matrix multiplication is associative)} \\ &= \mathbf{B}^{-1}\,\mathbf{I}_p\,\mathbf{B} && \text{(definition of } \mathbf{A}^{-1} \text{)} \\ &= \mathbf{B}^{-1}\mathbf{B} && \text{(identity matrix)} \\ &= \mathbf{I}_p && \text{(definition of } \mathbf{B}^{-1} \text{)} \end{aligned} \]
So \(\mathbf{B}^{-1}\mathbf{A}^{-1}\) satisfies Definition 27 for \(\mathbf{A}\mathbf{B}\). The steps use Theorem 7 and Theorem 12.
Proof. Multiply \({\mathbf{A}}^{\top}\) by the candidate inverse on each side:
\[ \begin{aligned} {\mathbf{A}}^{\top}\,{\mathopen{}\left(\mathbf{A}^{-1}\right)\mathclose{}}^{\top} &= {\mathopen{}\left(\mathbf{A}^{-1}\mathbf{A}\right)\mathclose{}}^{\top} && \text{(transpose of a product)} \\ &= {\mathbf{I}_p}^{\top} && \text{(definition of } \mathbf{A}^{-1} \text{)} \\ &= \mathbf{I}_p && \text{(} \mathbf{I}_p \text{ is symmetric)} \end{aligned} \]
\[ \begin{aligned} {\mathopen{}\left(\mathbf{A}^{-1}\right)\mathclose{}}^{\top}\,{\mathbf{A}}^{\top} &= {\mathopen{}\left(\mathbf{A}\mathbf{A}^{-1}\right)\mathclose{}}^{\top} && \text{(transpose of a product)} \\ &= {\mathbf{I}_p}^{\top} && \text{(definition of } \mathbf{A}^{-1} \text{)} \\ &= \mathbf{I}_p && \text{(} \mathbf{I}_p \text{ is symmetric)} \end{aligned} \]
So \({\mathopen{}\left(\mathbf{A}^{-1}\right)\mathclose{}}^{\top}\) satisfies Definition 27 for \({\mathbf{A}}^{\top}\). The first step of each display is Theorem 10.
Proof. \[ \begin{aligned} {\mathopen{}\left(\mathbf{A}^{-1}\right)\mathclose{}}^{\top} &= \mathopen{}\left({\mathbf{A}}^{\top}\right)^{-1}\mathclose{} && \text{(inverse of a transpose)} \\ &= \mathbf{A}^{-1} && \text{(} \mathbf{A} \text{ is symmetric)} \end{aligned} \]
The first step is Theorem 14.
Any idempotent matrix is called a projection matrix; an idempotent matrix that is not symmetric is an oblique projection. Regression texts often say “projection matrix” when they mean an orthogonal one. In these notes, “projection matrix” always means an orthogonal projection matrix in the sense of Definition 30.
Proof. We verify symmetry and idempotency.
Symmetry: \[{(\mathbf{I} - \mathbf{P})}^{\top} = {\mathbf{I}}^{\top} - {\mathbf{P}}^{\top} = \mathbf{I} - \mathbf{P}\]
Idempotency: \[\begin{aligned} (\mathbf{I} - \mathbf{P})^2 &= (\mathbf{I} - \mathbf{P})(\mathbf{I} - \mathbf{P}) \\ &= \mathbf{I} - \mathbf{P} - \mathbf{P} + \mathbf{P}^2 \\ &= \mathbf{I} - \mathbf{P} - \mathbf{P} + \mathbf{P} \\ &= \mathbf{I} - \mathbf{P} \end{aligned}\]
Proof. \[\begin{aligned} {(\mathbf{P}\tilde{v})}^{\top}\,(\mathbf{I} - \mathbf{P})\tilde{v} &= {\tilde{v}}^{\top}\,{\mathbf{P}}^{\top}\,(\mathbf{I} - \mathbf{P})\tilde{v} \\ &= {\tilde{v}}^{\top}\,\mathbf{P}\,(\mathbf{I} - \mathbf{P})\tilde{v} \\ &= {\tilde{v}}^{\top}\,(\mathbf{P} - \mathbf{P}^2)\tilde{v} \\ &= {\tilde{v}}^{\top}\,(\mathbf{P} - \mathbf{P})\tilde{v} \\ &= {\tilde{v}}^{\top}\,\mathbf{0}\,\tilde{v} \\ &= 0 \end{aligned}\]
where the second line uses symmetry (\({\mathbf{P}}^{\top} = \mathbf{P}\)) and the fourth line uses idempotency (\(\mathbf{P}^2 = \mathbf{P}\)).
Entry \((i, j)\) of \({\mathbf{Q}}^{\top}\mathbf{Q}\) is the dot product of column \(i\) and column \(j\) of \(\mathbf{Q}\), so \({\mathbf{Q}}^{\top}\mathbf{Q} = \mathbf{I}_p\) says that the columns of \(\mathbf{Q}\) are orthonormal (Definition 10). For a square matrix, \({\mathbf{Q}}^{\top}\mathbf{Q} = \mathbf{I}_p\) also implies \(\mathbf{Q}{\mathbf{Q}}^{\top} = \mathbf{I}_p\), so \(\mathbf{Q}^{-1} = {\mathbf{Q}}^{\top}\) (Definition 27) (Banerjee and Roy 2014, chap. 8, Theorem 8.1 and Definition 8.1, p. 209).
Proof. \[ \begin{aligned} \mathopen{}\left\lVert\mathbf{Q}\tilde{x}\right\rVert\mathclose{}^2 &= (\mathbf{Q}\tilde{x}) \cdot (\mathbf{Q}\tilde{x}) && \text{(definition of the Euclidean norm)} \\ &= {(\mathbf{Q}\tilde{x})}^{\top}\,(\mathbf{Q}\tilde{x}) && \text{(dot product as a matrix product)} \\ &= {\tilde{x}}^{\top}\,{\mathbf{Q}}^{\top}\,(\mathbf{Q}\tilde{x}) && \text{(transpose of a product)} \\ &= {\tilde{x}}^{\top}\,({\mathbf{Q}}^{\top}\mathbf{Q})\,\tilde{x} && \text{(regroup; matrix multiplication is associative)} \\ &= {\tilde{x}}^{\top}\,\mathbf{I}_p\,\tilde{x} && \text{(definition of an orthogonal matrix)} \\ &= {\tilde{x}}^{\top}\,\tilde{x} && \text{(identity matrix)} \\ &= \mathopen{}\left\lVert\tilde{x}\right\rVert\mathclose{}^2 && \text{(definition of the Euclidean norm)} \end{aligned} \]
Both norms are nonnegative square roots, so equal squares give \(\mathopen{}\left\lVert\mathbf{Q}\tilde{x}\right\rVert\mathclose{} = \mathopen{}\left\lVert\tilde{x}\right\rVert\mathclose{}\). The second step is Example 4, the third is Theorem 10, and the fourth is Theorem 7.
4 Quadratic Forms
Quadratic forms are the matrix generalizations of the scalar expression \(c x^2\). They occur frequently in statistics:
- The residual sum of squares in linear regression (see Vector Calculus) is a quadratic form.
- The variance of a linear combination of estimates (see Inference about Gaussian Linear Regression Models) is a quadratic form: \(\operatorname{Var}\mathopen{}\left({\tilde{x}}^{\top}\hat{\tilde{\beta}}\right)\mathclose{} = {\tilde{x}}^{\top}\,\operatorname{Var}\mathopen{}\left(\hat{\tilde{\beta}}\right)\mathclose{}\,\tilde{x}\).
Proof. The quadratic form \({\tilde{x}}^{\top}\mathbf{S}\tilde{x}\) is a \(1 \times 1\) matrix, so it equals its own transpose:
\[ \begin{aligned} {\tilde{x}}^{\top}\mathbf{S}\tilde{x} &= {\mathopen{}\left({\tilde{x}}^{\top}\mathbf{S}\tilde{x}\right)\mathclose{}}^{\top} && \text{(a } 1 \times 1 \text{ matrix is symmetric)} \\ &= {\tilde{x}}^{\top}\,{\mathbf{S}}^{\top}\,{\mathopen{}\left({\tilde{x}}^{\top}\right)\mathclose{}}^{\top} && \text{(transpose of a product, twice)} \\ &= {\tilde{x}}^{\top}\,{\mathbf{S}}^{\top}\,\tilde{x} && \text{(transposing twice changes nothing)} \end{aligned} \]
Averaging the two expressions for \({\tilde{x}}^{\top}\mathbf{S}\tilde{x}\):
\[ \begin{aligned} {\tilde{x}}^{\top}\mathbf{S}\tilde{x} &= \frac{1}{2}\mathopen{}\left({\tilde{x}}^{\top}\mathbf{S}\tilde{x}+ {\tilde{x}}^{\top}\,{\mathbf{S}}^{\top}\,\tilde{x}\right)\mathclose{} && \text{(average of two equal numbers)} \\ &= \frac{1}{2}\,{\tilde{x}}^{\top}\mathopen{}\left(\mathbf{S} + {\mathbf{S}}^{\top}\right)\mathclose{}\tilde{x} && \text{(distributive law)} \\ &= {\tilde{x}}^{\top}\left(\frac{1}{2}(\mathbf{S}+{\mathbf{S}}^{\top})\right)\tilde{x} && \text{(move the scalar } \tfrac{1}{2} \text{ inside)} \end{aligned} \]
The distributive step is Theorem 8, and the transpose step is Theorem 10.
5 Trace and Matrix Inner Product
Proof. \[ \begin{aligned} \operatorname{tr}(\mathbf{A}\mathbf{B}) &= \sum_{i=1}^{m} (\mathbf{A}\mathbf{B})_{ii} && \text{(definition of the trace)} \\ &= \sum_{i=1}^{m} \sum_{s=1}^{n} a_{is}\, b_{si} && \text{(definition of matrix multiplication)} \\ &= \sum_{s=1}^{n} \sum_{i=1}^{m} a_{is}\, b_{si} && \text{(swap the order of two finite sums)} \\ &= \sum_{s=1}^{n} \sum_{i=1}^{m} b_{si}\, a_{is} && \text{(multiplication of numbers is commutative)} \\ &= \sum_{s=1}^{n} (\mathbf{B}\mathbf{A})_{ss} && \text{(definition of matrix multiplication)} \\ &= \operatorname{tr}(\mathbf{B}\mathbf{A}) && \text{(definition of the trace)} \end{aligned} \]
\(\mathbf{A}\mathbf{B}\) and \(\mathbf{B}\mathbf{A}\) need not have the same size, so Theorem 19 can equate the traces of an \(m \times m\) matrix and an \(n \times n\) matrix. Applying it to \(\mathbf{A}\) and the product \(\mathbf{B}\mathbf{C}\) moves the last factor of a triple product to the front: \(\operatorname{tr}(\mathbf{A}\mathbf{B}\mathbf{C}) = \operatorname{tr}(\mathbf{C}\mathbf{A}\mathbf{B})\) (Banerjee and Roy 2014, chap. 1, Theorem 1.5 and eq. 1.17, p. 19).
Banerjee and Roy (2014, chap. 15, eq. 15.7, p. 491) defines the same inner product on \(n \times p\) matrices with the trace.
Proof. \[ \begin{aligned} \left\langle \mathbf{A}, \mathbf{B} \right\rangle &= \operatorname{tr}({\mathbf{A}}^{\top}\mathbf{B}) && \text{(definition of the inner product)} \\ &= \sum_{j=1}^{p} ({\mathbf{A}}^{\top}\mathbf{B})_{jj} && \text{(definition of the trace)} \\ &= \sum_{j=1}^{p} \sum_{i=1}^{n} ({\mathbf{A}}^{\top})_{ji}\, b_{ij} && \text{(definition of matrix multiplication)} \\ &= \sum_{j=1}^{p} \sum_{i=1}^{n} a_{ij}\, b_{ij} && \text{(definition of the transpose)} \\ &= \sum_{i=1}^{n} \sum_{j=1}^{p} a_{ij}\, b_{ij} && \text{(swap the order of two finite sums)} \end{aligned} \]
Theorem 20 says that the matrix inner product is the dot product (Definition 4) of the two matrices’ entries, each listed as one vector of length \(np\).
By Theorem 20, \(\mathopen{}\left\lVert\mathbf{A}\right\rVert\mathclose{}_F^2 = \sum_{i=1}^{n} \sum_{j=1}^{p} a_{ij}^2\), a sum of squares, so the square root is always defined. \(\mathopen{}\left\lVert\mathbf{A}\right\rVert\mathclose{}_F\) is the Euclidean norm (Definition 9) of the entries of \(\mathbf{A}\), listed as one vector of length \(np\) (Banerjee and Roy 2014, chap. 15, Definition 15.4, p. 492).
6 Matrix Decompositions
Multiplying by \(\mathbf{A}\) rescales an eigenvector by \(\lambda\) and does not change the line it lies on. Any nonzero multiple \(c\,\tilde{v}\) of an eigenvector is also an eigenvector for the same \(\lambda\), because \(\mathbf{A}(c\,\tilde{v}) = c\,\mathbf{A}\tilde{v} = c\,\lambda\tilde{v} = \lambda\,(c\,\tilde{v})\).
These notes take \(\lambda\) and \(\tilde{v}\) to be real. Banerjee and Roy (2014, chap. 11, Definition 11.1, pp. 312-313) also allows complex eigenvalues and eigenvectors, because some real matrices, such as a rotation by \(90\) degrees, have no real eigenvalues (Banerjee and Roy 2014, chap. 11, Example 11.2, p. 312).
The proof, by induction on \(p\), is outside the scope of these notes; see Banerjee and Roy (2014, chap. 11, Theorem 11.27, p. 349), which states the result in the equivalent form \({\mathbf{Q}}^{\top}\mathbf{A}\mathbf{Q} = \mathbf{\Lambda}\). The two forms are equivalent because \({\mathbf{Q}}^{\top}\mathbf{Q} = \mathbf{Q}{\mathbf{Q}}^{\top} = \mathbf{I}_p\): multiply \(\mathbf{A} = \mathbf{Q}\mathbf{\Lambda}{\mathbf{Q}}^{\top}\) by \({\mathbf{Q}}^{\top}\) on the left and by \(\mathbf{Q}\) on the right.
An eigendecomposition is not unique. For example, reordering the eigenvalues on the diagonal of \(\mathbf{\Lambda}\), and the columns of \(\mathbf{Q}\) with them, gives another one, and so does multiplying a column of \(\mathbf{Q}\) by \(-1\).
The proof is outside the scope of these notes; see Banerjee and Roy (2014, chap. 12, Theorem 12.1, p. 373). Unlike the spectral theorem (Theorem 21), Theorem 22 applies to every real matrix, including one that is not square or not symmetric.
An SVD is not unique (Banerjee and Roy 2014, chap. 12, Examples 12.2 and 12.3, p. 378). For example, for any \(i \le r\), multiplying column \(i\) of both \(\mathbf{U}\) and \(\mathbf{V}\) by \(-1\) gives another one. The singular values do not depend on which SVD is chosen (Banerjee and Roy 2014, chap. 12, pp. 371 and 378).
Some texts, and R’s svd(), also count \(\min(n, p) - r\) singular values equal to \(0\), so that every \(n \times p\) matrix has \(\min(n, p)\) singular values.
Proof. Symmetry.
\[ \begin{aligned} {\mathopen{}\left({\mathbf{A}}^{\top}\mathbf{A}\right)\mathclose{}}^{\top} &= {\mathbf{A}}^{\top}\,{\mathopen{}\left({\mathbf{A}}^{\top}\right)\mathclose{}}^{\top} && \text{(transpose of a product)} \\ &= {\mathbf{A}}^{\top}\mathbf{A} && \text{(transposing twice changes nothing)} \end{aligned} \]
The first step is Theorem 10, and the second follows from Definition 12, which swaps rows and columns, so swapping them again restores \(\mathbf{A}\).
The factorization.
\[ \begin{aligned} {\mathbf{A}}^{\top}\mathbf{A} &= {\mathopen{}\left(\mathbf{U}\mathbf{D}{\mathbf{V}}^{\top}\right)\mathclose{}}^{\top}\,\mathbf{U}\mathbf{D}{\mathbf{V}}^{\top} && \text{(substitute the SVD)} \\ &= {\mathopen{}\left(\mathbf{D}{\mathbf{V}}^{\top}\right)\mathclose{}}^{\top}\,{\mathbf{U}}^{\top}\,\mathbf{U}\mathbf{D}{\mathbf{V}}^{\top} && \text{(transpose of the product of } \mathbf{U} \text{ and } \mathbf{D}{\mathbf{V}}^{\top} \text{)} \\ &= {\mathopen{}\left({\mathbf{V}}^{\top}\right)\mathclose{}}^{\top}\,{\mathbf{D}}^{\top}\,{\mathbf{U}}^{\top}\,\mathbf{U}\mathbf{D}{\mathbf{V}}^{\top} && \text{(transpose of the product of } \mathbf{D} \text{ and } {\mathbf{V}}^{\top} \text{)} \\ &= \mathbf{V}\,{\mathbf{D}}^{\top}\,{\mathbf{U}}^{\top}\,\mathbf{U}\mathbf{D}{\mathbf{V}}^{\top} && \text{(transposing twice changes nothing)} \\ &= \mathbf{V}\,{\mathbf{D}}^{\top}\,\mathopen{}\left({\mathbf{U}}^{\top}\mathbf{U}\right)\mathclose{}\,\mathbf{D}{\mathbf{V}}^{\top} && \text{(regroup; matrix multiplication is associative)} \\ &= \mathbf{V}\,{\mathbf{D}}^{\top}\,\mathbf{I}_n\,\mathbf{D}{\mathbf{V}}^{\top} && \text{(} \mathbf{U} \text{ is orthogonal)} \\ &= \mathbf{V}\,\mathopen{}\left({\mathbf{D}}^{\top}\mathbf{D}\right)\mathclose{}\,{\mathbf{V}}^{\top} && \text{(identity matrix)} \\ &= \mathbf{V}\mathbf{\Lambda}{\mathbf{V}}^{\top} && \text{(definition of } \mathbf{\Lambda} \text{)} \end{aligned} \]
The entries of \(\mathbf{\Lambda}\). Write \(\lambda_{ij}\) for entry \((i, j)\) of \(\mathbf{\Lambda}\), so \(\lambda_i = \lambda_{ii}\). Only the entries \(d_{kk}\) with \(k \le r\) of \(\mathbf{D}\) can be nonzero.
\[ \begin{aligned} \lambda_{ij} &= \sum_{k=1}^{n} ({\mathbf{D}}^{\top})_{ik}\, d_{kj} && \text{(definition of matrix multiplication)} \\ &= \sum_{k=1}^{n} d_{ki}\, d_{kj} && \text{(definition of the transpose)} \end{aligned} \]
The term for \(k\) is nonzero only if \(k = i \le r\) and \(k = j\). So \(\lambda_{ij} = 0\) when \(i \neq j\). On the diagonal, only the term \(k = i\) can be nonzero, and for \(i \le r\)
\[ \begin{aligned} \lambda_i &= \lambda_{ii} && \text{(notation)} \\ &= d_{ii}\, d_{ii} && \text{(the only term that can be nonzero)} \\ &= \sigma_i \cdot\sigma_i && \text{(definition of } \mathbf{D} \text{)} \\ &= \sigma_i^2 && \text{(notation for a square)} \end{aligned} \]
For \(i > r\), every term is \(0\), so \(\lambda_i = 0\).
The eigenvectors. Write \(\tilde{v}_i\) for column \(i\) of \(\mathbf{V}\), and \(\tilde{e}_i\) for the indicator vector (Definition 7) of length \(p\). Column \(i\) of \({\mathbf{V}}^{\top}\mathbf{V} = \mathbf{I}_p\) says \({\mathbf{V}}^{\top}\tilde{v}_i = \tilde{e}_i\). Then
\[ \begin{aligned} {\mathbf{A}}^{\top}\mathbf{A}\,\tilde{v}_i &= \mathbf{V}\mathbf{\Lambda}\,{\mathbf{V}}^{\top}\tilde{v}_i && \text{(the factorization)} \\ &= \mathbf{V}\mathbf{\Lambda}\,\tilde{e}_i && \text{(} {\mathbf{V}}^{\top}\tilde{v}_i = \tilde{e}_i \text{)} \\ &= \mathbf{V}\,(\lambda_i\,\tilde{e}_i) && \text{(column } i \text{ of the diagonal matrix } \mathbf{\Lambda} \text{)} \\ &= \lambda_i\,\mathbf{V}\tilde{e}_i && \text{(move the scalar } \lambda_i \text{ to the front)} \\ &= \lambda_i\,\tilde{v}_i && \text{(} \mathbf{V}\tilde{e}_i \text{ is column } i \text{ of } \mathbf{V} \text{)} \end{aligned} \]
and \(\tilde{v}_i \neq \tilde{0}\) because it has norm \(1\).
Theorem 23 matches Banerjee and Roy (2014, chap. 12, pp. 372-373), which constructs an SVD from a spectral decomposition of \({\mathbf{A}}^{\top}\mathbf{A}\) and sets \(\sigma_i = \sqrt{\lambda_i}\).
7 Definite Matrices
Proof. For any vector \(\tilde{x}\) of length \(p\), let \(\tilde{y} = {\mathbf{Q}}^{\top}\tilde{x}\). Then:
\[ \begin{aligned} {\tilde{x}}^{\top}\mathbf{A}\tilde{x} &= {\tilde{x}}^{\top}\mathbf{Q}\mathbf{\Lambda}{\mathbf{Q}}^{\top}\tilde{x} && \text{(substitute the eigendecomposition)} \\ &= {\mathopen{}\left({\mathbf{Q}}^{\top}\tilde{x}\right)\mathclose{}}^{\top}\mathbf{\Lambda}\mathopen{}\left({\mathbf{Q}}^{\top}\tilde{x}\right)\mathclose{} && \text{(transpose of a product)} \\ &= {\tilde{y}}^{\top}\mathbf{\Lambda}\tilde{y} && \text{(definition of } \tilde{y} \text{)} \\ &= \sum_{i=1}^p \lambda_i y_i^2 && \text{(} \mathbf{\Lambda} \text{ is diagonal)} \end{aligned} \]
The second step is Theorem 10. Also, \(\tilde{x}= \tilde{0}\) exactly when \(\tilde{y} = \tilde{0}\): \(\mathbf{Q}{\mathbf{Q}}^{\top} = \mathbf{I}_p\) for an orthogonal matrix (Definition 31), so \(\tilde{x}= \mathbf{Q}\tilde{y}\).
If every \(\lambda_i \ge 0\), then every term \(\lambda_i y_i^2 \ge 0\), so \({\tilde{x}}^{\top}\mathbf{A}\tilde{x}\ge 0\). If every \(\lambda_i > 0\) and \(\tilde{x}\neq \tilde{0}\), then some \(y_i \neq 0\), so at least one term is positive and the rest are non-negative, and \({\tilde{x}}^{\top}\mathbf{A}\tilde{x}> 0\).
Conversely, take \(\tilde{x}= \tilde{q}_i\), column \(i\) of \(\mathbf{Q}\), which is not \(\tilde{0}\) because it has norm 1. Then \(\tilde{y} = {\mathbf{Q}}^{\top}\tilde{q}_i\) is column \(i\) of \({\mathbf{Q}}^{\top}\mathbf{Q} = \mathbf{I}_p\), so \(y_i = 1\) and every other entry of \(\tilde{y}\) is \(0\), and the display gives \({\tilde{q}_i}^{\top}\mathbf{A}\tilde{q}_i = \lambda_i\). So if \(\mathbf{A}\) is positive semidefinite, \(\lambda_i \ge 0\), and if \(\mathbf{A}\) is positive definite, \(\lambda_i > 0\).
Proof. By Theorem 24, every \(\lambda_i > 0\), so \(\mathbf{\Lambda}^{-1}\) is well defined, and multiplying the two diagonal matrices entry by entry gives \(\mathbf{\Lambda}\mathbf{\Lambda}^{-1} = \mathbf{\Lambda}^{-1}\mathbf{\Lambda} = \mathbf{I}_p\). Write \(\mathbf{B} = \mathbf{Q}\mathbf{\Lambda}^{-1}{\mathbf{Q}}^{\top}\). Then:
\[ \begin{aligned} \mathbf{A}\mathbf{B} &= \mathbf{Q}\mathbf{\Lambda}{\mathbf{Q}}^{\top}\mathbf{Q}\mathbf{\Lambda}^{-1}{\mathbf{Q}}^{\top} && \text{(substitute)} \\ &= \mathbf{Q}\mathbf{\Lambda}\mathbf{I}_p\mathbf{\Lambda}^{-1}{\mathbf{Q}}^{\top} && \text{(} {\mathbf{Q}}^{\top}\mathbf{Q} = \mathbf{I}_p \text{)} \\ &= \mathbf{Q}\mathbf{\Lambda}\mathbf{\Lambda}^{-1}{\mathbf{Q}}^{\top} && \text{(identity matrix)} \\ &= \mathbf{Q}{\mathbf{Q}}^{\top} && \text{(} \mathbf{\Lambda}\mathbf{\Lambda}^{-1} = \mathbf{I}_p \text{)} \\ &= \mathbf{I}_p && \text{(} \mathbf{Q} \text{ is orthogonal)} \end{aligned} \]
The same steps, with \(\mathbf{\Lambda}^{-1}\) and \(\mathbf{\Lambda}\) swapped, give \(\mathbf{B}\mathbf{A} = \mathbf{I}_p\), so \(\mathbf{B} = \mathbf{A}^{-1}\) (Definition 27). The steps with \(\mathbf{Q}\) use Definition 31, whose remark records that \(\mathbf{Q}{\mathbf{Q}}^{\top} = \mathbf{I}_p\) too, and the identity step uses Theorem 12.
\(\mathbf{A}^{-1}\) is symmetric by Corollary 1. For \(\tilde{x}\neq \tilde{0}\), let \(\tilde{y} = {\mathbf{Q}}^{\top}\tilde{x}\), which is not \(\tilde{0}\) because \(\tilde{x}= \mathbf{Q}\tilde{y}\). As in the proof of Theorem 24:
\[ \begin{aligned} {\tilde{x}}^{\top}\mathbf{A}^{-1}\tilde{x} &= {\tilde{y}}^{\top}\mathbf{\Lambda}^{-1}\tilde{y} && \text{(substitute } \mathbf{A}^{-1} = \mathbf{Q}\mathbf{\Lambda}^{-1}{\mathbf{Q}}^{\top} \text{)} \\ &= \sum_{i=1}^p \frac{y_i^2}{\lambda_i} && \text{(} \mathbf{\Lambda}^{-1} \text{ is diagonal)} \\ &> 0 && \text{(each } \lambda_i > 0 \text{, and some } y_i \neq 0 \text{)} \end{aligned} \]
So \(\mathbf{A}^{-1}\) is positive definite.
8 Determinants
Proof. By induction on \(p\). For \(p = 1\), the matrix is \(\begin{bmatrix} d_1 \end{bmatrix}\), and its determinant is \(d_1\) by definition.
For \(p \ge 2\), suppose the result holds for \((p-1) \times (p-1)\) diagonal matrices, and let \(\mathbf{D}\) be \(p \times p\) and diagonal. Row 1 of \(\mathbf{D}\) is \((d_1, 0, \ldots, 0)\), so only the \(j = 1\) term of the definition can be nonzero, and deleting row 1 and column 1 of \(\mathbf{D}\) leaves the diagonal matrix with diagonal entries \(d_2, \ldots, d_p\):
\[ \begin{aligned} \det(\mathbf{D}) &= (-1)^{1+1}\, d_1 \det\mathopen{}\left(\mathbf{D}_{(11)}\right)\mathclose{} + \sum_{j=2}^p (-1)^{1+j} \cdot 0 \cdot\det\mathopen{}\left(\mathbf{D}_{(1j)}\right)\mathclose{} && \text{(definition)} \\ &= d_1 \det\mathopen{}\left(\mathbf{D}_{(11)}\right)\mathclose{} && \text{(drop the zero terms)} \\ &= d_1 \prod_{i=2}^p d_i && \text{(induction hypothesis)} \\ &= \prod_{i=1}^p d_i && \text{(combine)} \end{aligned} \]
Proof. First, \(\det({\mathbf{Q}}^{\top})\det(\mathbf{Q}) = 1\):
\[ \begin{aligned} \det({\mathbf{Q}}^{\top})\det(\mathbf{Q}) &= \det({\mathbf{Q}}^{\top}\mathbf{Q}) && \text{(determinant of a product)} \\ &= \det(\mathbf{I}_p) && \text{(} \mathbf{Q} \text{ is orthogonal)} \\ &= 1 && \text{(determinant of the identity)} \end{aligned} \]
Then:
\[ \begin{aligned} \det(\mathbf{A}) &= \det(\mathbf{Q}\mathbf{\Lambda}{\mathbf{Q}}^{\top}) && \text{(substitute the eigendecomposition)} \\ &= \det(\mathbf{Q}) \det(\mathbf{\Lambda}) \det({\mathbf{Q}}^{\top}) && \text{(determinant of a product, twice)} \\ &= \det(\mathbf{\Lambda}) \cdot\det({\mathbf{Q}}^{\top})\det(\mathbf{Q}) && \text{(reorder the three numbers)} \\ &= \det(\mathbf{\Lambda}) && \text{(the first display)} \\ &= \prod_{i=1}^p \lambda_i && \text{(determinant of a diagonal matrix)} \end{aligned} \]
The product steps are Theorem 27, the orthogonality step is Definition 31, and the identity and diagonal steps are Theorem 26 and Example 31.
Proof. By Theorem 24, every eigenvalue of \(\mathbf{A}\) is positive, so their product, which is \(\det(\mathbf{A})\) by Theorem 28, is positive.
9 Design Matrix
The product \(\mathbf{X}\tilde{\beta}\) collects all the linear predictors \({\tilde{x}_i}^{\top}\tilde{\beta}\) into a single \(n \times 1\) vector:
\[ \mathbf{X}\tilde{\beta}= \begin{bmatrix} {\tilde{x}_1}^{\top}\tilde{\beta}\\ \vdots \\ {\tilde{x}_n}^{\top}\tilde{\beta} \end{bmatrix} \]
The matrix \({\mathbf{X}}^{\top}\mathbf{X}\) is a \(p \times p\) symmetric matrix that appears in the OLS estimator \(\hat{\tilde{\beta}} = ({\mathbf{X}}^{\top}\mathbf{X})^{-1}{\mathbf{X}}^{\top}\tilde{y}\).
Proof. Let \(\tilde{c}\) be a vector of length \(p\) with \({\mathbf{X}}^{\top}\mathbf{X}\tilde{c} = \tilde{0}\). Then
\[ \begin{aligned} 0 &= {\tilde{c}}^{\top}\,{\mathbf{X}}^{\top}\mathbf{X}\tilde{c} && \text{(multiply } {\mathbf{X}}^{\top}\mathbf{X}\tilde{c} = \tilde{0}\text{ on the left by } {\tilde{c}}^{\top} \text{)} \\ &= {\mathopen{}\left(\mathbf{X}\tilde{c}\right)\mathclose{}}^{\top}\mathopen{}\left(\mathbf{X}\tilde{c}\right)\mathclose{} && \text{(transpose of a product)} \\ &= \mathopen{}\left\lVert\mathbf{X}\tilde{c}\right\rVert\mathclose{}^2 && \text{(definition of the Euclidean norm)} \end{aligned} \]
so \(\mathbf{X}\tilde{c} = \tilde{0}\). Because \(\mathbf{X}\tilde{c} = c_1 (\text{column } 1) + \cdots + c_p (\text{column } p)\) and the columns of \(\mathbf{X}\) are linearly independent, \(\tilde{c} = \tilde{0}\). So the only solution of \({\mathbf{X}}^{\top}\mathbf{X}\tilde{c} = \tilde{0}\) is \(\tilde{c} = \tilde{0}\), which says that the columns of the square matrix \({\mathbf{X}}^{\top}\mathbf{X}\) are linearly independent, and a square matrix with linearly independent columns is invertible (Banerjee and Roy 2014, Corollary 5.7, p. 143).
Proof. We verify symmetry and idempotency. Both use that \({\mathbf{X}}^{\top}\mathbf{X}\) is symmetric, \({\mathopen{}\left({\mathbf{X}}^{\top}\mathbf{X}\right)\mathclose{}}^{\top} = {\mathbf{X}}^{\top}\,{\mathopen{}\left({\mathbf{X}}^{\top}\right)\mathclose{}}^{\top} = {\mathbf{X}}^{\top}\mathbf{X}\) (Theorem 10), so its inverse is symmetric too (Corollary 1).
Symmetry: \[\begin{aligned} {\mathbf{H}}^{\top} &= {\left(\mathbf{X}({\mathbf{X}}^{\top}\mathbf{X})^{-1}{\mathbf{X}}^{\top}\right)}^{\top} && \text{(definition of } \mathbf{H} \text{)} \\ &= {({\mathbf{X}}^{\top})}^{\top} \cdot {\left(({\mathbf{X}}^{\top}\mathbf{X})^{-1}\right)}^{\top} \cdot {\mathbf{X}}^{\top} && \text{(transpose of a product, twice)} \\ &= \mathbf{X}\cdot {\left(({\mathbf{X}}^{\top}\mathbf{X})^{-1}\right)}^{\top} \cdot {\mathbf{X}}^{\top} && \text{(transposing twice changes nothing)} \\ &= \mathbf{X}\cdot ({\mathbf{X}}^{\top}\mathbf{X})^{-1} \cdot {\mathbf{X}}^{\top} && \text{(the inverse of a symmetric matrix is symmetric)} \\ &= \mathbf{H} && \text{(definition of } \mathbf{H} \text{)} \end{aligned}\]
Idempotency: \[\begin{aligned} \mathbf{H}^2 &= \mathbf{X}({\mathbf{X}}^{\top}\mathbf{X})^{-1}{\mathbf{X}}^{\top} \cdot \mathbf{X}({\mathbf{X}}^{\top}\mathbf{X})^{-1}{\mathbf{X}}^{\top} && \text{(definition of } \mathbf{H} \text{)} \\ &= \mathbf{X}({\mathbf{X}}^{\top}\mathbf{X})^{-1}({\mathbf{X}}^{\top}\mathbf{X})({\mathbf{X}}^{\top}\mathbf{X})^{-1}{\mathbf{X}}^{\top} && \text{(regroup; matrix multiplication is associative)} \\ &= \mathbf{X}\,\mathbf{I}_p\,({\mathbf{X}}^{\top}\mathbf{X})^{-1}{\mathbf{X}}^{\top} && \text{(definition of the inverse)} \\ &= \mathbf{X}({\mathbf{X}}^{\top}\mathbf{X})^{-1}{\mathbf{X}}^{\top} && \text{(identity matrix)} \\ &= \mathbf{H} && \text{(definition of } \mathbf{H} \text{)} \end{aligned}\]
The hat matrix appears in the formula for fitted values in linear regression: \(\hat{\tilde{y}} = \mathbf{X}\hat{\tilde{\beta}} = \mathbf{X}({\mathbf{X}}^{\top}\mathbf{X})^{-1}{\mathbf{X}}^{\top}\tilde{y}= \mathbf{H}\tilde{y}\). It “puts a hat” on \(\tilde{y}\) — hence the name.