Chapter 04.
Monte Carlo Approximation
๋ณธ ํฌ์คํ ์ First Course in Bayesian Statistical Methods๋ฅผ ์ฐธ๊ณ ํ์๋ค.
Monte Carlo Method
Monte Carlo Method๋ ์ด๋ฆ์ ๊ฑฐ์ฐฝํด๋ณด์ด์ง๋ง ์ฌ์ค ๊ทธ ๋ฐฉ๋ฒ์ ๋งค์ฐ ๊ฐ๋จํ๋ค.
์ฐ์ , ์ฌํ๋ถํฌ($p(\theta|y_1,...,y_n)$)๋ก๋ถํฐ S๊ฐ์ random sample์ ๋ฝ๋๋ค.
$$\theta^{1}, …, \theta^{S} \ \stackrel{iid}{\sim} \ p(\theta|y_1, …, y_n) $$
๊ทธ๋ฌ๋ฉด S๊ฐ ์ปค์ง์๋ก {$\theta^{1}, ..., \theta^{S}$}๋ ๊ทผ์ฌ์ ์ผ๋ก ์ฌํ๋ถํฌ($p(\theta|y_1,...,y_n)$)๋ฅผ ๋ฐ๋ฅธ๋ค.
์ด๋ฅผ ํตํด $E[\theta|y_1, ..., y_n]$, $Var[\theta|y_1, ..., y_n]$๋ถํฐ ์ค์๊ฐ, $\alpha$ percentile ๋ฑ์ ํต๊ณ๋๊ฐ๋ค์ ๊ทผ์ฌ์ ์ผ๋ก ๊ณ์ฐํ ์ ์๋ค.

์ด๋ approximate Monte Carlo Standard error์ $\sqrt{\hat{\sigma}^2/S}$์ด๋ค. ๊ทธ๋ ๊ธฐ ๋๋ฌธ์, ๊ฐ๋ น $E[\theta|y_1, ..., y_n]$์ Monte Carlo ์ถ์ ์น์ ์ฐจ์ด๊ฐ 0.01์ดํ๋ก ํ๊ณ ์ถ๋ค๊ณ ํ๋ค๋ฉด, Monte Carlo Sample Size๋ฅผ ์กฐ์ ํด์ฃผ๋ฉด ๋๋ค. ์ด๋ ์๋ฅผ ๋ค์ด์ $\hat{\sigma}^2$๊ฐ 0.024๋ผ๊ณ ํ๋ค๋ฉด, Sample Size๋ $2\sqrt{0.024/S} < 0.01$๋ก ๊ณ์ฐํด์ sample์ 960๊ฐ๋ณด๋ค๋ ๋ง์ด ๋ฝ์์ผ ํจ์ ์ ์ ์๋ค.
Monte Carlo Method๋ฅผ ํ์ฉํ๋ฉด ๋ค์ํ ๊ฒ๋ค์ ํ ์ ์๋๋ฐ, ๊ทธ ๋ํ์ ์ธ ์์๋ก ์๋ ์ธ ๊ฐ๋ฅผ ์ดํดํด๋ณด์.
1. Posterior Inference for Arbitrary Functions
$\theta$ ๊ทธ ์์ฒด๊ฐ ์๋๋ผ ์์์ $f(\theta)$์ posterior distribution์ด ๊ถ๊ธํ ์ ์๋ค. ์๋ฅผ ๋ค์ด์, log odds์ ๊ฐ์ ๊ฒ ๋ง์ด๋ค. ํ์ง๋ง ๊ฒฐ๊ตญ $\gamma = f(\theta)$๋ $\theta$์ฒ๋ผ Monte Carlo Method๋ก ์ฌํ๋ถํฌ์ ์ถ์ ํ ์ ์๋ค.
ํ๋์ parameter๋ง ์๋ ๊ฒ์ด ์๋๋ผ, ์ฌ์ง์ด $Pr(\theta_1 > \theta_2 | Y_{1,1} = y_{1,1}, ..., Y_{n_2,2}=y_{n_2,2})$๋ $Pr(\theta_1/\theta_2 | Y_{1,1} = y_{1,1}, ..., Y_{n_2,2}=y_{n_2,2})$์ฒ๋ผ parameter๊ฐ ๋ ๊ฐ์ธ ๊ฒฝ์ฐ๋ ๊ตฌํ ์ ์๋ค.
2. Sampling from Predictive Distributions
Step1. sample $\theta^{(1)},...,\theta^{(S)} \text{ ~ i.i.d} \ p(\theta|y_1,...,y_n)$
Step2. approximate $p(\tilde{y}|y_1,...,.y_n)$ with $\sum_{s=1}^{S}p(\tilde{y}|\theta^{(s)})/S$
์ ๋ฐฉ๋ฒ์ ํตํด $Pr(\tilde{Y_1}>\tilde{Y_2}|\sum Y_{i,1}=217,\sum Y_{i,2}=66)$๋ฅผ ๊ทผ์ฌํ๋ ๊ฒ๋ ๊ฐ๋ฅํ๋ค. ์๋ํ๋ฉด $Pr(\tilde{Y_1})$์ $Pr(\tilde{Y_2})$์ posterior independentํ๊ธฐ ๋๋ฌธ์ด๋ค.
|
|
## [1] 0.9708
|
|
## [1] 0.4846
์ ๊ฒฐ๊ณผ๋ฅผ ํตํด์ ์ฃผ์๊น๊ฒ ์ดํด๋ณด์์ผ ํ ๊ฒ์, ์์ธก์น์ ์ฐจ์ด์ ๋ชจ์์ ์ฐจ์ด๊ฐ ๊ฐ์ง ์๋ค๋ ์ ์ด๋ค.
์๋ ์ธ ๊ฐ ๊ตฌ๋ถํ๊ธฐ
- (1) sampling model:
$Pr(\tilde{Y}=\tilde{y}|\theta)$ - (2) prior predictive model:
$Pr(\tilde{Y}=\tilde{y})$$\theta$์ ๋ํ ์ฌ์ ํ๋ฅ ๋ถํฌ๊ฐ ๊ด์ธก๊ฐ๋ฅํ ๋ฐ์ดํฐ$\tilde{Y}$์ ๋ํด ํฉ๋ฆฌ์ ์ธ ๋ฏฟ์์ ๋ํ๋ผ ์ ์๋์ง ํ์ธํด๋ณด๋ ์ฉ๋๋ก ํ์ฉ๊ฐ๋ฅํ๋ค.
- (3) posterior predictive model:
$Pr(\tilde{Y}=\tilde{y}|Y_1=y_1, ..., Y_n=y_n)$
3. Posterior Predictive Model Checking
We should at least make sure that our model generates predictive datasets
$\tilde{Y}$that resemble the observed dataset in terms of features that are of interest
|
|

์ค์ (empirical) ๋ถํฌ์ ์์ธก ๋ถํฌ์ ๋ชจ์ต์ด ๋ค์ ์ฐจ์ด๊ฐ ๋จ์ ํ์ธํ ์ ์๋ค.
์ฐธ๊ณ
[1] FCB code
ํน์ ๊ถ๊ธํ ์ ์ด๋ ์๋ชป๋ ๋ด์ฉ์ด ์๋ค๋ฉด, ๋๊ธ๋ก ์๋ ค์ฃผ์๋ฉด ์ ๊ทน ๋ฐ์ํ๋๋ก ํ๊ฒ ์ต๋๋ค.
