Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

最尤推定法に基づく正規方程式の導出

被説明変数y\boldsymbol{y}を、説明変数X\boldsymbol{X}と回帰係数β\boldsymbol{\beta}の線形結合と誤差項ε\boldsymbol{\varepsilon}によって表現する線形回帰モデル

y=Xβ+ε\newcommand{\b}[1]{\boldsymbol{#1}} \b{y} = \b{X} \b{\beta} + \b{\varepsilon}

を考える。また、以下を仮定する(古典的正規回帰モデル(Classical Normal Regression Model: CNRM) の仮定)

  1. 説明変数\b{X}は非確率的である

  2. E[Y] = \b{X \beta}であり、したがって誤差項の期待値はゼロ:E(\b{\varepsilon}) = 0

  3. 誤差項の分散σ2\sigma^2は一定(均一分散)であり、共分散はゼロ(独立性):Var(\b{\varepsilon}) = \sigma^2 \b{I}

  4. \b{X}の階数はkkrank(\b{X}) = k\b{X^\top X}に逆行列が存在することの仮定)

  5. YYは正規分布に従う(正規性):Y \sim \mathcal{N}(\b{X\beta}, \sigma^2\b{I}), \quad \b{\varepsilon} \sim \mathcal{N}(0, \sigma^2\b{I})

特に3(標本がi.i.d.)と5(正規性)は最尤推定のために必要で、誤差項εi=yixiβ\varepsilon_i = y_i - \boldsymbol{x}_i^\top \boldsymbol{\beta}が従う分布型を仮定することで最尤推定が可能になる。

尤度としては、平均xiβ\boldsymbol{x}_i^\top \boldsymbol{\beta}の正規分布で観測値yiy_iが得られる確率N(yixiβ,σ2I)\mathcal{N}(y_i| \boldsymbol{x}_i^\top \boldsymbol{\beta}, \sigma^2I)を用いて

L(yX,β,σ)=i=1NN(yixiβ,σ2I)\newcommand{\b}[1]{\boldsymbol{#1}} L(\b{y}| \b{X}, \b{\beta}, \sigma) = \prod^N_{i=1} \mathcal{N}(y_i| \b{x}_i^\top \b{\beta}, \sigma^2I)

ただし、N\mathcal{N}は正規分布

N(xμ,σ2)=12πσexp{(xμ)22σ2},<x<\mathcal{N}(x|\mu, \sigma^2) = \frac{1}{\sqrt{2\pi}\sigma} \exp \left\{ - \frac{(x-\mu)^2}{2\sigma^2} \right\} , \hspace{1em} -\infty < x < \infty

対数尤度は

Undefined control sequence: \b at position 21: …n{align}
\ln L(\̲b̲{y}| \b{X}, \b{…

\begin{align}
\ln L(\b{y}| \b{X}, \b{\beta}, \sigma)
&= \sum^N_{i=1} \ln \mathcal{N}(y_i| \b{x}_i^\top \b{\beta}, \sigma^2)
\\
&= - \frac{N}{2} \ln (2\pi)
    - \frac{N}{2} \ln \sigma^2
    - \frac{1}{2\sigma^2} \sum^N_{i=1} (y_i - \b{x}_i^\top \b{\beta})^2
\end{align}

回帰係数の推定

対数尤度を\b{\beta}について微分した勾配を0と置いて解くと

Undefined control sequence: \b at position 28: …}
\nabla \ln L(\̲b̲{y}| \b{X}, \b{…

\begin{align}
\nabla \ln L(\b{y}| \b{X}, \b{\beta}, \sigma)
&= \frac{1}{\sigma^2} \sum^N_{i=1} (y_i - \b{x}_i^\top \b{\beta})\b{x}_i^\top\\
&= \frac{1}{\sigma^2} (\sum^N_{i=1} y_i \b{x}_i^\top)
 - \b{\beta}^\top \frac{1}{\sigma^2} (\sum^N_{i=1} \b{x}_i \b{x}_i^\top)\\
&= \frac{1}{\sigma^2} (\b{X}^\top \b{y})^\top
 - \b{\beta}^\top \frac{1}{\sigma^2} \b{X}^\top \b{X}\\
&= 0\\
\to \hat{\b{\beta}} &= (\b{X}^\top \b{X})^{-1} \b{X}^\top \b{y}\\
\end{align}

となり、最尤推定量と最小二乗推定量が同じ方程式になることがわかる

標準偏差σ\sigmaの導出

Undefined control sequence: \b at position 36: …\partial \ln L(\̲b̲{y}| \b{X}, \b{…

\begin{align}
\frac{\partial \ln L(\b{y}| \b{X}, \b{\beta}, \sigma) }{ \partial \sigma }
&= \frac{\partial}{ \partial \sigma }
    \left(- \frac{N}{2} \ln (2\pi)
    - \frac{N}{2} \ln \sigma^2
    - \frac{1}{2\sigma^2} \sum^N_{i=1} (y_i - \b{x}_i^\top \b{\beta})^2 \right)\\
&= - \frac{N}{2} \frac{1}{\sigma^2} 2\sigma
   + \frac{4\sigma}{4\sigma^4} \sum^N_{i=1} (y_i - \b{x}_i^\top \b{\beta})^2\\
&= - \frac{N}{\sigma}
   + \frac{1}{\sigma^3} \sum^N_{i=1} (y_i - \b{x}_i^\top \b{\beta})^2\\
\end{align}

これをゼロにするσ2\sigma^2

Undefined control sequence: \b at position 76: …N_{i=1} (y_i - \̲b̲{x}_i^\top \b{\…

\begin{align}
&- \frac{N}{\sigma} + \frac{1}{\sigma^3} \sum^N_{i=1} (y_i - \b{x}_i^\top \b{\beta})^2 = 0\\
&\to \frac{N}{\sigma} = \frac{1}{\sigma^3} \sum^N_{i=1} (y_i - \b{x}_i^\top \b{\beta})^2\\
&\to \frac{\sigma^3}{\sigma} = \frac{\sigma^3}{N \sigma^3} \sum^N_{i=1} (y_i - \b{x}_i^\top \b{\beta})^2\\
&\to \sigma^2 = \frac{1}{N} \sum^N_{i=1} (y_i - \b{x}_i^\top \b{\beta})^2\\
\end{align}

となる

\b{\beta}の最尤推定量 \hat{\b{\beta}}_{ML} = (\b{X}^\top \b{X})^{-1} \b{X}^\top \b{y}を代入すると

Undefined control sequence: \b at position 70: …N_{i=1} (y_i - \̲b̲{x}_i^\top \hat…

\begin{align}
\hat{\sigma}^2_{ML}
&= \frac{1}{N} \sum^N_{i=1} (y_i - \b{x}_i^\top \hat{\b{\beta}}_{ML})^2\\
&= \frac{ \b{\varepsilon}^\top \b{\varepsilon} }{N}\\
\end{align}