Bias-Variance Tradeoff

統計
作者

Ryo Nakagami

公開

2025-08-27

更新日

2025-09-02

統計的推測とBias-Variance Tradeoff

Bias, variance, MSE and RMSE

何かしらのパラメータ θ の推定量の性質を考えるとき,基本的には推定誤差

θ̂ − θ

の分布についてまず考えます.この評価手法の1例としてRMSEが挙げられます.

$$ \operatorname{RMSE} = \sqrt{\mathbb E_{\pmb\theta}[(\hat\theta - \theta)^2]} $$

RMSEの単位は θ の単位と同じなので,誤差のスケールを直感的に理解しやすいというメリットがあります.ただし,推定量の性質を考えるときはMSEのほうが取り回しが良いときが多いのでMSEの次に考えます.

定義 1 MSE

$$ \begin{align} \operatorname{MSE} &= \mathbb E_{\pmb\theta}[(\hat\theta - \theta)^2] \\ &= \mathbb E_{\pmb\theta}[(\hat\theta - \mathbb E_{\pmb\theta}[\hat\theta] + \mathbb E_{\pmb\theta}[\hat\theta] - \theta)^2] \\ &= \mathbb E_{\pmb\theta}[(\hat\theta - \mathbb E_{\pmb\theta}[\hat\theta])^2] + \mathbb E_{\pmb\theta}[(\mathbb E_{\pmb\theta}[\hat\theta] - \theta)^2] + 2\mathbb E_{\pmb\theta}[(\hat\theta - \mathbb E_{\pmb\theta}[\hat\theta])(\mathbb E_{\pmb\theta}[\hat\theta] - \theta)] \\ &= \mathbb E_{\pmb\theta}[(\hat\theta - \mathbb E_{\pmb\theta}[\hat\theta])^2] + (\mathbb E_{\pmb\theta}[\hat\theta] - \theta)^2 \\ &= \operatorname{Variance} + \operatorname{Bias}^2 \end{align} $$

上記の定義よりMSEは以下のように分解されます

MSE  = Variance  + Bias2

例 1

{X1, ⋯, Xn} がなにかしらの分布 D(μ, σ) からのi.i.dサンプルだとします.なお,μ ≠ 0, 𝔼[Xi4] < ∞ とします.

σ2 の推定量の候補として

σ2 = 𝔼[X2] − 𝔼[X]2

であるので,

$$ \begin{align} \overline{X^2} &= \frac{1}{n}\sum_{i=1}^n X_i^2\\ \overline{X} &= \frac{1}{n}\sum_{i=1}^n X_i\\ \hat\sigma^2 &= \overline{X^2} - \overline{X}^2 \end{align} $$

このとき,

$$ \begin{align} \mathbb E[(\overline{X})^2] &= \operatorname{Var}(\overline{X}) + (\mathbb E[\overline{X}])^2\\ &= \frac{1}{n}\sigma^2 + \mu^2 \end{align} $$

$$ \begin{align} \mathbb E[\overline{X^2}] &= \frac{1}{n}\sum_{i=1}^n\mathbb E[X_i^2]\\ &= \sigma^2 + \mu^2 \end{align} $$

従って,σ̂2 のBiasは

$$ \begin{align} \mathbb E[\hat\sigma^2] - \sigma^2 &= \mathbb E[\overline{X^2}] - \mathbb E[(\overline{X})^2] - \sigma^2\\ &= \sigma^2 + \mu^2 - \frac{1}{n}\sigma^2 - \mu^2 \sigma^2\\ &= - \frac{1}{n}\sigma^2 \end{align} $$

一方,σ̂2 のVarianceは,Delta methodを用いた漸近近似により

$$ \begin{align} \operatorname{Var}(\hat\sigma^2) &= \operatorname{Var}(\overline{X^2}) + \operatorname{Var}(\overline{X}^2)\\ &\approx \frac{1}{n}\operatorname{Var}(X_i^2) + (2\mu)^2\frac{\sigma^2}{n}\\ &= \mathcal{O}(n^{-1}) \end{align} $$

注釈 1.

Large Samplesの場合は,

  • Variance 1/n の速さで小さくなる
  • Bias21/n2 の速さで小さくなる

以上より MSE  を最小化したい場合はvarianceの方を小さくするのが有効であることがわかる.


例 2 MSEの比較

$$ \begin{align} \{X_1, \cdots, X_n\} \overset{\mathrm{iid}}{\sim} N(\mu, \sigma^2) \label{eq-exm} \end{align} $$

としたとき,σ2 のunbiased estimatorとして

$$ S^2 = \frac{1}{n-1}\sum_{i=1}^n (X_i - \overline{X})^2 \label{eq-exm-2} $$

が考えられます.このとき,かんたんな計算により 例 1 の推定量との関係として

$$ S^2 = \frac{n}{n-1}\hat\sigma^2 $$

と より

$$ (n-1)\frac{S^2}{\sigma^2} \sim \operatorname{\chi^2}(n-1) $$

従って,

$$ \operatorname{Var}(S^2)=\frac{2}{n-1}\sigma^4 $$

MSE (S2)MSE (σ̂2) を比較すると,

$$ \begin{align} \operatorname{MSE}(\hat\sigma^2) &= \mathbb E[(\hat\sigma^2 - \sigma^2)^2]\\ &= \frac{2(n-1)}{n^2}\sigma^4 + \frac{1}{n^2}\sigma^4\\ &= \frac{2n-1}{n^2}\sigma^4\\ &< \frac{2}{n-1}\sigma^4\\ &= \operatorname{Var}(S^2)\\ &= \operatorname{MSE}(S^2) \end{align} $$


CEF Decomposition Property

定理 1 CEF Decomposition Property

Yi = 𝔼[Yi|Xi] + ϵi

  • 𝔼[ϵi|Xi] = 0: ϵi is mean independent of Xi
  • ϵi is uncorrelated with any function of Xi
ノートProof (i)

$$ \begin{align} \mathbb E[\epsilon_i | X_i] &= \mathbb E[Y_i - \mathbb E[Y_i|X_i]|X_i]\\[3pt] &= \mathbb E[Y_i|X_i] - \mathbb E[Y_i|X_i]\\[3pt] &= 0 \end{align} $$

ノートProof (ii)

b(Xi)Xi についての任意の関数とするとき

$$ \begin{align} \mathbb E[b(X_i)\epsilon] &= \mathbb E[\mathbb E[b(X_i)\epsilon | X_i]]\\ &= \mathbb E[b(X_i)\mathbb E[\epsilon | X_i]]\\ &= 0 \end{align} $$

従って,Xi についての任意の関数と ϵi は無相関(uncorrelated, orthogonal)であることがわかる.

定理 2 CEFとMSE

m(Xi)Xi の関数とするとき,

$$ \mathbb E[Y_i | X_i] = \underset{m(X_i)}{\arg\min}\mathbb E[(Y_i - m(X_i))^2] $$

つまり,𝔼[Yi|Xi]Xi で条件づけた Yi の予測関数についてのMinimum Mean Squared Error(MMSE) である.

ノートProof

$$ \begin{align} (Y_i - m(X_i))^2 &= (Y_i - \mathbb E[Y_i | X_i] + \mathbb E[Y_i | X_i] - m(X_i))^2\\ &= (Y_i - \mathbb E[Y_i | X_i])^2 + 2(Y_i - \mathbb E[Y_i | X_i])(\mathbb E[Y_i | X_i] - m(X_i))^2 + (\mathbb E[Y_i | X_i] - m(X_i))^2\\ &= \epsilon^2 + 2\epsilon(\mathbb E[Y_i | X_i] - m(X_i)) + (\mathbb E[Y_i | X_i] - m(X_i))^2 \end{align} $$

期待値を取ると

𝔼[(Yi − m(Xi))2] = 𝔼[ϵi2] + 𝔼[(𝔼[Yi|Xi] − m(Xi))2]

従って,

E[Yi|Xi] = m(Xi)

のときMSEの意味で E[Yi|Xi] が最小化関数であることがわかる.