8 Matrix Laws, Rank, Eigenvalue, and Projection
This section develops matrix operations and rank and projection ideas.
8.1 Laws of matrix algebra
8.1.1 From scalar algebra to matrix algebra
In scalar algebra, we have the associative, distributive, and commutative rules for addition and for multiplication.
Specifically, for any scalars \(a\), \(b\), and \(c\), we learned in elementary school that:
- Associative rule for addition:\((a + b) + c = a + (b + c)\)
- Associative rule for multiplication:\((a \times b) \times c = a \times (b \times c)\)
- Commutative rule for addition:\(a + b = b + a\)
- Commutative rule for multiplication:\(a \times b = b \times a\)
- Distributive rule:\(a \times (b + c) = a \times b + a \times c\) and \((a + b) \times c = a \times c + b \times c\)
In matrix algebra, the associative and distributive rules hold, but the commutative rule for multiplication does not hold in general. Specifically, for any matrices \(A\), \(B\), and \(C\):
- Associative rule for addition:\((A + B) + C = A + (B + C)\)
- Associative rule for multiplication:\((A \times B) \times C = A \times (B \times C)\)
- Commutative rule for addition:\(A + B = B + A\)
- Commutative rule for multiplication:\(A \times B \neq B \times A\) in general
- Distributive rule:\(A \times (B + C) = A \times B + A \times C\) and \((A + B) \times C = A \times C + B \times C\)
So matrix algebra is very similar to scalar algebra, except that matrix multiplication is not commutative in general.
8.1.2 Transpose
Transposing a matrix means swapping its rows and columns. The transpose of a matrix \(A\) is denoted as \(A^T\). If \(A\) is a 1 by 1 matrix, then its transpose is itself. If \(A\) is a 1 by n matrix (a row vector), then its transpose is an n by 1 matrix (a column vector), and vice versa. If \(A\) is an m by n matrix, then its transpose is an n by m matrix.
The transpose operation has the following core properties:
- \((cA)^T = cA^T\) for any scalar \(c\)
- \((A^T)^T = A\)
- \((A + B)^T = A^T + B^T\)
- \((AB)^T = B^T A^T\)
The first and the second properties are straightforward. The first says that transposing a scaled matrix is the same as scaling the transposed matrix. The second says that transposing a matrix twice returns the original matrix.
The third property looks confusing because the \(^T\) transpose notation looks like an exponent. But it is not an exponent, it is just a notation for the transpose operation. The third property says that the transpose of a sum of matrices is the same as the sum of the transposed matrices. So while we can not distribute exponents over addition, we can distribute the transpose operation over addition.
The fourth perhaps is a commonly used operation, the transpose can be distributed over matrix multiplication, but the order of the matrices is reversed. This is because when we transpose a matrix, we swap its rows and columns. So when we transpose a product of matrices, we need to reverse the order of the matrices to maintain the correct dimensions for multiplication. Suppose A is a m by n matrix, and B is a n by p matrix, then AB is a m by p matrix. The transpose of AB is a p by m matrix. On the other hand, the transpose of B is a p by n matrix, and the transpose of A is a n by m matrix. The product of the transposes is a p by m matrix, which is the same as the transpose of AB.
8.2 Product of matrices and vectors
8.2.1 The product of two vectors (dot product)
The product of two vectors \(a\) and \(b\), also known as the dot product, is defined as:
\[ a \cdot b = \sum_{i=1}^{n} a_i b_i \]
where \(a_i\) and \(b_i\) are the components of vectors \(a\) and \(b\), respectively, and \(n\) is the number of components in each vector. The dot product results in a scalar value.
Generally, we just use the symbol \(\cdot\) for any scalar multiplication. And when we have a vector \(a\) that is a n by 1 column vector, and a vector \(b\) that is another n by 1 column vector, we can write the dot product as:
\[ a \cdot b = a^T b = \sum_{i=1}^{n} a_i b_i \]
where \(a^T\) is the transpose of vector \(a\), which is a 1 by n row vector. The product \(a^T b\) is then a 1 by 1 matrix, which is equivalent to a scalar. Writing this out in matrix form, we have:
\[\begin{align} a^T b &= \begin{bmatrix} a_1 & a_2 & \cdots & a_n \end{bmatrix} \begin{bmatrix} b_1 \\ b_2 \\ \vdots \\ b_n \end{bmatrix}\\ &= a_1 b_1 + a_2 b_2 + \cdots + a_n b_n\\ &= \sum_{i=1}^{n} a_i b_i \end{align}\]
8.2.2 The product of a matrix and a vector
The product of a matrix \(A\) that is m by n and a vector \(b\) that is n by 1 is defined as:
\[ Ab = \begin{bmatrix} a_{11} & a_{12} & \cdots & a_{1n} \\ a_{21} & a_{22} & \cdots & a_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{m1} & a_{m2} & \cdots & a_{mn} \end{bmatrix} \begin{bmatrix} b_1 \\ b_2 \\ \vdots \\ b_n \end{bmatrix} = \begin{bmatrix} \sum_{j=1}^{n} a_{1j} b_j \\ \sum_{j=1}^{n} a_{2j} b_j \\ \vdots \\ \sum_{j=1}^{n} a_{mj} b_j \end{bmatrix} \]
The result is a m by 1 column vector. The notation \(Ab\) might look confusing, especially confusing if English words are used for matrix names, and \(Ab\) might look like a single word, so be careful about your notations. We often like to use bold to represent column vectors and perhaps capitalized letters (and bold) to represent matrices, and small cap not bold for scalar values. For example, we can write the above as:
\[ \mathbf{A} \mathbf{b} = \mathbf{c} \]
8.2.3 The product of two matrices
Let A be a m by n matrix, and B be a n by p matrix, then the product of A and B is defined as:
\[\begin{align} C = AB =& \begin{bmatrix} a_{11} & a_{12} & \cdots & a_{1n} \\ a_{21} & a_{22} & \cdots & a_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{m1} & a_{m2} & \cdots & a_{mn} \end{bmatrix} \begin{bmatrix} b_{11} & b_{12} & \cdots & b_{1p} \\ b_{21} & b_{22} & \cdots & b_{2p} \\ \vdots & \vdots & \ddots & \vdots \\ b_{n1} & b_{n2} & \cdots & b_{np} \end{bmatrix}\\ =& \begin{bmatrix} \sum_{j=1}^{n} a_{1j} b_{j1} & \sum_{j=1}^{n} a_{1j} b_{j2} & \cdots & \sum_{j=1}^{n} a_{1j} b_{jp} \\ \sum_{j=1}^{n} a_{2j} b_{j1} & \sum_{j=1}^{n} a_{2j} b_{j2} & \cdots & \sum_{j=1}^{n} a_{2j} b_{jp} \\ \vdots & \vdots & \ddots & \vdots \\ \sum_{j=1}^{n} a_{mj} b_{j1} & \sum_{j=1}^{n} a_{mj} b_{j2} & \cdots & \sum_{j=1}^{n} a_{mj} b_{jp} \end{bmatrix} \end{align}\]
The value in row i and column k of the resulting matrix C is the dot product of row i of matrix A and column k of matrix B:
\[ c_{ik} = \sum_{j=1}^{n} a_{ij} b_{jk} \]
By using matrix notation, rather than having to work out m by p dot products, we can just write the product of two matrices as AB, which is much more compact and easier to read.
Matrixes algebra is a time saving device that allows us to focus on the big picture, and not get mired in the details of individual dot product calculations.
8.2.4 Matrixes and investment portfolio
This matrix way of representing information is widely applicable in many settings. For example, the m by p matrix C, which is the product of m by n matrix A and n by p matrix B, can be viewed as a return matrix, across states-of-the-world for different investment portfolios. In this case, Matrix A represent contingent-returns for \(n\) assets (e.g., stocks, bonds, etc) across states of the world \(m\), with each value in matrix \(A\) recording the return of asset \(j\) in state of the world \(i\). Each column of matrix \(B\) represents a portfolio. Different columns are different investment strategies.
Each column of matrix C then represents the returns to each portfolio, across states of the world (rows). We can solve for specific vectors in matrix \(B\) that achieves specific vectors of returns. Including a portfolio that hedges risks and returns the same in all states of the world, or a vector that provides insurance and provides only positive return in one state of the world and nothing in other states.
Suppose there are two states of the world, sunny and rain, and two assets, Ray-ban and doordash. The return matrix \(A\) is given as follows:
\[ A = \begin{bmatrix} 1.5 \, (\text{Ray-ban sunny}) & 0.5 \, (\text{doordash sunny}) \\ 0.5 \, (\text{Ray-ban rain}) & 1.2 \, (\text{doordash rain}) \end{bmatrix} \]
where the first row represents the returns of the two assets when it is sunny, and the second row represents the returns of the two assets when it is rainy. The first column represents the returns of Ray-ban, and the second column represents the returns of doordash. Now, suppose we have three investment strategies: (1) invest 50% in Ray-ban and 50% in doordash; (2) invest 20% in Ray-ban and 80% in doordash; (3) invest about 41.18 percent in Ray-ban, and the rest in doordash. The portfolio matrix \(B\) is given as follows:
\[ B = \begin{bmatrix} 0.5 & 0.2 & 0.4118 \\ 0.5 & 0.8 & 0.5882 \end{bmatrix} \]
The return matrix \(C\) is given as follows:
\[ C = AB = \begin{bmatrix} 1.0 & 0.70 & 0.9118 \\ 0.85 & 1.06 & 0.9118 \end{bmatrix} \]
where the first column represents the returns of the first investment strategy across the two states of the world, and so forth. Which strategy is better? Depends on investor’s preferences and the investor needs to insure against, different portofolios can return more in sunny state, more in rainy state, or the same in both states.
An investment firm has three roles: (1) discover the \(A\) matrix with research analysts, with each analyst specializing across subsets of rows (state of the world contingencies) or columns (companies assets); (2) design column vectors in matrix \(B\) that achieve alternative cross-states return objectives with portfolio managers; and (3) pair investors with portfolios that match with their financial needs with financial advisors.
8.2.5 Generalized solution to the portfolio problem
We now set up the portfolio problem from the prior section formally, without assigning numerical values to returns. Consider two assets and two states of the world. The return matrix is:
\[ A = \begin{bmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{bmatrix}, \]
where row \(i\) gives the returns in state \(i\), and column \(j\) gives the returns of asset \(j\). Thus, \(a_{11}\) is the return of asset 1 in state 1, \(a_{12}\) is the return of asset 2 in state 1, and so forth.
Let \(w_1\) and \(w_2\) denote the fractions of wealth invested in assets 1 and 2. We consider fully invested portfolios, so:
\[ w_1 + w_2 = 1. \]
The portfolio-weight vector is:
\[ w = \begin{bmatrix}w_1 \\ w_2\end{bmatrix}. \]
Matrix multiplication gives the portfolio return in each state:
\[ Aw = \begin{bmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{bmatrix} \begin{bmatrix}w_1 \\ w_2\end{bmatrix} = \begin{bmatrix} a_{11}w_1 + a_{12}w_2 \\ a_{21}w_1 + a_{22}w_2 \end{bmatrix}. \]
The portfolio has zero risk, in the sense of having the same return in both states, if there is a scalar \(r\) such that:
\[ a_{11}w_1 + a_{12}w_2 = r, \qquad a_{21}w_1 + a_{22}w_2 = r. \]
Equating the two state returns and moving all terms to the left gives:
\[ (a_{11}-a_{21})w_1 + (a_{12}-a_{22})w_2 = 0. \]
Together with the full-investment condition, the two equations determining the weights are:
\[ \begin{aligned} (a_{11}-a_{21})w_1 + (a_{12}-a_{22})w_2 &= 0, \\ w_1+w_2 &= 1. \end{aligned} \]
Use \(w_2=1-w_1\) in the first equation:
\[ (a_{11}-a_{21})w_1 + (a_{12}-a_{22})(1-w_1)=0. \]
Collect the terms involving \(w_1\):
\[ \left(a_{11}-a_{21}-a_{12}+a_{22}\right)w_1 = a_{22}-a_{12}. \]
Define the denominator:
\[ D = a_{11}+a_{22}-a_{12}-a_{21}. \]
When \(D\ne0\), the unique zero-risk portfolio is:
\[ w_1^* = \frac{a_{22}-a_{12}}{D}, \qquad w_2^* = 1-w_1^* = \frac{a_{11}-a_{21}}{D}. \]
Equivalently,
\[ w^* = \frac{1}{D} \begin{bmatrix} a_{22}-a_{12} \\ a_{11}-a_{21} \end{bmatrix}. \]
We can derive the common return by substituting these weights into the return in state 1:
\[ \begin{aligned} r^* &= a_{11}w_1^* + a_{12}w_2^* \\ &= a_{11}\left(\frac{a_{22}-a_{12}}{D}\right) + a_{12}\left(\frac{a_{11}-a_{21}}{D}\right) \\ &= \frac{a_{11}a_{22}-a_{12}a_{21}}{D}. \end{aligned} \]
The same expression results from substituting the weights into the return in state 2. Therefore:
\[ Aw^* = r^*\begin{bmatrix}1 \\ 1\end{bmatrix}, \qquad r^* = \frac{\det(A)}{D}. \]
For the portfolio to be long-only, both weights must be nonnegative. A common sufficient condition is that asset 1 has a higher return in state 1 than in state 2 and asset 2 has a higher return in state 2 than in state 1:
\[ a_{11}>a_{21}, \]
8.3 Rank and independence of matrix
8.3.1 Independence and zero condition
Given a matrix A that is m x n, we can say that the columns of A are linearly independent if the only solution to the equation:
\[ A \mathbf{x} = 0 \]
is true when \(\mathbf{x} = 0\).
This matrix \(A\) then has full column rank, meaning that the rank of \(A\) is equal to the number of columns, which is \(n\).
8.3.2 Parallel lines
Consider a 2 by 2 example in our familiar x and y space with two lines, what the above condition means is that if the two lines are not parallel, then their associated matrix has linearly independent columns. If the two lines are parallel, then their associated matrix has linearly dependent columns. And checking whether the lines are parallel is equivalent to checking the condition above.
Suppose we have \(y = a + b x\) and \(y = c + d x\). We can write this as a matrix equation, with \(x\) and \(y\) as the variables, and \(a, b, c, d\) as the coefficients:
We can rearrange both equations to isolate terms involving \(x\) and \(y\):
\[\begin{align*} y - b x &= a \\ y - d x &= c \end{align*}\]
This can be written as a matrix equation:
\[ \begin{bmatrix} - b & 1 \\ - d & 1 \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} = \begin{bmatrix} a \\ c \end{bmatrix} \]
The columns of the coefficient matrix are linearly independent if and only if \(b \neq d\), which means the two lines are not parallel.
8.3.3 Non-singular matrix and zero
Let \(A\) be a full rank square matrix that is \(n\) by \(n\). Then for any non-zero vector \(\mathbf{v}\), the transformation \(A\mathbf{v}\) is also non-zero.
Proof: Let \(A\) be a full rank \(n \times n\) matrix, and let \(\mathbf{v}\) be any non-zero vector in \(\mathbb{R}^n\). Suppose, for contradiction, that \(A\mathbf{v} = \mathbf{0}\).
If \(A\mathbf{v} = \mathbf{0}\), this means that a linear combination of the columns of \(A\), weighted by the entries of \(\mathbf{v}\), results in the zero vector. Specifically, if \(A = [a_1, a_2, \ldots, a_n]\) and \(\mathbf{v} = [v_1, v_2, \ldots, v_n]^T\), then:
\[ A\mathbf{v} = v_1 a_1 + v_2 a_2 + \cdots + v_n a_n = \mathbf{0} \]
This equation says that the columns \(a_1, a_2, \ldots, a_n\) of \(A\) can be combined using the coefficients \(v_1, v_2, \ldots, v_n\) to produce the zero vector. Because \(v\) is a non-zero vector, select an index \(j\) where \(v_j \neq 0\). Then column \(j\) is a linear combination of the other columns:
\[ a_j = -\frac{1}{v_j}\sum_{i\neq j} v_i a_i \]
This means that the \(j\) vector’s information is contained in the other \(n-1\) vectors, which means that the columns of \(A\) are linearly dependent. This contradicts our assumption that \(A\) is full rank, which means that its columns are linearly independent.
Therefore, for any non-zero vector \(\mathbf{v}\), \(A\mathbf{v}\) cannot be zero. This shows that a full rank square matrix does not collapse the space into a lower dimension.
8.4 Eigenvalues and eigenvectors
8.4.1 Transforming a vector, scale, rotate, and shear
Given matrix \(A\) and vector \(v\), when we multiply \(A\) by \(v\), we get another vector \(Av\). This is called a linear transformation of the vector \(v\) by the matrix \(A\). The resulting vector \(Av\) may have a different direction and magnitude than the original vector \(v\).
What does linear transformation mean? It means that the transformation preserves the operations of vector addition and scalar multiplication. Specifically, for any vectors \(u\) and \(v\), and any scalar \(c\). Suppose we are dealing with 2 dimensions. Let \(v\) be a two dimensional vector, and let \(A\) be a 2 by 2 matrix.\(v\) marks the position of a point in the 2D space, and \(Av\) marks the position of another point in the 2D space. The transformation from \(v\) to \(Av\) can be visualized as a mapping from one point to another point in the 2D space.
Suppose we have a vector \(v = [1,1]\), matrix \(A\) would be scaling the vector \(v\) if matrix \(A\) is a diagonal matrix, such as:
\[ A = \begin{bmatrix} 2 & 0 \\ 0 & 3 \end{bmatrix} \]
Then the transformation \(Av\) would be:
\[ Av = \begin{bmatrix} 2 & 0 \\ 0 & 3 \end{bmatrix} \begin{bmatrix} 1 \\ 1 \end{bmatrix} = \begin{bmatrix} 2 \\ 3 \end{bmatrix} \]
In this case, the two coordinates are scaled by different amounts, which changes both the vector’s magnitude and direction.
How do we reflect the vector \(v\) across the x-axis? We can use the following matrix:
\[ A = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix} \]
Then the transformation \(Av\) would be:
\[ Av = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix} \begin{bmatrix} 1 \\ 1 \end{bmatrix} = \begin{bmatrix} 1 \\ -1 \end{bmatrix} \]
This is a reflection of the vector \(v\) across the x-axis.
What do the cross-diagonal elements do? The cross-diagonal elements are responsible for shearing the vector \(v\). For example, if we have the following matrix:
\[ A = \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix} \]
Then the transformation \(Av\) would be:
\[ Av = \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix} \begin{bmatrix} 1 \\ 1 \end{bmatrix} = \begin{bmatrix} 2 \\ 1 \end{bmatrix} \]
This is a shear transformation of the vector \(v\). Shearing means that the shape of the object is distorted, but the area remains the same (\(\det(A)=1\)).
8.4.2 The geometries of eigenvalues, eigenvectors, and determinant
Eigen means “own” in German. So eigenvalues means ownvalues, and eigenvectors means ownvectors. The eigenvalues and eigenvectors of a square matrix \(A\) are defined as follows:
\[ A v = \lambda v \]
where \(v\) is a non-zero vector (the eigen vector), and \(\lambda\) is a scalar (the eigen value). This equation means that when we multiply the matrix \(A\) by the eigen vector \(v\), the result is a scaled version of the same vector \(v\), scaled by the eigen value \(\lambda\).
How do we use determinant to find eigenvalues? We can rearrange the equation above as follows:
\[ (A - \lambda I) v = 0 \]
where \(I\) is the identity matrix. This equation means that the matrix \((A - \lambda I)\) transforms the vector \(v\) into the zero vector. For this equation to have a non-trivial solution (i.e., a non-zero vector \(v\)), the matrix \((A - \lambda I)\) must be singular and not full-rank, which means that its determinant is zero:
\[ \text{det}(A - \lambda I) = 0 \]
How to compute the determinant of a 2 by 2 matrix? For a 2 by 2 matrix:
\[ Z = \begin{bmatrix} a & b \\ c & d \end{bmatrix} \] the determinant is given by:
\[ \text{det}(Z) = ad - bc \]
What does determinant capture? The determinant of a matrix captures the scaling factor of the area (in 2D) or volume (in 3D) when the matrix is used as a linear transformation. If the determinant is zero, it means that the transformation collapses the space into a lower dimension, resulting in zero area or volume. So determinant is how much the area or volume is scaled by the transformation.
8.4.3 Solving for eigenvalues and associated eigenvectors
To solve for eigenvalues, we solve for values of \(\lambda\) when the matrix \(A-\lambda I\) would be singular, with a determinant of zero. We will in the example here find two eigenvalues, \(\lambda_1\) and \(\lambda_2\), for a 2 by 2 matrix \(A\). Associated with these eigenvalues are two sets of continuum of eigenvectors that are scalar multiples of each other. It will always be the case that for each eigenvalue, there is an infinite number of eigenvectors that are scalar multiples of each other that satisfy the eigen \(A v = \lambda v\) equation.
First, suppose we have the following matrix:
\[ A = \begin{bmatrix} 4 & 2 \\ 1 & 3 \end{bmatrix} \]
To find the eigenvalues, set up the equation:
\[ \text{det}(A - \lambda I) = 0 \]
So,
\[ A - \lambda I = \begin{bmatrix} 4 - \lambda & 2 \\ 1 & 3 - \lambda \end{bmatrix} \]
Second, we solve for the determinant. The determinant is:
\[ (4 - \lambda)(3 - \lambda) - (2)(1) = 0 \]
Expanding:
\[ (4 - \lambda)(3 - \lambda) - 2 = 0 \\ (12 - 4\lambda - 3\lambda + \lambda^2) - 2 = 0 \\ \lambda^2 - 7\lambda + 10 = 0 \]
Third, we find the eigenvalues. Solving the quadratic equation:
\[ \lambda^2 - 7\lambda + 10 = 0 \]
The solutions are:
\[ \lambda = 5 \quad \text{and} \quad \lambda = 2 \]
These are the eigenvalues of \(A\). To find the corresponding eigenvectors, substitute each eigenvalue back into \((A - \lambda I)v = 0\) and solve for \(v\). The eigenvectors corresponding to each eigenvalue can be found by solving the following systems:
Fourth, for \(\lambda = 5\), we find its associated eigenvector by substituting into the equation:
\[ A - 5I = \begin{bmatrix} 4 - 5 & 2 \\ 1 & 3 - 5 \end{bmatrix} = \begin{bmatrix} -1 & 2 \\ 1 & -2 \end{bmatrix} \]
Set up the equation: \[ \begin{bmatrix} -1 & 2 \\ 1 & -2 \end{bmatrix} \begin{bmatrix} v_1 \\ v_2 \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \end{bmatrix} \]
This gives the system: \[ -1 v_1 + 2 v_2 = 0 \\ 1 v_1 - 2 v_2 = 0 \]
Both equations are equivalent. Solving for \(v_1\) in terms of \(v_2\): \[ -1 v_1 + 2 v_2 = 0 \implies v_1 = 2 v_2 \]
So, any nonzero scalar multiple of \(\begin{bmatrix} 2 \\ 1 \end{bmatrix}\) is an eigenvector for \(\lambda = 5\).
Fifth, we find the eigenvector for \(\lambda = 2\):
\[ A - 2I = \begin{bmatrix} 4 - 2 & 2 \\ 1 & 3 - 2 \end{bmatrix} = \begin{bmatrix} 2 & 2 \\ 1 & 1 \end{bmatrix} \]
Set up the equation: \[ \begin{bmatrix} 2 & 2 \\ 1 & 1 \end{bmatrix} \begin{bmatrix} v_1 \\ v_2 \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \end{bmatrix} \]
This gives the system: \[ 2 v_1 + 2 v_2 = 0 \\ v_1 + v_2 = 0 \]
Both equations are equivalent. Solving for \(v_1\) in terms of \(v_2\): \[ v_1 + v_2 = 0 \implies v_1 = -v_2 \]
So, any nonzero scalar multiple of \(\begin{bmatrix} -1 \\ 1 \end{bmatrix}\) is an eigenvector for \(\lambda = 2\).
8.5 Projection
8.5.1 Normalized orthogonal basis
Basis vectors are a set of vectors that are linearly independent and span the vector space. In \(\mathbb{R}^2\), the standard basis vectors are:
\[ e_1 = \begin{bmatrix} 1 \\ 0 \end{bmatrix}, \quad e_2 = \begin{bmatrix} 0 \\ 1 \end{bmatrix} \]
Multiplying the basis vectors by any scalar will stretch or compress them, and adding them together will create new vectors in the space with contribution from each of the basis directions. The example just given is are two orthogonal basis vectors, meaning they are at right angles to each other, with dot product zero.
Not only that, we have normalized them so the norm of each vector is 1, where norm is computed as the square root of the sum of squares of the elements of the vector. This is the Euclidean norm, also called the 2-norm, for a vector \(v\) in \(\mathbb{R}^n\), its Euclidean norm is defined as:
\[ \|v\|_2 = \sqrt{v_1^2 + v_2^2 + \ldots + v_n^2} \]
So these are orthonormal basis vectors.
These are not the only two orthonormal basis vectors in \(\mathbb{R}^2\). For example, we could have:
\[ b_1 = \begin{bmatrix} \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} \end{bmatrix}, \quad b_2 = \begin{bmatrix} -\frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} \end{bmatrix} \]
These two vectors are also orthonormal, as they are at right angles to each other and have a norm of 1: their dot product is zero, and their norms are both 1.
8.5.2 Projecting a vector onto a basis vector
Now consider any vector \(v\) in \(\mathbb{R}^n\). Imagine in \(n=2\), we can draw a line from the “tip” of this vector towards a basis vector, such that this line drawn is perpendicular to the basis vector. The point where this line intersects the basis vector is marks the projection vector of \(v\) onto this basis vector.
Note that this projection vector is a scaled version of the basis vector. Let \(\gamma^v\) be the scaling factor, then we can write the projection of \(v\) onto the basis vector \(e_1\) as:
\[ p^v_{e_1} = \gamma^v_{e_1} e_1 \]
where \(\gamma^v_{e_1}\) is the scaling factor for the projection of \(v\) onto \(e_1\). The residual after projection is the difference between \(v\) and its projection onto \(e_1\), \(v-p^v_{e_1}\). It is orthogonal to the basis vector \(e_1\).
\[ (v - p^v_{e_1}) \cdot e_1 = (v - \gamma^v_{e_1} e_1) \cdot e_1 = 0 \]
Now, working with dot product algebra, which is distributive, and the definition of \(p^v_{e_1}\)
\[\begin{align} (v - \gamma^v_{e_1} e_1) \cdot e_1 &= 0\\ v \cdot e_1 - \gamma^v_{e_1} e_1 \cdot e_1 &= 0\\ \gamma^v e_1 \cdot e_1 &= v \cdot e_1\\ \gamma^v &= \frac{v \cdot e_1}{e_1 \cdot e_1} \end{align}\]
Recognizing that the dot product of a vector with itself is the square of its norm, we can write this as:
\[ \gamma^v = \frac{v \cdot e_1}{\|e_1\|^2} \]
And correspondingly the projection vector itself is:
\[ p^v_{e_1} = \frac{v \cdot e_1}{\|e_1\|^2} e_1 \]
In vector notation we have, given that we can move around and take transpose scalar while preserving value (\(v^T e_1\) is a scalar):
\[\begin{align} p^v_{e_1} &= \frac{v^T e_1 e_1 }{e_1^T e_1} = \frac{e_1 v^T e_1}{e_1^T e_1} = \frac{e_1 e_1^T}{e_1^T e_1}v \end{align}\]
This states that the outer product, scaled by the inner product of the basis vector with itself, projects \(v\) onto \(e_1\). If \(e_1\) is a unit vector, then \(e_1^T e_1=1\) and the denominator can be dropped.
8.5.3 Projection onto a multidimensional subspace
We just projected a vector onto a single vector. We can project a vector, more generally, onto the subspace spanned by multiple basis vectors. In the case of \(\mathbb{R}^2\), we can project onto either \(e_1\) or \(e_2\), if we project onto the subspace spanned by both, then we get back the original vector, because a line is on the plane spanned by two basis vectors. In the case of \(\mathbb{R}^3\), suppose \(e_1\), \(e_2\) and \(e_3\) are basis vectors that span the space, then projecting \(v \in \mathbb{R^3}\) onto the spaced spanned by \(e_1\) and \(e_2\) will give us a vector on the plane spanned by \(e_1\) and \(e_2\), projecting onto the space spanned by \(e_1\) and \(e_3\) will give us a vector on the plane spanned by \(e_1\) and \(e_3\), and so on. If we project onto the space spanned by all three basis vectors, we get back the original vector again. So projection onto a “subspace” is more interesting when the subspace is of lower dimension than the original space.
Given basis vectors \(b_i\) for \(i=1,2,...,n\) that span a k-dimensional subspace of \(\mathbb{R}^n\). We can project from vector \(v\) to each of the basis, in that case, we have what we had from before. We can also project with respect to the subspace spanned by the basis vectors. Let \(\gamma_i\) be the scaling factor along each dimension, then the projection of \(v\) onto the subspace can be written as:
\[ p^v_{\mathbb{b}} = \sum_{i=1}^{k} \gamma^v_i b_i \]
where \(k \le n\). As before, the difference between \(v\) and its projection onto the subspace is orthogonal to each of the basis vectors:
\[ (v - p^v_{\mathbb{b}}) \cdot b_i = 0 \quad \text{for } i=1,2,...,k \]
\[\begin{align} (v - p^v_{b} ) \cdot b_i &= 0\\ v \cdot b_i - p^v_{b} \cdot b_i &= 0\\ p^v_{b} \cdot b_i &= v \cdot b_i\\ \left(\sum_{i=1}^{k} \gamma^v_i b_i \right) \cdot b_i &= v \cdot b_i\\ \end{align}\]
Suppose m=2, then we have:
\[\begin{align} \gamma^v_1 b_1 \cdot b_1 + \gamma^v_2 b_2 \cdot b_1 &= v \cdot b_1\\ \gamma^v_1 b_1 \cdot b_2 + \gamma^v_2 b_2 \cdot b_2 &= v \cdot b_2\\ \end{align}\]
8.5.4 Projection onto a multidimensional subspace, matrix representation
Building from prior, note that the dot product of \(b_i \cdot b_j\) are all scalar values. This is a system of linear equations, which we can write in matrix form as:
\[ \begin{bmatrix} b_1 \cdot b_1 & b_2 \cdot b_1 \\ b_1 \cdot b_2 & b_2 \cdot b_2 \end{bmatrix} \begin{bmatrix} \gamma^v_1 \\ \gamma^v_2 \end{bmatrix} = \begin{bmatrix} v \cdot b_1 \\ v \cdot b_2 \end{bmatrix} \]
Instead of writing dot product, we can write this in matrix form as:
\[ \begin{bmatrix} b_1^T b_1 & b_2^T b_1 \\ b_1^T b_2 & b_2^T b_2 \end{bmatrix} \begin{bmatrix} \gamma^v_1 \\ \gamma^v_2 \end{bmatrix} = \begin{bmatrix} v^T b_1 \\ v^T b_2 \end{bmatrix} \]
In general, for \(k \le n\) basis vectors, we have a matrix of the dot products of the basis vectors multiplying the vector of scaling factors equaling the vector of dot products of \(v\) with each of the basis vectors:
\[ \begin{bmatrix} b_1^T b_1 & b_2^T b_1 & \cdots & b_k^T b_1 \\ b_1^T b_2 & b_2^T b_2 & \cdots & b_k^T b_2 \\ \vdots & \vdots & \ddots & \vdots \\ b_1^T b_k & b_2^T b_k & \cdots & b_k^T b_k \end{bmatrix} \begin{bmatrix} \gamma^v_1 \\ \gamma^v_2 \\ \vdots \\ \gamma^v_k \end{bmatrix} = \begin{bmatrix} v^T b_1 \\ v^T b_2 \\ \vdots \\ v^T b_k \end{bmatrix} \]
In the matrix of dot products of the basis vectors, we have what looks like the definition of matrix product, with different cells equaling to different row-column products from two underlying matrices. The first element, is the first row of matrix 1 times the first column of matrix 2, the ith row and jth column is the ith row of matrix 1 times the jth column of matrix 2. Recognizing this, and the fact that the matrix is symmetric, we can write this more compactly. Let \(B\) (n by k) be the matrix whose columns are the basis vectors \(b_i\), we have:
\[ B = \begin{bmatrix} | & | & & | \\ b_1 & b_2 & \cdots & b_k \\ | & | & & | \end{bmatrix} \]
and we can write the system of equations as where the left hand size is k by 1 (k by n times n by k times k by 1) and the right hand size is k by 1 as well (k by n times n by 1):
\[ (B^T B) \gamma^v = B^T v \]
8.5.5 Projection onto a multidimensional subspace, matrix solution
If the basis vectors are not parallel (independent), then \(B^T B\) is invertible, and we can solve for \(\gamma^v\) (the k by 1 vector) as:
\[\begin{align} (B^T B) \gamma^v &= B^T v\\ (B^T B)^{-1}(B^T B) \gamma^v &= (B^T B)^{-1}B^T v\\ \gamma^v &= (B^T B)^{-1} B^T v \end{align}\]
Correspondingly, the projection vector, from \(v\) projected onto the space spanned by \(B\) is:
\[ p^v_{b} = B \cdot (B^T B)^{-1} B^T v \]
Note that the basis vectors do not have to be orthonormal, they just have to be independent. If they are orthonormal, then \(B^T B = I\) (the main diagonal are euclidean norms of each basis vector, all other components are dot products of different orthogonal basis vectors), the identity matrix, and the equation simplifies to (k by 1 = n by k times k by 1):
\[\begin{align} \gamma^v &= B^T v\\ p^v_{b} &= B (B^T v)\\ \end{align}\]
If \(n=k\), then \(p^v_{b} = v\).
They are not independent if one of the basis vectors can be written as a linear combination of the others. For example, if \(n\ge 3\) we have three basis vectors \(b_1\), \(b_2\) and \(b_3\), and \(b_3 = 2b_1 + 3b_2\), then these three basis vectors are not independent, and \(B^T B\) is not invertible.
8.5.6 Projection and least square regressions
From a projection point of view, the least square regression projects the a vector \(Y\) that is \(n\) by 1 onto the subspace spanned by \(k\) basis vectors, each of which is a \(n\) by 1 vector, the \(n\) by \(k\) matrix of basis vectors form matrix \(X\).\(n\) is usually the number of observations, and \(k\) the number of right-hand-side variables. Vector \(Y\) of “outcomes” correspond to the “v” vector above, and the matrix \(X\) of observable right-hand-side variables correspond to the matrix \(B\) above. The projection vector \(p^v_b\) above corresponds to the predicted value of the regression.
When we talk about colinearity issues with \(X\), that is the same as saying the basis vectors are not independent and do not span the \(R^k\) subspace.
If \(n=k\), we would have the same number of observables as coefficients of interests, and in that case, we would fit the data perfectly, hence the projection would be the same as the original vector \(Y\).