数量経済分析 図解ポータル
Chapter 4  ·  Part I 基礎  ·  原典 P.19–24

行列代数の復習

OLS 推定量 \(\hat{\boldsymbol{\beta}} = (X'X)^{-1}X'y\) を書き下すための行列の言語を整備する。ベクトルと行列の基本演算から始め、転置・逆行列・ランク・正値定符号性まで、計量経済学で必須となる道具をひとつずつ組み上げていく。

ベクトル 行列演算 逆行列 X'X 転置
川崎賢太郎(東京大学大学院農学生命科学研究科) 原典 P.19–24 Review of matrix algebra
図解で読む 原文に忠実な和訳
Contents
  1. 01. 行列の定義と記法
  2. 02. ベクトル(行ベクトル・列ベクトル)
  3. 03. 行列の加減算とスカラー倍
  4. 04. 行列の積
  5. 05. 行列積の性質
  6. 06. 単位行列 \(I\)
  7. 07. 転置(Transpose)
  8. 08. 逆行列(Matrix Inverse)
  9. 09. 線形独立とランク
  10. 10. 二次形式と正値定符号性
  11. 11. 計量経済学で頻出する表現:\(X'X\) と \(X'u\)
SECTION 01

行列の定義と記法

\(m \times n\) 型の行列 \(A\) とは、\(m\) 行 \(n\) 列の数の配列である。

A matrix A of size \(m \times n\) has the form
(\(m \times n\) 型の行列 \(A\) は以下の形をとる。)
\[ A = \begin{pmatrix} a_{11} & a_{12} & \cdots & a_{1n} \\ a_{21} & a_{22} & \cdots & a_{2n} \\ \vdots & \vdots & & \vdots \\ a_{m1} & a_{m2} & \cdots & a_{mn} \end{pmatrix} \]

\(a_{ij}\) は行列 \(A\) の第 \(i\) 行・第 \(j\) 列の要素(element)を表す。

用語説明
\(m \times n\)行列のサイズ(型)。\(m\) が行数、\(n\) が列数。
\(a_{ij}\)第 \(i\) 行・第 \(j\) 列の要素。例: \(a_{12}\) は第1行第2列。
例題(P.19): \( A = \begin{pmatrix} -5 & 10 & 0 & 1 \\ 3 & 2 & -5 & 1 \end{pmatrix} \) のとき、サイズは \(2 \times 4\) であり、\(a_{12} = 10\)、\(a_{23} = -5\) である。
参照文献

本章の内容は Wooldridge, Introductory Econometrics(IE)付録 D に基づく。行列代数の詳細な証明については Greene の付録 A も参照せよ。

原典 P.19 冒頭 "[Reference] Wooldridge, IE, Appendix D"。
SECTION 02

ベクトル(行ベクトル・列ベクトル)

行が1つの行列を行ベクトル(row vector)、列が1つの行列を列ベクトル(column vector)という。

A row vector is a matrix with one row. A column vector is a matrix with one column.
(行ベクトルは行が1つの行列である。列ベクトルは列が1つの行列である。)
Row Vector(行ベクトル)

1行 \(n\) 列の行列

例: \[ C = \begin{pmatrix} 3 & -4 & 8 & 1 \end{pmatrix} \] は \(1 \times 4\) の行ベクトルである。

Column Vector(列ベクトル)

\(m\) 行 1 列の行列

例: \[ D = \begin{pmatrix} 0 \\ 1 \\ 4 \end{pmatrix} \] は \(3 \times 1\) の列ベクトルである。

計量経済学では、誤差項のベクトル \(\boldsymbol{u} = (u_1, u_2, \dots, u_N)'\) や被説明変数のベクトル \(\boldsymbol{y} = (y_1, y_2, \dots, y_N)'\) のように、列ベクトルが標準的な形式として用いられる。
SECTION 03

行列の加減算とスカラー倍

行列の加算・減算はサイズが同じ行列同士でのみ行える。対応する成分ごとに加減する。

Matrices can only be added and subtracted if they have the same size. To add or subtract matrices, we add or subtract each corresponding component.
(行列を加算・減算できるのは、同じサイズの行列同士に限られる。加算・減算は各対応成分に対して行う。)

例題(P.19)

\( A = \begin{pmatrix} -3 & 2 \\ 2 & 1 \\ 5 & 0 \end{pmatrix} \)、 \( B = \begin{pmatrix} 0 & -5/2 \\ 1 & 2 \\ 3 & -1 \end{pmatrix} \) のとき、

\[ 5A - 2B = 5\begin{pmatrix} -3 & 2 \\ 2 & 1 \\ 5 & 0 \end{pmatrix} - 2\begin{pmatrix} 0 & -5/2 \\ 1 & 2 \\ 3 & -1 \end{pmatrix} = \begin{pmatrix} -15 & 10 \\ 10 & 5 \\ 25 & 0 \end{pmatrix} - \begin{pmatrix} 0 & -5 \\ 2 & 4 \\ 6 & -2 \end{pmatrix} = \begin{pmatrix} -15 & 15 \\ 8 & 1 \\ 19 & 2 \end{pmatrix} \]

加算・スカラー倍の基本規則(P.19–20)

\(A\)、\(B\)、\(C\) を同サイズの行列、\(c\) と \(d\) をスカラーとする。

1

交換則(commutative)

\(A + B = B + A\)(行列の加算は交換可能)

2

結合則(associative)

\((A + B) + C = A + (B + C)\)(行列の加算は結合可能)

3

スカラー倍の結合

\(c \cdot d(A) = (cd)A\)

4

スカラー倍の分配

\(c(A + B) = cA + cB\)

SECTION 04

行列の積(Matrix Multiplication)

行列の積を理解するには、まず行ベクトル × 列ベクトルの積を理解する必要がある。

To understand matrix multiplication, one must first understand how to multiply a row vector times a column vector.
(行列の積を理解するためには、まず行ベクトルと列ベクトルの積の計算を理解しなければならない。)

行ベクトル × 列ベクトル = スカラー

\(A = [a_{11}, a_{12}, \dots, a_{1n}]\) が \(1 \times n\) の行ベクトル、\(B = \begin{pmatrix} b_{11} \\ b_{21} \\ \vdots \\ b_{n1} \end{pmatrix}\) が \(n \times 1\) の列ベクトルのとき、積 \(AB\) は各対応成分を掛け合わせて加えたスカラーである。

\[ AB = [a_{11}, a_{12}, \dots, a_{1n}] \begin{pmatrix} b_{11} \\ b_{21} \\ \vdots \\ b_{n1} \end{pmatrix} = a_{11}b_{11} + a_{12}b_{21} + \cdots + a_{1n}b_{n1} \]
例題(P.20): \(A = [1 \;-1\; 0\; 4]\)、\(B = \begin{pmatrix}3\\-5\\1\\-1\end{pmatrix}\) のとき、
\(AB = (1)(3)+(-1)(-5)+(0)(1)+(4)(-1) = 3+5+0-4 = 4\)

一般の行列積

\(A\) が \(m \times n\) 型、\(B\) が \(n \times p\) 型のとき、積 \(C = AB\) は \(m \times p\) 型の行列であり、各要素 \(c_{ij}\) は \(A\) の第 \(i\) 行ベクトルと \(B\) の第 \(j\) 列ベクトルの積(内積)として求まる。

\[ c_{ij} = (\text{行列 } A \text{ の第 } i \text{ 行}) \cdot (\text{行列 } B \text{ の第 } j \text{ 列}) \]
積が存在する条件:左辺の行列 \(A\) の列数が、右辺の行列 \(B\) の行数に等しくなければならない。 積のサイズは(\(A\) の行数)\(\times\)(\(B\) の列数)になる。 図示すると: \(\underbrace{A}_{m \times n} \cdot \underbrace{B}_{n \times p} = \underbrace{C}_{m \times p}\)(中の \(n\) が一致する必要がある)

例題(P.21)

\( A = \begin{pmatrix} 1 & -3 \\ 0 & 2 \end{pmatrix} \)(\(2 \times 2\))、 \( B = \begin{pmatrix} 1 & 0 & -2 \\ -1 & 2 & 3 \end{pmatrix} \)(\(2 \times 3\))のとき、

\[ AB = \begin{pmatrix} 1 & -3 \\ 0 & 2 \end{pmatrix} \begin{pmatrix} 1 & 0 & -2 \\ -1 & 2 & 3 \end{pmatrix} = \begin{pmatrix} (1)(1)+(-3)(-1) & (1)(0)+(-3)(2) & (1)(-2)+(-3)(3) \\ (0)(1)+(2)(-1) & (0)(0)+(2)(2) & (0)(-2)+(2)(3) \end{pmatrix} = \begin{pmatrix} 4 & -6 & -11 \\ -2 & 4 & 6 \end{pmatrix} \]

積のサイズが \(2 \times 3\) になるのは、\(A\) が \(2 \times 2\)、\(B\) が \(2 \times 3\) であり、内側の \(2\) が一致していることから確認できる。

SECTION 05

行列積の性質(Multiplicative Properties)

行列積はサイズが乗法的に適合する行列 \(A\)、\(B\)、\(C\) およびスカラー \(c\) について、以下の5つの性質をもつ。

1

結合則(associative)

\((AB)C = A(BC)\)

2

左分配則(left distributive)

\(A(B + C) = AB + AC\)

3

右分配則(right distributive)

\((A + B)C = AC + BC\)

4

スカラーとの結合

\(c(AB) = (cA)B = A(cB)\)

5

一般に非可換(非交換則)

一般に \(AB \neq BA\)。スカラー積と異なり、行列積の順序は変えられない。

注意:スカラーの乗算では \(ab = ba\) が成り立つが、行列積では一般に \(AB \neq BA\) である。この非可換性は計量経済学の行列式変形で頻繁に重要になる。
SECTION 06

単位行列 \(I\)(Identity Matrix)

\(n \times n\) の単位行列 \(I\) は、対角成分がすべて 1、非対角成分がすべて 0 の正方行列である。スカラーの「1」に相当する役割を果たす。

\[ I = \begin{pmatrix} 1 & 0 & 0 & \cdots & 0 \\ 0 & 1 & 0 & \cdots & 0 \\ 0 & 0 & 1 & \cdots & 0 \\ \vdots & \vdots & \vdots & \ddots & 0 \\ 0 & 0 & 0 & \cdots & 1 \end{pmatrix} \]

\(A\) が \(m \times n\) 型の行列のとき、

\[ A I_n = I_m A = A \]
単位行列 \(I\) は正値定符号(positive definite)である。証明:\(\mathbf{x}' I \mathbf{x} = \mathbf{x}'\mathbf{x} > 0\)(\(\mathbf{x} \neq \mathbf{0}\) のとき)。(P.23)
SECTION 07

転置(Transpose)

行列 \(A\) の転置 \(A'\)(あるいは \(A^T\))は、行と列を入れ替えて得られる行列である。

例(P.21): \( A = \begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{pmatrix} \) のとき、 \( A' = \begin{pmatrix} 1 & 4 \\ 2 & 5 \\ 3 & 6 \end{pmatrix} \)

転置の性質(Properties of transpose)

性質意味
スカラー倍 \((aA)' = a A'\) スカラー倍を転置の外に出せる
積の転置 \((AB)' = B' A'\) 順序が逆転することに注意
和の転置 \((A + B)' = A' + B'\) 各行列を転置してから加える
対称行列 \(A = A'\) ならば \(A\) は対称行列 例:\(X'X\) は対称行列
計量経済学での重要性:\((AB)' = B'A'\) という性質は、OLS の正規方程式や分散行列の導出で繰り返し使われる。たとえば \(X'X\) は \((X'X)' = X' (X')' = X'X\) であるから、対称行列になる。
SECTION 08

逆行列(Matrix Inverse)

\(n \times n\) 型の正方行列 \(A\) に対し、\(AA^{-1} = A^{-1}A = I\) を満たす行列 \(A^{-1}\) が存在するとき、これを \(A\) の逆行列(inverse)という。

The inverse of a \(n \times n\) matrix \(A\), if it exists, is denoted by \(A^{-1}\), and is defined to be the \(n \times n\) matrix where
\( AA^{-1} = A^{-1}A = I \)
(\(n \times n\) 型の行列 \(A\) の逆行列は、存在する場合 \(A^{-1}\) で表し、\(AA^{-1} = A^{-1}A = I\) を満たす \(n \times n\) 型の行列として定義される。)

\(A^{-1}\) が一意(unique)であることが示せる。また逆行列が存在するのは、行数と列数が等しい正方行列(square matrix)に限られる。

例題:逆行列の検証(P.22)

\( A = \begin{pmatrix} 1 & -1 \\ 2 & 3 \end{pmatrix} \) の逆行列が \( A^{-1} = \begin{pmatrix} 3/5 & 1/5 \\ -2/5 & 1/5 \end{pmatrix} \) であることを確認する。

\[ A^{-1} A = \begin{pmatrix} 3/5 & 1/5 \\ -2/5 & 1/5 \end{pmatrix} \begin{pmatrix} 1 & -1 \\ 2 & 3 \end{pmatrix} = \begin{pmatrix} 3/5 + 2/5 & -3/5 + 3/5 \\ -2/5 + 2/5 & 2/5 + 3/5 \end{pmatrix} = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix} = I \]
同様に \(AA^{-1} = I\) も計算で確認できる。原典 P.22。

\(2 \times 2\) 行列の逆行列の公式(P.22)

\( A = \begin{pmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{pmatrix} \) に対し、\(A^{-1}\) が存在するのは \(\det(A) \neq 0\) のときに限られる。このとき、

\[ A^{-1} = \frac{1}{\det(A)} \begin{pmatrix} a_{22} & -a_{12} \\ -a_{21} & a_{11} \end{pmatrix} \]

公式の行列部分は、主対角成分(\(a_{11}\) と \(a_{22}\))を入れ替え、副対角成分(\(a_{12}\) と \(a_{21}\))の符号を反転させることで得られる。

逆行列の性質(P.22)

性質
スカラー倍の逆\((aA)^{-1} = \frac{1}{a} A^{-1}\)
積の逆(順序逆転)\((AB)^{-1} = B^{-1} A^{-1}\)
転置との交換\((A')^{-1} = (A^{-1})'\)
\((AB)^{-1} = B^{-1}A^{-1}\)(積の転置と同様に順序が逆転する)。この性質は、OLS 推定量 \(\hat{\boldsymbol{\beta}} = (X'X)^{-1}X'y\) の導出・変形で必須となる。
SECTION 09

線形独立とランク(Linear Dependence & Rank)

行列のランクは線形独立な列の最大数である。逆行列の存在・OLS 推定量の一意性と直結する概念だ。

線形従属(Linear Dependence)

\(a_1 x_1 + a_2 x_2 + \cdots + a_r x_r = 0\)
If some non-zero \(a\)'s satisfy this equation, then \(x\)'s are linearly dependent.
(ゼロでない係数 \(a\) でこの等式を満たすものが存在するとき、ベクトル \(x\) たちは線形従属(linearly dependent)である。)

ランク(Rank)

行列のランク \(\mathrm{rank}(A)\) とは、\(A\) の線形独立な列の最大数である。

条件呼称意味
\(A\) が \(m \times n\) で \(\mathrm{rank}(A) = n\) 列フルランク(full column rank) すべての列が線形独立
\(A\) が \(n \times n\) で \(\mathrm{rank}(A) = n\) 非特異(non-singular) 逆行列 \(A^{-1}\) が存在する
例題(P.22):
\( A = \begin{pmatrix} 1 & 10 \\ 2 & 20 \\ 3 & 30 \end{pmatrix} \):第2列は第1列の10倍であり、列は線形従属。\(\mathrm{rank}(A) = 1\)。
\( B = \begin{pmatrix} 1 & 2 \\ 2 & 2 \\ 3 & -1 \end{pmatrix} \):2つの列は線形独立。\(\mathrm{rank}(B) = 2\)。
多重共線性(multicollinearity)は \(X\) が列フルランクでない(いずれかの列が他の列の線形結合)状態であり、\((X'X)^{-1}\) が存在しなくなる。OLS 推定量が計算できなくなる直接の原因である。
SECTION 10

二次形式と正値定符号性(Quadratic Form & Positive Definiteness)

\(n \times n\) 対称行列 \(A\) と \(n \times 1\) ベクトル \(\mathbf{x}\) に対し、\(\mathbf{x}'A\mathbf{x}\) を二次形式(quadratic form)という。

Let A be an \(n \times n\) symmetric matrix. Then quadratic form is defined for all \(n \times 1\) vectors \(\mathbf{x}\): \[ \mathbf{x}'A\mathbf{x} = \sum_i a_{ii} x_i^2 + 2\sum_{i < j} a_{ij} x_i x_j \] (\(n \times n\) 対称行列 \(A\) とすべての \(n \times 1\) ベクトル \(\mathbf{x}\) に対して二次形式が定義される。)

例題(P.23)

\( A = \begin{pmatrix} 1 & 3 \\ 3 & 4 \end{pmatrix} \)、\( \mathbf{x} = \begin{pmatrix} x_1 \\ x_2 \end{pmatrix} \) のとき、

\[ \mathbf{x}'A\mathbf{x} = \begin{pmatrix} x_1 & x_2 \end{pmatrix} \begin{pmatrix} 1 & 3 \\ 3 & 4 \end{pmatrix} \begin{pmatrix} x_1 \\ x_2 \end{pmatrix} = x_1^2 + 4x_2^2 + 6x_1 x_2 \]

正値定符号性の定義と判定

Positive Definite(正値定符号)

\(\mathbf{x}'A\mathbf{x} > 0\)

\(\mathbf{x} \neq \mathbf{0}\) であるすべての \(\mathbf{x}\) に対して成り立つ。

Positive Semi-Definite(半正値定符号 / nonneg. def.)

\(\mathbf{x}'A\mathbf{x} \geq 0\)

\(\mathbf{x} \neq \mathbf{0}\) であるすべての \(\mathbf{x}\) に対して成り立つ。

正値定符号行列の性質(P.23)

対称行列 \(A\) は \(A = C\Lambda C'\) と分解できる(\(\Lambda\) は固有値の対角行列)。二次形式は \(\mathbf{x}'A\mathbf{x} = \mathbf{y}'\Lambda\mathbf{y} = \sum_i \lambda_i y_i^2\)(\(\mathbf{y} = C'\mathbf{x}\))と書ける。したがってすべての固有値 \(\lambda_i\) が正であれば、\(\mathbf{x}\) の取り方によらず二次形式は正になる。

\(A\) が半正値定符号ならば \(|A| \geq 0\)

行列式は固有値の積であり、固有値がすべて非負ならば積も非負。逆は一般に成り立たない(2つの負の固有値をもつ行列は、行列式が正でも正値定符号ではない)。

\(A\) が正値定符号ならば \(A^{-1}\) も正値定符号

正値定符号行列の逆行列も正値定符号。OLS の分散行列が正値定符号であることの根拠になる。

回帰分析における重要な結果(P.23)

\(A\) が \(n \times K\) で列フルランク(\(n > K\))ならば、\(A'A\) は正値定符号、\(AA'\) は半正値定符号。すなわち設計行列 \(X\) が列フルランクであれば \(X'X\) は正値定符号であり、\((X'X)^{-1}\) が存在する

\(A\) が正値定符号、\(B\) が非特異ならば \(B'AB\) も正値定符号

SECTION 11

計量経済学で頻出する表現:\(X'X\) と \(X'u\)

計量経済学では \(X'X\) や \(X'u\) という表現が繰り返し現れる。簡単な例でその構造を確認しておく。

In econometrics, often we use expressions like \(\boldsymbol{X}'\boldsymbol{X}\) or \(\boldsymbol{X}'\boldsymbol{u}\).
For simplicity, suppose there are only three samples (\(N = 3\)) and two regressors (\(k = 2\)).
(計量経済学では \(X'X\) や \(X'u\) のような表現をしばしば用いる。簡単のため、標本数 \(N = 3\)、説明変数の数 \(k = 2\) の場合を考える。)

設定

設計行列(design matrix)\(X\) と誤差ベクトル \(\boldsymbol{u}\) を次のように定義する。 同じ色は同じ標本 \(i\) を示す。

\[ X = \begin{pmatrix} x_{11} & x_{21} \\ x_{12} & x_{22} \\ x_{13} & x_{23} \end{pmatrix} \quad (N \times k = 3 \times 2), \qquad \boldsymbol{u} = \begin{pmatrix} u_1 \\ u_2 \\ u_3 \end{pmatrix} \quad (N \times 1 = 3 \times 1) \]
添え字の読み方について

\(x_{ji}\) の第1添え字 \(j\) は変数番号(説明変数の番号)、第2添え字 \(i\) は標本番号(個体・観測番号)を表す。 \(x_{11}\) は「第1変数の第1標本」、\(x_{23}\) は「第2変数の第3標本」である。

\(X'X\) の計算(次元 \(k \times k\))

転置 \(X'\) は \(2 \times 3\)、\(X\) は \(3 \times 2\) であるから、積 \(X'X\) は \(2 \times 2\) になる。

\[ X'X = \begin{pmatrix} x_{11} & x_{12} & x_{13} \\ x_{21} & x_{22} & x_{23} \end{pmatrix} \begin{pmatrix} x_{11} & x_{21} \\ x_{12} & x_{22} \\ x_{13} & x_{23} \end{pmatrix} = \begin{pmatrix} \displaystyle\sum_{i=1}^{N} x_{1i}^2 & \displaystyle\sum_{i=1}^{N} x_{1i} x_{2i} \\[10pt] \displaystyle\sum_{i=1}^{N} x_{1i} x_{2i} & \displaystyle\sum_{i=1}^{N} x_{2i}^2 \end{pmatrix} \]
\(X'X\) の次元は \(k \times k\)(説明変数の数 × 説明変数の数)。 \((1,1)\) 成分は \(\sum x_{1i}^2\)、\((1,2)\) 成分と \((2,1)\) 成分は \(\sum x_{1i}x_{2i}\)(等しい → 対称行列)、\((2,2)\) 成分は \(\sum x_{2i}^2\)。

\(X'u\) の計算(次元 \(k \times 1\))

転置 \(X'\) は \(2 \times 3\)、\(\boldsymbol{u}\) は \(3 \times 1\) であるから、積 \(X'\boldsymbol{u}\) は \(2 \times 1\) になる。

\[ X'\boldsymbol{u} = \begin{pmatrix} x_{11} & x_{12} & x_{13} \\ x_{21} & x_{22} & x_{23} \end{pmatrix} \begin{pmatrix} u_1 \\ u_2 \\ u_3 \end{pmatrix} = \begin{pmatrix} \displaystyle\sum_{i=1}^{N} x_{1i} u_i \\[10pt] \displaystyle\sum_{i=1}^{N} x_{2i} u_i \end{pmatrix} \]
\(X'\boldsymbol{u}\) の次元は \(k \times 1\)。各成分は「各説明変数と誤差項の共分散的な量」にあたる。 OLS の正規方程式(normal equations)は \(X'X\hat{\boldsymbol{\beta}} = X'y\) であり、誤差の直交条件は \(X'\hat{\boldsymbol{u}} = \mathbf{0}\) と書かれる。
OLS 推定量との接続: モデル \(\boldsymbol{y} = X\boldsymbol{\beta} + \boldsymbol{u}\) に対し、OLS 推定量は \(\hat{\boldsymbol{\beta}} = (X'X)^{-1}X'\boldsymbol{y}\) と書ける(\(X'X\) が逆行列をもつ、すなわち \(X\) が列フルランクである場合)。 本章で学んだ行列の道具がすべてここに集結する。

\(X'X\) まとめ

  • 次元:\(k \times k\)(正方行列)
  • \(X\) が列フルランク → 正値定符号 → 逆行列が存在
  • 対称行列(\((X'X)' = X'X\))
  • 対角成分:各説明変数の二乗和 \(\sum x_{ji}^2\)
  • 非対角成分:2変数間の交差積和 \(\sum x_{ji} x_{li}\)

\(X'u\) まとめ

  • 次元:\(k \times 1\)(列ベクトル)
  • 各成分:\(\sum_{i=1}^{N} x_{ji} u_i\)(第 \(j\) 変数と誤差の積和)
  • OLS の誤差直交条件:\(X'\hat{u} = \mathbf{0}\)
  • 母集団の仮定:\(E[X'u] = \mathbf{0}\)(外生性条件)