Appendix A — Matrix Results Used in Regression

This appendix collects the results from matrix algebra used in the book. Proofs can be found in Rao (1973) and in standard texts on matrix algebra for statistics.

A.1 Basic operations

  • Transpose: \((\mathbf A\mathbf B)'=\mathbf B'\mathbf A'\); \((\mathbf A')'=\mathbf A\). A matrix is symmetric if \(\mathbf A'=\mathbf A\); \(\mathbf X'\mathbf X\) is always symmetric.
  • Inverse: for a non-singular square \(\mathbf A\), \(\mathbf A\mathbf A^{-1}=\mathbf A^{-1}\mathbf A=\mathbf I\); \((\mathbf A\mathbf B)^{-1}=\mathbf B^{-1}\mathbf A^{-1}\); \((\mathbf A')^{-1}=(\mathbf A^{-1})'\). The inverse of a symmetric matrix is symmetric. For a \(2\times2\) matrix, \[\begin{bmatrix}a&b\\c&d\end{bmatrix}^{-1}=\frac1{ad-bc}\begin{bmatrix}d&-b\\-c&a\end{bmatrix}.\]
  • Scalar transpose: a \(1\times1\) matrix equals its transpose, so \(\mathbf y'\mathbf X\boldsymbol\beta=\boldsymbol\beta'\mathbf X'\mathbf y\).

A.2 Rank

The rank of a matrix is the maximum number of linearly independent columns (equivalently rows). For \(\mathbf X\) of order \(n\times p\): \(\operatorname{rank}(\mathbf X)\le\min(n,p)\), and \(\operatorname{rank}(\mathbf X'\mathbf X)=\operatorname{rank}(\mathbf X)\). \(\mathbf X\) has full column rank if \(\operatorname{rank}(\mathbf X)=p\); then \(\mathbf X'\mathbf X\) is non-singular.

A.3 Trace

The trace of a square matrix is the sum of its main diagonal elements; it is defined only for square matrices.

  1. \(\operatorname{tr}(\mathbf A+\mathbf B)=\operatorname{tr}(\mathbf A)+\operatorname{tr}(\mathbf B)\); \(\operatorname{tr}(c\mathbf A)=c\operatorname{tr}(\mathbf A)\).
  2. \(\operatorname{tr}(\mathbf A\mathbf B)=\operatorname{tr}(\mathbf B\mathbf A)\) whenever both products exist (even if \(\mathbf A\) and \(\mathbf B\) are not square). More generally the trace is invariant under cyclic permutation: \(\operatorname{tr}(\mathbf A\mathbf B\mathbf C)=\operatorname{tr}(\mathbf C\mathbf A\mathbf B)\).
  3. The trace of a matrix equals the sum of its eigenvalues.
  4. For a scalar \(a=\mathbf x'\mathbf A\mathbf x\), \(a=\operatorname{tr}(a)=\operatorname{tr}(\mathbf A\mathbf x\mathbf x')\).

A.4 Determinant

\(|\mathbf A\mathbf B|=|\mathbf A||\mathbf B|\); \(|\mathbf A^{-1}|=1/|\mathbf A|\); \(|c\mathbf A|=c^n|\mathbf A|\) for \(n\times n\) \(\mathbf A\); \(|\mathbf A|\) equals the product of the eigenvalues. \(\mathbf A\) is singular if and only if \(|\mathbf A|=0\). For a rank-one update, \(|\mathbf A-\mathbf x\mathbf x'|=|\mathbf A|(1-\mathbf x'\mathbf A^{-1}\mathbf x)\) (used for COVRATIO).

A.5 Eigenvalues and eigenvectors

\(\lambda\) is an eigenvalue and \(\mathbf t\ (\neq\mathbf 0)\) an eigenvector of \(\mathbf A\) if \(\mathbf A\mathbf t=\lambda\mathbf t\). A real symmetric matrix has real eigenvalues and orthogonal eigenvectors, and has the spectral decomposition \(\mathbf A=\mathbf T\boldsymbol\Lambda\mathbf T'=\sum\lambda_j\mathbf t_j\mathbf t_j'\), with \(\mathbf T'\mathbf T=\mathbf I\). Then \(\mathbf A^{-1}=\mathbf T\boldsymbol\Lambda^{-1}\mathbf T'\), so small eigenvalues produce large elements in the inverse (multicollinearity).

A.6 Definite matrices

A symmetric matrix \(\mathbf A\) is

  • positive definite if \(\mathbf c'\mathbf A\mathbf c>0\) for all \(\mathbf c\neq\mathbf 0\) (all eigenvalues positive);
  • positive semi-definite (non-negative definite) if \(\mathbf c'\mathbf A\mathbf c\ge0\) for all \(\mathbf c\) (all eigenvalues non-negative).

\(\mathbf X'\mathbf X\) is positive semi-definite always, and positive definite when \(\mathbf X\) has full column rank, since \(\mathbf c'\mathbf X'\mathbf X\mathbf c=\|\mathbf X\mathbf c\|^2\). A positive definite matrix has a Cholesky factorization \(\mathbf A=\mathbf L\mathbf L'\) with \(\mathbf L\) lower triangular.

A.7 Idempotent matrices

\(\mathbf A\) is idempotent if \(\mathbf A\mathbf A=\mathbf A\).

  1. The eigenvalues of an idempotent matrix are 0 or 1.
  2. For a symmetric idempotent matrix, \(\operatorname{rank}(\mathbf A)=\operatorname{tr}(\mathbf A)\).
  3. If \(\mathbf A\) is idempotent, so is \(\mathbf I-\mathbf A\), and \(\mathbf A(\mathbf I-\mathbf A)=\mathbf 0\).
  4. Symmetric idempotent matrices are orthogonal projection matrices. \(\mathbf H=\mathbf X(\mathbf X'\mathbf X)^{-1}\mathbf X'\) projects onto the column space of \(\mathbf X\); \(\mathbf I-\mathbf H\) onto its orthogonal complement; \(\frac1n\mathbf J=\frac1n\mathbf 1\mathbf 1'\) onto the vector of ones.

A.8 Generalized inverses

A generalized inverse (g-inverse) of an \(m\times n\) matrix \(\mathbf A\) is any \(n\times m\) matrix \(\mathbf G\) with \(\mathbf A\mathbf G\mathbf A=\mathbf A\). It always exists, and is unique (equal to \(\mathbf A^{-1}\)) only when \(\mathbf A\) is non-singular. The Moore–Penrose inverse \(\mathbf A^+\) is the unique g-inverse satisfying in addition \(\mathbf G\mathbf A\mathbf G=\mathbf G\), \((\mathbf A\mathbf G)'=\mathbf A\mathbf G\) and \((\mathbf G\mathbf A)'=\mathbf G\mathbf A\).

If \(\mathbf G\) is a g-inverse of \(\mathbf X'\mathbf X\), then:

  1. \(\mathbf G'\) is also a g-inverse of \(\mathbf X'\mathbf X\).
  2. \(\mathbf X\mathbf G\mathbf X'\mathbf X=\mathbf X\) and \(\mathbf X'\mathbf X\mathbf G\mathbf X'=\mathbf X'\).
  3. \(\mathbf X\mathbf G\mathbf X'\) is invariant to the choice of \(\mathbf G\), symmetric and idempotent; it equals the hat matrix \(\mathbf H\).
  4. \(\boldsymbol\beta^0=\mathbf G\mathbf X'\mathbf y\) is a solution of the normal equations \(\mathbf X'\mathbf X\boldsymbol\beta=\mathbf X'\mathbf y\).

A.9 Inverse of a partitioned matrix

If \(\mathbf A=\begin{bmatrix}\mathbf A_{11}&\mathbf A_{12}\\\mathbf A_{21}&\mathbf A_{22}\end{bmatrix}\) with \(\mathbf A_{11}\) non-singular and \(\mathbf S=\mathbf A_{22}-\mathbf A_{21}\mathbf A_{11}^{-1}\mathbf A_{12}\) (the Schur complement) non-singular, then

\[\mathbf A^{-1}=\begin{bmatrix}\mathbf A_{11}^{-1}+\mathbf A_{11}^{-1}\mathbf A_{12}\mathbf S^{-1}\mathbf A_{21}\mathbf A_{11}^{-1}&-\mathbf A_{11}^{-1}\mathbf A_{12}\mathbf S^{-1}\\-\mathbf S^{-1}\mathbf A_{21}\mathbf A_{11}^{-1}&\mathbf S^{-1}\end{bmatrix}.\]

This result underlies the extra sum of squares, partial regression coefficients and the formula \(C_{jj}=1/(1-R_j^2)\) in correlation form.

A.10 Sherman–Morrison–Woodbury formula

For non-singular \(\mathbf A\) and vectors \(\mathbf u\), \(\mathbf v\) with \(1+\mathbf v'\mathbf A^{-1}\mathbf u\neq0\),

\[(\mathbf A+\mathbf u\mathbf v')^{-1}=\mathbf A^{-1}-\frac{\mathbf A^{-1}\mathbf u\mathbf v'\mathbf A^{-1}}{1+\mathbf v'\mathbf A^{-1}\mathbf u}.\]

With \(\mathbf A=\mathbf X'\mathbf X\), \(\mathbf u=-\mathbf x_i\), \(\mathbf v=\mathbf x_i\), this gives the deletion formula used for PRESS residuals and influence measures (Sherman and Morrison 1950):

\[\left[\mathbf X'\mathbf X-\mathbf x_i\mathbf x_i'\right]^{-1}=(\mathbf X'\mathbf X)^{-1}+\frac{(\mathbf X'\mathbf X)^{-1}\mathbf x_i\mathbf x_i'(\mathbf X'\mathbf X)^{-1}}{1-h_{ii}}.\]

Verification: multiply the right-hand side by \(\mathbf X'\mathbf X-\mathbf x_i\mathbf x_i'\) and use \(\mathbf x_i'(\mathbf X'\mathbf X)^{-1}\mathbf x_i=h_{ii}\); the product simplifies to \(\mathbf I\).

A.11 Vector differentiation

For a \(p\times1\) vector \(\boldsymbol\beta\), a constant vector \(\mathbf a\) and a constant matrix \(\mathbf A\):

\[\frac{\partial(\mathbf a'\boldsymbol\beta)}{\partial\boldsymbol\beta}=\frac{\partial(\boldsymbol\beta'\mathbf a)}{\partial\boldsymbol\beta}=\mathbf a,\qquad \frac{\partial(\boldsymbol\beta'\mathbf A\boldsymbol\beta)}{\partial\boldsymbol\beta}=(\mathbf A+\mathbf A')\boldsymbol\beta=2\mathbf A\boldsymbol\beta\ \text{(if }\mathbf A\text{ symmetric)}.\]

The matrix of second derivatives of \(\boldsymbol\beta'\mathbf A\boldsymbol\beta\) (symmetric \(\mathbf A\)) is \(2\mathbf A\).

A.12 Expectation and covariance of random vectors

For a random vector \(\mathbf y\) with \(E(\mathbf y)=\boldsymbol\mu\) and \(V(\mathbf y)=\boldsymbol\Sigma\), and constant \(\mathbf A\), \(\mathbf b\):

  1. \(E(\mathbf A\mathbf y+\mathbf b)=\mathbf A\boldsymbol\mu+\mathbf b\), \(V(\mathbf A\mathbf y+\mathbf b)=\mathbf A\boldsymbol\Sigma\mathbf A'\).
  2. \(Cov(\mathbf A\mathbf y,\mathbf B\mathbf y)=\mathbf A\boldsymbol\Sigma\mathbf B'\).
  3. Expectation of a quadratic form: \(E(\mathbf y'\mathbf A\mathbf y)=\operatorname{tr}(\mathbf A\boldsymbol\Sigma)+\boldsymbol\mu'\mathbf A\boldsymbol\mu\).

A.13 Distribution of quadratic forms

Let \(\mathbf y\sim N_n(\boldsymbol\mu,\sigma^2\mathbf I)\) and let \(\mathbf A\) be symmetric.

  1. \(\mathbf y'\mathbf A\mathbf y/\sigma^2\) has a (non-central) chi-square distribution with \(\operatorname{rank}(\mathbf A)\) degrees of freedom and non-centrality \(\boldsymbol\mu'\mathbf A\boldsymbol\mu/\sigma^2\) if and only if \(\mathbf A\) is idempotent. It is central when \(\mathbf A\boldsymbol\mu=\mathbf 0\).
  2. Two quadratic forms \(\mathbf y'\mathbf A\mathbf y\) and \(\mathbf y'\mathbf B\mathbf y\) are independent if and only if \(\mathbf A\mathbf B=\mathbf 0\).
  3. A linear form \(\mathbf L\mathbf y\) and a quadratic form \(\mathbf y'\mathbf A\mathbf y\) are independent if \(\mathbf L\mathbf A=\mathbf 0\).
  4. Cochran’s theorem: if \(\mathbf y'\mathbf y=\sum_{j}\mathbf y'\mathbf A_j\mathbf y\) with \(\sum\operatorname{rank}(\mathbf A_j)=n\), then the quadratic forms are independent chi-squares (times \(\sigma^2\)).

Applied to regression: \(SS_{Res}=\mathbf y'(\mathbf I-\mathbf H)\mathbf y\) with \((\mathbf I-\mathbf H)\mathbf X\boldsymbol\beta=\mathbf 0\) gives \(SS_{Res}/\sigma^2\sim\chi^2_{n-p}\); \(\hat{\boldsymbol\beta}=(\mathbf X'\mathbf X)^{-1}\mathbf X'\mathbf y\) is independent of \(SS_{Res}\) because \((\mathbf X'\mathbf X)^{-1}\mathbf X'(\mathbf I-\mathbf H)=\mathbf 0\); and \(SS_R\) and \(SS_{Res}\) are independent because \((\mathbf H-\frac1n\mathbf J)(\mathbf I-\mathbf H)=\mathbf 0\).

A.14 Matrix computations in R

A <- matrix(c(12, 52, 102, 52, 296, 536, 102, 536, 1004), 3)
t(A); solve(A); det(A); sum(diag(A))      # transpose, inverse, determinant, trace
eigen(A)                                  # eigenvalues and eigenvectors
chol(A)                                   # Cholesky factor (upper triangular)
qr(A)$rank                                # rank
MASS::ginv(A)                             # Moore-Penrose inverse
crossprod(X)                              # X'X, faster than t(X) %*% X