Linear Algebra
Study guide: Exam MAS-I
Linear Algebra is the branch of mathematics that studies vectors, matrices and the linear operations on them. In regression it writes the model for all n observations as one equation, \mathbf{y} = \mathbf{X}\boldsymbol\beta + \boldsymbol\varepsilon, where \mathbf{X} is the design matrix.
The product of an m \times q matrix \mathbf{A} and a q \times r matrix \mathbf{B} is the m \times r matrix \mathbf{A}\mathbf{B} whose entry in row i and column j is
(\mathbf{A}\mathbf{B})_{ij} = \sum_{k=1}^{q} a_{ik}\, b_{kj}
a_{ik}is the entry of\mathbf{A}in rowiand columnk, andb_{kj}is the entry of\mathbf{B}in rowkand columnj.- The number of columns of
\mathbf{A}must equal the number of rows of\mathbf{B}.
A design matrix has rows
(1, 2),(1, 5)and(1, 8), and the estimated coefficients are\hat\beta_0 = 1.0and\hat\beta_1 = 0.5. What are the fitted values\mathbf\hat?
\mathbf{X}is3 \times 2and\hat{\boldsymbol\beta}is2 \times 1, so the product is a3 \times 1vector.- Each entry is a row of
\mathbf{X}multiplied entry by entry with\hat{\boldsymbol\beta}and summed:1(1.0) + 2(0.5) = 2.0,1(1.0) + 5(0.5) = 3.5and1(1.0) + 8(0.5) = 5.0.- The fitted values are
2.0,3.5and5.0.
The matrix \mathbf{X}^T\mathbf{X}
The transpose \mathbf{X}^T has the rows of \mathbf{X} as its columns. The entry of \mathbf{X}^T\mathbf{X} in row j and column k is
(\mathbf{X}^T\mathbf{X})_{jk} = \sum_{i=1}^{n} x_{ij}\, x_{ik}
x_{ij}is the entry of\mathbf{X}for observationiin columnj.
A diagonal entry (\mathbf{X}^T\mathbf{X})_{jj} is the sum of squares of column j. For the intercept column, whose entries are all 1, it is the number of observations n, and the off-diagonal entries in that row are the column sums of the other columns.
The design matrix has rows
(1, 1),(1, 2)and(1, 3). What is\mathbf^T\mathbf?
- The intercept column's sum of squares is
1 + 1 + 1 = 3, the number of observations.- The second column's sum of squares is
1 + 4 + 9 = 14.- The off-diagonal entry is the sum of products of the two columns,
1 + 2 + 3 = 6.- So
\mathbf{X}^T\mathbf{X}has rows(3, 6)and(6, 14).
The inverse of a matrix
The inverse of a square matrix \mathbf{A} is the matrix \mathbf{A}^{-1} with \mathbf{A}\mathbf{A}^{-1} = \mathbf{I}, the identity matrix. It exists only when the determinant of \mathbf{A} is not zero. The inverse of a 2 \times 2 matrix is
\begin{bmatrix} a & b \\ c & d \end{bmatrix}^{-1} = \frac{1}{ad - bc}\begin{bmatrix} d & -b \\ -c & a \end{bmatrix}
ad - bcis the determinant, andad - bc \ne 0.
What is the inverse of the matrix with rows
(3, 6)and(6, 14)?
- The determinant is
3(14) - 6(6) = 6.- Swapping the diagonal entries and changing the sign of the off-diagonal entries gives rows
(14, -6)and(-6, 3).- The inverse is
\frac{1}{6}times that matrix, with rows(2.3333, -1)and(-1, 0.5).
Eigenvalues and eigenvectors
A nonzero vector \mathbf{v} is an eigenvector of a square matrix \mathbf{A}, with eigenvalue \lambda, when
\mathbf{A}\mathbf{v} = \lambda \mathbf{v}
The eigenvalues are the solutions of \det(\mathbf{A} - \lambda \mathbf{I}) = 0. The eigenvectors of a covariance matrix are the directions of the principal components, and each eigenvalue is the variance along its component.
Two standardized variables have the covariance matrix with rows
(1, 0.6)and(0.6, 1). What are its eigenvalues, and what share of the total variance does the first principal component explain?
- The eigenvalues solve
(1 - \lambda)^2 - 0.6^2 = 0, so1 - \lambda = \pm 0.6.- The eigenvalues are
1.6and0.4.- The first principal component explains
1.6/(1.6 + 0.4) = 80\%of the total variance.