UBC Economics Math Camps
\[ x \cdot y = \sum_{i=1}^n x_i y_i \]
\[ x \cdot y = (1 \times 4) + (2 \times 5) + (3 \times 6) = 32 \]
\[ \|x\|_2 = \sqrt{\sum_{i=1}^n x_i^2} \]
The inner product \(x \cdot y\) directly measures how much \(y\) extends in the direction of \(x\)
\[ \text{proj}_{x}(y) = \frac{x \cdot y}{x \cdot x} \, x \]
\[ \begin{bmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{bmatrix} \begin{bmatrix} b_{11} & b_{12} \\ b_{21} & b_{22} \end{bmatrix} = \begin{bmatrix} a_{11}b_{11} + a_{12}b_{21} & a_{11}b_{12} + a_{12}b_{22} \\ a_{21}b_{11}+a_{22}b_{21} & a_{21}b_{12}+a_{22}b_{22} \end{bmatrix} \]
\[ \begin{bmatrix}1 & 2 \\ 3 & 4 \\ 5 & 6 \end{bmatrix} \begin{bmatrix}3 \\ -1 \end{bmatrix} = \begin{bmatrix} \begin{bmatrix}1 & 2 \end{bmatrix} \cdot \begin{bmatrix}3 & -1 \end{bmatrix} \\ \begin{bmatrix}3 & 4 \end{bmatrix} \cdot \begin{bmatrix}3 & -1 \end{bmatrix} \\ \begin{bmatrix}5 & 6 \end{bmatrix} \cdot \begin{bmatrix}3 & -1 \end{bmatrix} \end{bmatrix} = \begin{bmatrix} 1 \\ 5 \\ 9 \end{bmatrix} \]
\[ A b = b_1\mathbf{a}_1 + b_2\mathbf{a}_2 + \cdots + b_m\mathbf{a}_m \]
Diagonal matrix inverse
If \(D = \mathrm{diag}(d_1, \ldots, d_n)\) with all \(d_i \neq 0\): \[D^{-1} = \mathrm{diag}\!\left(\tfrac{1}{d_1}, \ldots, \tfrac{1}{d_n}\right)\]
Exercise: \((AB)^{-1} = B^{-1}A^{-1}\)
Show that \(B^{-1}A^{-1}\) is the inverse of \(AB\).
\[ \{2x + 3y = 2, \quad x - 2y = -1\} \Rightarrow \begin{bmatrix}2 & 3 \\ 1 & -2 \end{bmatrix} \begin{bmatrix}x \\ y \end{bmatrix} = \begin{bmatrix} 2 \\ -1 \end{bmatrix} \]
\[ \Rightarrow \begin{bmatrix}x \\ y \end{bmatrix} = \begin{bmatrix}2 & 3 \\ 1 & -2 \end{bmatrix}^{-1} \begin{bmatrix} 2 \\ -1 \end{bmatrix} \]
Topics covered:
The key mental model for econometrics: \(X \in \mathbb{R}^{n \times k}\) is a data matrix.
The product \(X\beta\) gives a vector in \(\mathbb{R}^n\): the \(i\)-th entry is a weighted combination of unit \(i\)’s attributes: \[ (X\beta)_i = x_i'\beta = \beta_1 x_{i1} + \cdots + \beta_k x_{ik} \]
A central question: do the columns of \(X\) contain redundant information? If so, many different \(\beta\) vectors produce the same \(X\beta\) — the weight vector cannot be uniquely recovered from the product alone.
Predict sepal length from sepal width and petal length (\(n = 150\) flowers, \(k = 3\) columns including intercept):
| Int | SW | PL | \(y\) | |
|---|---|---|---|---|
| Setosa 1 | 1 | 3.5 | 1.4 | 5.1 |
| Setosa 2 | 1 | 3.0 | 1.4 | 4.9 |
| Versicol. 3 | 1 | 3.2 | 4.7 | 7.0 |
| Versicol. 4 | 1 | 3.2 | 4.5 | 6.4 |
| Virginica 5 | 1 | 3.3 | 6.0 | 6.3 |
\[ X = \begin{pmatrix} 1 & 3.5 & 1.4 \\ 1 & 3.0 & 1.4 \\ 1 & 3.2 & 4.7 \\ 1 & 3.2 & 4.5 \\ 1 & 3.3 & 6.0 \end{pmatrix} \quad y = \begin{pmatrix} 5.1 \\ 4.9 \\ 7.0 \\ 6.4 \\ 6.3 \end{pmatrix} \]
\(X\beta = \beta_1\mathbf{1} + \beta_2 x_{(\text{sw})} + \beta_3 x_{(\text{pl})}\): each row gives one predicted sepal length.
For a data matrix \(X\) (\(n \times k\)), the column space is the set of all outcome vectors the model can reproduce exactly: \[ \text{col}(X) = \{X\beta : \beta \in \mathbb{R}^k\} = \text{span of the columns of } X \]
Each column of \(X\) is one regressor across all \(n\) observations. Finding which linear combination of these columns lies closest to a given \(y\) is the projection problem we address later.
Rank
The rank of \(X\) is the number of linearly independent columns — the number of regressors that genuinely contribute new information: \[ \text{rank}(X) = \dim(\text{col}(X)) \leq \min(n, k) \]
\[ X = \begin{pmatrix} 1 & 10 \\ 1 & 15 \\ 1 & 20 \end{pmatrix} \qquad \text{Columns: intercept } x_{(1)} \text{ and income } x_{(2)}\text{, three observations} \]
Can we write \(x_{(2)} = \alpha \, x_{(1)}\)? We need \((10,15,20) = \alpha(1,1,1)\), which requires \(\alpha = 10, 15, 20\) simultaneously — impossible. The columns are linearly independent, \(\text{rank}(X) = 2\), and \(\beta_1\) and \(\beta_2\) can be separately identified from \(X\beta\).
\[ X = \begin{pmatrix} 1 & 10 & 20 \\ 1 & 15 & 30 \\ 1 & 20 & 40 \end{pmatrix} \qquad \text{Columns: intercept, income, } 2\times\text{income} \]
Column 3 \(= 2\times\) column 2: the third regressor is redundant. Consequently:
Setup
You have a vector \(y \in \mathbb{R}^n\) and a subspace \(S = \text{col}(X)\) — the span of the columns of an \(n \times k\) matrix \(X\).
Goal: Find the best linear approximation of \(y\) from the columns of \(X\) — the vector \(\hat{y} \in S\) that is closest to \(y\).
The closest point \(\hat{y}\) in \(\text{col}(X)\) to \(y\) is the one where the residual \(e = y - \hat{y}\) is perpendicular to the subspace.
Orthogonality condition
\(e\) must be orthogonal to every vector in \(\text{col}(X)\): \[ X'e = 0 \] Each column of \(X\) must be orthogonal to the residual.
Since \(\hat{y} \in \text{col}(X)\), write \(\hat{y} = Xb\) for some \(b \in \mathbb{R}^k\). The residual is \(e = y - Xb\).
Applying \(X'e = 0\): \[ X'(y - Xb) = 0 \implies X'Xb = X'y \quad \text{(orthogonality conditions)} \]
If \(X\) has full column rank, \(X'X\) is invertible: \[ b = (X'X)^{-1}X'y \implies \hat{y} = Xb = X(X'X)^{-1}X'y \]
The projection matrix
\[ P = X(X'X)^{-1}X', \qquad \hat{y} = Py \]
Idempotent: \(P^2 = P\)
\[ P^2 = X(X'X)^{-1}\underbrace{X'X(X'X)^{-1}}_{I}X' = P \] Projecting twice is the same as projecting once.
Symmetric: \(P' = P\)
\[ P' = (X(X'X)^{-1}X')' = X((X'X)')^{-1}X' = X(X'X)^{-1}X' = P \]
Definition
\(M = I - P\) produces the residual: \(e = y - Py = My\).
\(M\) inherits the same properties: idempotent (\(M^2 = M\)) and symmetric (\(M' = M\)).
Key property: \(MX = 0\)
\[ MX = (I - P)X = X - X(X'X)^{-1}X'X = X - X = 0 \] \(M\) annihilates anything in \(\text{col}(X)\) and keeps only the perpendicular part.
Rank and degrees of freedom
\(\text{rank}(P) = k\), \(\;\text{rank}(M) = n - k\), \(\;\text{tr}(M) = n - k\).
This is why \(n - k\) is called degrees of freedom: it is the dimension of the space the residuals live in.
Practice: Properties of \(P\) and \(M\)
Let \(P = X(X'X)^{-1}X'\) and \(M = I - P\), with \(X\) of full column rank.
The expression \(P = X(X'X)^{-1}X'\) requires \((X'X)^{-1}\) to exist. The equivalent conditions are:
Equivalent conditions for \((X'X)^{-1}\) to exist
When any of these fail, \(X'X\) is singular, the formula breaks down, and the coefficient vector \(b\) with \(\hat{y} = Xb\) is not unique — many \(b\)’s yield the same closest approximation of \(y\).
The projection \(\hat{y} = X(X'X)^{-1}X'y\) depends on \(X'X\) being invertible. But \(X'X\) has richer structure worth understanding on its own terms: it is always symmetric, and its eigenvalues and eigenvectors encode how much independent information the columns of \(X\) carry.
Definition
A square matrix \(A\) is symmetric if \(A = A'\), i.e., \(a_{ij} = a_{ji}\) for all \(i, j\).
The \((i,j)\) entry of \(X'X\) is the inner product \(x_{(i)} \cdot x_{(j)}\) of regressor columns \(i\) and \(j\) — and inner products are symmetric. So \(X'X\) is always symmetric:
\[ (X'X)' = X'(X')' = X'X \quad \checkmark \]
For most vectors \(v\), \(Av\) is a vector not proportional to \(v\). But some vectors are special: \(Av\) is just a scalar multiple of \(v\).
Definition
A nonzero vector \(v\) is an eigenvector of \(A\) if \[ Av = \lambda v \] for some scalar \(\lambda\). The scalar \(\lambda\) is the corresponding eigenvalue.
\(\lambda > 1\): \(v\) stretched. \(\quad\) \(0 < \lambda < 1\): \(v\) compressed. \(\quad\) \(\lambda < 0\): \(v\) negated and scaled.
Example: \(A = \begin{pmatrix} 3 & 1 \\ 1 & 2 \end{pmatrix}\)
Claim: \(v_1 = \begin{pmatrix} 1 \\ 0.62 \end{pmatrix}\) is an eigenvector with \(\lambda_1 \approx 3.62\).
Check: \(Av_1 = \begin{pmatrix} 3 & 1 \\ 1 & 2 \end{pmatrix}\begin{pmatrix} 1 \\ 0.62 \end{pmatrix} = \begin{pmatrix} 3.62 \\ 2.24 \end{pmatrix} \approx 3.62 \begin{pmatrix} 1 \\ 0.62 \end{pmatrix}\) \(\checkmark\)
Second eigenvector
Claim: \(v_2 = \begin{pmatrix} 1 \\ -1.62 \end{pmatrix}\) is an eigenvector with \(\lambda_2 \approx 1.38\).
Check: \(Av_2 = \begin{pmatrix} 3 & 1 \\ 1 & 2 \end{pmatrix}\begin{pmatrix} 1 \\ -1.62 \end{pmatrix} = \begin{pmatrix} 1.38 \\ -2.24 \end{pmatrix} \approx 1.38 \begin{pmatrix} 1 \\ -1.62 \end{pmatrix}\) \(\checkmark\)
Stack all eigenvector equations \(Av_i = \lambda_i v_i\) into one matrix equation:
\[ A \underbrace{\begin{pmatrix} v_1 & \cdots & v_n \end{pmatrix}}_{P} = \underbrace{\begin{pmatrix} v_1 & \cdots & v_n \end{pmatrix}}_{P} \underbrace{\begin{pmatrix} \lambda_1 & & \\ & \ddots & \\ & & \lambda_n \end{pmatrix}}_{D} \]
So \(AP = PD\), which gives:
Eigendecomposition
\[A = PDP^{-1}\] where \(P\) has eigenvectors as columns and \(D = \text{diag}(\lambda_1, \ldots, \lambda_n)\).
For symmetric \(A\): \(P\) is orthogonal (\(P^{-1} = P'\)), so \(A = PDP'\).
Key insight
A matrix transformation is completely pinned down by its eigenvalues and eigenvectors.
If you know the eigenvectors (the special vectors \(A\) scales) and the eigenvalues (the scale factors), you can reconstruct \(A\) entirely.
Our running example
\[ \underbrace{\begin{pmatrix} 3 & 1 \\ 1 & 2 \end{pmatrix}}_{A} = \underbrace{\begin{pmatrix} 1 & 1 \\ 0.62 & -1.62 \end{pmatrix}}_{P} \underbrace{\begin{pmatrix} 3.62 & 0 \\ 0 & 1.38 \end{pmatrix}}_{D} \underbrace{\begin{pmatrix} 1 & 1 \\ 0.62 & -1.62 \end{pmatrix}^{-1}}_{P^{-1}} \]
Eigenvectors with distinct eigenvalues are orthogonal
Let \(A = A'\), \(Av_1 = \lambda_1 v_1\), \(Av_2 = \lambda_2 v_2\) with \(\lambda_1 \neq \lambda_2\).
Show \(v_1' v_2 = 0\).
Orthonormal eigenvectors give \(P^{-1} = P'\)
If \(P\) has orthonormal columns (\(v_i' v_j = 0\) for \(i \neq j\), \(v_i'v_i = 1\)), show \(P'P = I\) and conclude \(P^{-1} = P'\).
Every PD matrix factors as \(K'K\)
Let \(A = PDP'\) with all \(\lambda_i > 0\). Define \(D^{1/2} = \mathrm{diag}(\sqrt{\lambda_1}, \ldots, \sqrt{\lambda_n})\) and set \(K = D^{1/2}P'\).
Show \(K'K = A\) and conclude every PD matrix can be written as \(K'K\) for invertible \(K\).
Solution: orthogonality Solution: inverse = transpose Solution: PD factorization
For this symmetric matrix, \(v_1 \perp v_2\): \(v_1' v_2 = (1)(1) + (0.62)(-1.62) \approx 0\). (See Practice 1 above.)
Definition
Given a symmetric \(n \times n\) matrix \(A\), the quadratic form is the function \[ q(x) = x'Ax \] It takes a vector \(x \in \mathbb{R}^n\) and returns a scalar.
Example: \(A = \begin{pmatrix} 3 & 1 \\ 1 & 2 \end{pmatrix}\)
\[ q(x) = \begin{pmatrix} x_1 & x_2 \end{pmatrix}\begin{pmatrix} 3 & 1 \\ 1 & 2 \end{pmatrix}\begin{pmatrix} x_1 \\ x_2 \end{pmatrix} = 3x_1^2 + 2x_1 x_2 + 2x_2^2 \]
Positive definiteness is the matrix analog of a positive real number: just as \(a > 0\) means \(ax\) never “opposes” \(x\), a PD matrix never produces a negative quadratic form.
Definition
A symmetric matrix \(A\) is positive definite (PD) if \(x'Ax > 0\) for all \(x \neq 0\).
Equivalent characterization via eigenvalues
\(A\) is positive definite \(\;\Longleftrightarrow\;\) all eigenvalues are strictly positive: \(\lambda_i > 0\) for all \(i\).
Since \(\det(A) = \prod_i \lambda_i\), every PD matrix is invertible.
Positive semidefinite (PSD)
\(A\) is positive semidefinite if \(x'Ax \geq 0\) for all \(x\) — equivalently, all \(\lambda_i \geq 0\).
\(A\) is indefinite if it has both positive and negative eigenvalues.
Using the spectral decomposition \(A = PDP'\), let \(z = P'x\) (coordinates along eigenvector directions):
Quadratic form in eigenvector coordinates
\[ x'Ax = x'PDP'x = z'Dz = \lambda_1 z_1^2 + \lambda_2 z_2^2 + \cdots + \lambda_n z_n^2 \]
Why the eigenvalue condition works
The quadratic form is a weighted sum of squares with weights \(\lambda_i\). It is positive for every \(z \neq 0\) if and only if every weight is positive — exactly the PD condition.
Practice: Diagonalizing the quadratic form
Let \(A = PDP'\) be symmetric (\(P\) orthogonal, \(D = \mathrm{diag}(\lambda_1, \ldots, \lambda_n)\)), and set \(z = P'x\).
For any matrix \(X\), \(X'X\) is positive semidefinite: \(\;c'X'Xc = \|Xc\|^2 \geq 0\).
Result
\(X'X\) is positive definite \(\;\Longleftrightarrow\;\) \(X\) has full column rank \(\;\Longleftrightarrow\;\) \(X'X\) is invertible.
Full column rank: \(X'X\) is positive definite
\[X = \begin{pmatrix} 1 & 0 \\ 0 & 1 \\ 1 & 1 \end{pmatrix}\]
For any \(c = (c_1, c_2)' \neq 0\): \(\;c'X'Xc = \|Xc\|^2 = c_1^2 + c_2^2 + (c_1+c_2)^2 > 0\) \(\checkmark\)
Rank deficient: \(X'X\) is only positive semidefinite
\[X = \begin{pmatrix} 1 & 2 \\ 2 & 4 \\ 3 & 6 \end{pmatrix} \quad (\text{col}_2 = 2\cdot\text{col}_1)\]
Take \(c = (2, -1)'\): \(\;Xc = 0\), so \(c'X'Xc = \|Xc\|^2 = 0\) with \(c \neq 0\). \(X'X\) is not PD. ✗
Prove the result: \(X'X\) is PD \(\iff\) \(X\) has full column rank
Key identity: \(c'X'Xc = \|Xc\|^2\).
Cholesky factorization
Every positive definite matrix \(\Sigma\) can be written uniquely as \[ \Sigma = LL' \] where \(L\) is lower triangular with strictly positive diagonal entries.
Example
\[ \begin{pmatrix} 4 & 2 \\ 2 & 3 \end{pmatrix} = \underbrace{\begin{pmatrix} 2 & 0 \\ 1 & \sqrt{2} \end{pmatrix}}_{L} \underbrace{\begin{pmatrix} 2 & 1 \\ 0 & \sqrt{2} \end{pmatrix}}_{L'} \quad\checkmark \]
Core applications
Sampling correlated normals. To draw \(\varepsilon \sim \mathcal{N}(0, \Sigma)\): factor \(\Sigma = LL'\), draw \(z \sim \mathcal{N}(0, I)\), set \(\varepsilon = Lz\). The covariance of \(Lz\) is \(L \cdot I \cdot L' = \Sigma\). \(\checkmark\)
Solving symmetric linear systems stably. Rather than inverting a positive definite matrix \(A\) directly, decompose \(A = LL'\) and solve two triangular systems \(Lv = b\) then \(L'x = v\) to find \(x = A^{-1}b\). Triangular solves are far more numerically stable than direct inversion for ill-conditioned matrices.
For symmetric \(A\), positive definiteness has a clean vector interpretation: \(x'Ax > 0\) means \(x \cdot Ax > 0\), i.e., \(x\) and \(Ax\) always point into the same half-space — they form an acute angle.