Bayes Estimation Method

Definition

Prior and Posterior Distributions

確率の基本法則

  • 加法定理
  • 乗法定理

を用いて、導出される以下のベイズの定理
\begin{align} P(Y|X) &= \frac{P(X,Y)}{P(X)} \\ &= \frac{P(X|Y)P(Y)}{P(X)} \\ &= \frac{P(X|Y)P(Y)}{\sum_Y P(X,Y)} \\ &= \frac{P(X|Y)P(Y)}{\sum_Y P(X|Y)P(Y)} \end{align}
を使って
\begin{align} f_{\Theta|X_1=x_1,\cdots,X_n=x_n}(\theta|x_1,\cdots,x_n) &= \frac{f_{X_1,\cdots,X_n|\Theta=\theta}(x_1,\cdots,x_n|\theta)g_\Theta(\theta)}{f_{X_1,\cdots,X_n}(x_1,\cdots,x_n} \\ &= \frac{[\prod^n_{i=1}f(x_i|\theta)]g_\Theta(\theta)}{\int[\prod^n_{i=1}f(x_i|\theta)]g_\Theta(\theta) d \theta} \end{align}
と計算できるが、これを事後分布(posterior distribution)という。

事後分布のmodeで\thetaを推定することもできる(mleにつながってくる)が、事後分布は単に\thetaの関数ではなく、分布関数である。なので、\thetaを推定するのに事後分布のmedianやmeanを使うこともできるわけである。meanを使うことで\thetaを推定して出てくる推定値のことをposterior Bayes estimatorと言う。

で、ここでは(Introduction to the Theory of StatisticsのP341)もっと一般に\thetaの関数\tau(\theta)の推定値を考えて定義してある。

Let X_1,\cdots,X_n be a random sample from a density f(x|\theta), where \theta is a value of the random variable \Theta with known density g_\Theta(\cdot). The posterior Bayes estimator of \tau(\theta) with respect to the prior g_\Theta(\cdot) isn defined to be E[\tau(\Theta)|X_1,\cdots,X_n].

で、こやつを計算するとこんな感じにできるよねっいうのが書いてある(Introduction to the Theory of StatisticsのP341の(21)式)。
\begin{align} E[\tau(\Theta)|X_1,\cdots,X_n] &= \int \tau(\theta)f_{\Theta|X_1=x_1,\cdots,X_n=x_n}(\theta|x_1,\cdots,x_n) d \theta \\ &= \frac{\int \tau(\theta)[\prod^n_{i=1}f(x_i|\theta)]g_\Theta(\theta) d \theta}{\int[\prod^n_{i=1}f(x_i|\theta)]g_\Theta(\theta) d \theta} \end{align}
分母の積分は定数なので、期待値に関する計算は分子のみにかかってくることに注意する。Pitman estimatorとの類似性などが書いてあったりもする。

posterior mean、すなわち、posterior Bayes estimatorを\thetaの推定値として使うこともできると書いたが、posterior Bayes estimatorは、一般にはunbiased estimatorではない(不偏推定量ではないということ)。

Posterior distribution is a function of sufficient statistics

Prior Predictive Distribution

Posterior Predictive Distribution

Posterior Mean

Loss-function Approach

loss function、リスク、admissibleなestimatorの話についてはこっちでまとめてみた。

リスクを最小にするような推定値について考えたいんだけど、リスクは\thetaの関数なので、一般的には一様にリスクを最小にするような推定値は存在しない。だから、リスクの平均を取って考えるようにすればいいんじゃない?ベイズならパラメータが分布できるからリスクの平均を考えることができるでしょ?というのがここまでの流れ。

そういうことなので、リスクの平均を考えましょう。んでもって、それをBayes riskと呼びましょう。

Let X_1,\cdots,X_n be a random sample from a density f(x|\theta), where \theta is the value of a random variable \Theta with cumulative distribution function G(\cdot) = G_\Theta(\cdot) and corresponding density g(\cdot) = g_\Theta(\cdot). In estimating \tau(\theta), let l(t;\theta) be the loss function. The risk of estimator T=t(X_1,\cdots,X_n) is denoted by R_t(\theta). The Bayes risk of estimator T=t(X_1,\cdots,X_n) with respect to the loss function l(\cdot;\cdot) and prior cumulative distribution G(\cdot), denoted by r(t) = r_{l,G}(t) = \int_\Phi R_t(\theta) g(\theta) d \theta.

これでベイズリスクの定義をすることができた。ここでBayes estimatorの定義をすることができるようになる。Bayes estimatorとはベイズリスクを最小にするような推定値のことなんだけど、ちゃんと書くとこういう感じ。admissible estimatorの時もこんなの出てきたな。

The Bayes estimator of \tau(\theta), denoted by T^*_{l,G} = t^*_{l,G}(X_1,\cdots,X_n), with respect to the loss function l(\cdot;\cdot) and prior cumulative distribution G(\cdot), is defined to be that estimator with smallest Bayse risk. Or the Bayes estimator of \tau(\theta) is that estimator t^*_{l,G} satisfying r_{l,G}(t^*) = r_{l,G}(t^*_{l,G}) \leq r_{l,G}(t) for every other estimator T = t(X_1,\cdots,X_n) of \tau(\theta).

ベイズに関する推定値ではposterior Bayes estimatorがあったんだけど、ちょっとそれと比較してみる。

  • posterior Bayes estimator
    • loss functionが必要なかった
    • その代わり、一般的には不偏推定量にはならないという性質があった
  • Bayes estimator
    • あとで見るけど、色々よい性質がある
    • だけど、loss functionがはっきりしてないと推定値計算するのとかに困るんだよね

こんな風なトレードオフがあったりする。完璧な推定値というのは中々ないねーという感じ。条件を付けることで強いことが言えたりとか。

なんだけど、loss functionが二乗和誤差の形だと結構簡単にBayes estimatorを求めることができるよねーというのがIntroduction to the Theory of StatisticsのP345の付近。

Loss functionが二乗和誤差である時のBayes estimatorを求める

結構簡単にとか言いながらも、Introduction to the Theory of StatisticsのP345の説明だといまいち分からなかったので、パターン認識と機械学習 上 - ベイズ理論による統計的予測のP45からのところで見てみることにする。このページに書いてある期待損失というのは
E[L] = \int \int \{y(x) -t\}^2 p(x,t)dxdt
という風に書いてあって、Introduction to the Theory of StatisticsのP345の記述とは微妙に違ったりする。こっちには
\begin{align} \int_\Phi R_t(\theta) g(\theta) d \theta &= \int_\Phi E_\theta [ [ t(X_1,\cdots,X_n) - \tau(\theta)]^2] g(\theta) d \theta \\ &= \int_\Phi \{ \int_{\mathfrak{X}} [ [ t(X_1,\cdots,X_n) - \tau(\theta)]^2] f_{X_1,\cdots,X_n}(x_1,\cdots,x_n) \prod^n_{i=1}d x_i \} g(\theta) d \theta \\ &= \int_{\mathfrak{X}} \{ \int_\Phi [ [ t(X_1,\cdots,X_n) - \tau(\theta)]^2] \frac{f_{X_1,\cdots,X_n}(x_1,\cdots,x_n|\theta) g(\theta) d \theta}{f_{X_1,\cdots,X_n}(x_1,\cdots,x_n)}  \}  f_{X_1,\cdots,X_n}(x_1,\cdots,x_n) \prod^n_{i=1}d x_i \\ &= \int_{\mathfrak{X}} \{ \int_\Phi [ [ t(X_1,\cdots,X_n) - \tau(\theta)]^2] f_{\Theta|{X_1=x_1,\cdots,X_n=x_n}}(\theta|x_1,\cdots,x_n) d \theta \}  f_{X_1,\cdots,X_n}(x_1,\cdots,x_n) \prod^n_{i=1}d x_i \\ &= \int_{\mathfrak{X}} \{ \int_\Phi [ [ t(X_1,\cdots,X_n) - \tau(\theta)]^2] f_{X_1=x_1,\cdots,X_n=x_n,\Theta}(x_1,\cdots,x_n,\theta) d \theta \} \prod^n_{i=1}d x_i \end{align}
という風に書いてある(最後はベイズの定理を使って自分で計算した)。

これで、yとtに、xをX_1,\cdots,X_n、pをfに、tを\thetaにおきかえれば同じ式に見えるところまできた(xはベクトル)。これからは、E[L] = \int \int \{y(x) -t\}^2 p(x,t)dxdtのほうで考えるようにしていくことにする。

変分法というのを使うと、これを最小にする推定値が計算できるらしいんだが、知らないので使わないアプローチのほうで行く。パターン認識と機械学習 上 - ベイズ理論による統計的予測のP46。とりあえず二乗和誤差を以下のように変形する(E[t|x]とできるのは答えがこれだと知っているからなんだけど、すまして使ってしまうw)。
\begin{align} \{y(x)-t\}^2 &= \{y(x) - E[t|x] + E[t|x] - t\} \\ &= \{y(x) - E[t|x]\}^2 + 2\{y(x) - E[t|x]\}\{E[t|x] - t\} + \{E[t|x] -t \}^2 \end{align}
これをリスクに入れて、tで積分を取ると、クロス項は消えて、リスクは
E[L] = \int \{y(x) - E[t|x]\}^2 p(x) dx + \int \mbox{var}[t|x] p(x) dx
という形に計算できるらしい。が、本当か分からないので計算することにした。

クロス項が消える

まず、条件付き期待値E[t|x]がxの関数であることを思い出しておこう。Introduction to the Theory of Statisticsのp158付近に例がある。これより、クロス項の部分の積分は、xに関する関数の部分を前に出して
\int \int (y(x) - E[t|x]) (E[t|x] -t)p(x,t) dt dx = \int (y(x) - E[t|x]) \int (E[t|x] -t)p(x,t) dt dx
とできる。\int (E[t|x] -t)p(x,t) dtの部分について考えると、後半部分はベイズの定理を使って
\begin{align} \int t p(x,t) dt &= \int t p(t|x) p(x) dt \\ &= p(x) \int t p(t|x) dt \\ &= E[t|x] p(x) \end{align}
とできる*1。これより前半部とキャンセルアウトされて、クロス項が消える。

条件付き分散の項

第三項を展開していくと
\int \int \{E[t|x] - t\}^2 p(x,t) dx dt = \int \int \{(E[t|x])^2 -2 t E[t|x] - t^2\} p(x,t) dx dt
条件付き期待値E[t|x]がxの関数であることを考えつつ、第二項を考えると
\begin{align} \int \int -2 t E[t|x] p(x,t) dx &= -2 \int \int t E[t|x] p(x,t) dt dx \\ &= -2 \int \int t E[t|x] p(t|x) p(x) dt dx \\ &= -2 \int p(x) E[t|x] \int t  p(t|x) dt dx \\ &= -2 \int p(x) E[t|x] E[t|x] dx \\ &= -2 \int p(x) (E[t|x])^2 dx \end{align}
とできる。また、第一項は
\begin{align} \int \int (E[t|x])^2 p(x,t) dx &= \int (E[t|x])^2 \int  p(x,t) dt dx \\ &= \int (E[t|x])^2 p(x) dx \end{align}
となる。これより、第一項と第二項によって= - \int (E[t|x])^2 p(x) dxが出てくる。第三項は
\begin{align} \int \int t^2 p(x,t) dx dt &= \int \int t^2 p(t|x)p(x) dx dt \\ &= \int \int t^2 p(t|x) p(x) dx dt \\ &= \int E[t^2|x] p(x) dx \end{align}
となる。条件付き分散の定義*2\mbox{var}[Y|X] = E[Y^2|X] - (E[Y|X])^2より全体として、\int \mbox{var} [t|x] p(x) dxとできる。

これによりE[L] = \int \{y(x) - E[t|x]\}^2 p(x) dx + \int \mbox{var}[t|x] p(x) dxを導くことができた。長かった。。。

リスクを最小にする推定値を考える

E[L] = \int \{y(x) - E[t|x]\}^2 p(x) dx + \int \mbox{var}[t|x] p(x) dxの第一項のみが推定値に関係している。第一項のy(x) - E[t|x]が0になればリスクは最小となるので、リスクを最小にする推定値はy(x) = E[t|x]となる。これをよく見ると、データが与えられたもとでの事後平均となっていることが分かる。

*1:条件付き期待値の定義を使っている。Introduction to the Theory of Statisticsのp157のdefinition 21

*2:Introduction to the Theory of Statisticsのp159