Bayes-tilastotiede MCMC

Johdanto

Bayes-päättely \(\begin{cases} \text{1. Määr priori } p(\theta) \\ \text{2. Määr malli } p(y | \theta) \\ \text{3. Laske posteriori } p(\theta|y)= \frac{p(y|\theta)p(\theta)}{p(y)} \\ \text{4. Arvoitata dataan } \end{cases} \).

Posteriorin laskeminen \(\begin{cases} p(y) = \displaystyle\int p(y|\theta)p(\theta) \\ \text{Konjugaattiprioreiden käyttö}\\ \text{Analyyttinen integrointi } \\ \text{Numeerien integrointi } \\ \text{Approksimointi } \\ \text{Riippumattominen haviantojen tuottaminen posteriori } \\ \text{Riippuvien – : Markov chain Mante Carlo} \end{cases} \).

Hierarkkiset mallit

Hierakkinen malli esitetään usein graafin avulla. DAG – Directed Asyclic Graph:


For graph 2, \(\begin{cases} &p(y,\theta,\eta) &= \underbrace{p(y|\theta)}_{\text{uskottavuus } } \times \underbrace{p(\theta|\eta)}_{\text{priori } } \times \underbrace{p(\eta)}_{p(\eta)} \\ \ ⇒ &p(\theta,\eta|y) &= \frac{p(y|\theta)p(\theta|\eta)p(\eta)}{p(y)} \propto \underbrace{p(y|\theta)p(\theta|\eta)p(\eta)}_{\text{MAP – Maximum A Posteriori } } \end{cases} \).

Havainnot ovat vihdannaisia (finitely exchangeable) \(p(y_1,\dots,y_n) = \displaystyle\int \prod\limits_{i=1}^{ n} \bigg( p(y_i|\theta) \bigg) p(\theta)d\theta\).

Posteriorin laskeminen

Numeerinen integrointi \(\begin{cases} \text{1. Kirjoita posteriori } p(\theta|y) \propto p(y|\theta)p(\theta) \\ \text{2. Laske numeerisella integroinnilla esim. R “integrate”} \\ \text{toimii, kun dim}\theta \leq 2 \end{cases} \).

Suurten otosten approksimaatio \(\begin{cases} h(\theta):= \log [p(y|\theta)p(\theta)] \\ \underset{ \overline{\text{Taylor}} }{h(\theta) \approx h(\hat\theta)}+ (\theta-\hat\theta) \underbrace{h'(\theta)}_{p\times 1} + \frac{1}{2} (\theta-\hat\theta)^T \underbrace{h”(\hat\theta)}_{p\times p} (\theta-\hat\theta) \\ \text{Newtonin algoritmiin } \hat\theta \text{:lle } \\ \begin{cases} \text{Alkuarvo } \hat\theta ^{(0)} \\ \text{Päivitys } \hat\theta ^{(k+1)} = \hat\theta ^{(k)} – h” (\hat\theta ^{(k)} ) ^{-1} h'(\hat\theta ^{(k)} ) \\ \ ⇒\ h'(\hat\theta ^{(k)}) \to 0;\ -h”(\hat\theta ^{(k)} ) \to V ^{-1} \\ \ ⇒\ p(\theta|y)\sim N_p (\hat\theta,V)\end{cases} \\ \text{esim. R “nlm“, hessian} = V ^{-1} \end{cases} \).

Monte Carlo – menetelmä \(\begin{cases} \theta ^{(1)} ,\dots, \theta ^{(n)} \overset{iid}{\ \sim\ } p (\theta|y) \\ ⇒ \begin{cases} \xi(\theta ^{(1)} ),\dots, \xi(\theta ^{(n)} ) \overset{iid}{\ \sim\ } p (\xi(\theta)|y) \\ E(\xi(\theta)|y) \sim \frac{1}{N} \sum\limits_{j=1}^n \xi(\theta ^{(j)} )=: \bar\xi \\ Var(\xi(\theta)) \sim \frac{1}{N-1} \sum\limits_{j=1}^n \big( \xi(\theta ^{(j)} ) – \bar\xi \big)^2 \\ s.e._\xi = \sqrt{\frac{1}{N} Var(\xi(\theta))}\end{cases} \\ \end{cases}\).

Tärekeysotanta/importance sampling \(\begin{cases} \text{Idea: sample from } g(\theta) \text{ that is easier and }\sim p(\theta|y) \\ E(\xi(\theta)|y) = \frac{E_g[w(\theta)\xi(\theta)]}{E_g[w(\theta)]} \\ \text{ missä, } w(\theta) = \frac{p(\theta,y)}{g(\theta)} = \frac{p(y|\theta)p(\theta)}{g(\theta)} \\ \bar\xi _{IS} = \frac{\sum_{j=1}^n w (\theta ^{(j)} )\xi(\theta ^{(j)} )}{\sum_{j=1}^n w (\theta ^{(j)} )} \\ s.e._{\bar\xi} = \frac{ \sqrt{\sum_{j=1}^n [w (\theta ^{(j)} )]^2 (\xi(\theta ^{(j))}-\bar\xi _{IS} )^2}}{\sum_{j=1}^n w (\theta ^{(j)} )} \end{cases} \).

SIR/Sampling Importance Resampling \(\begin{cases} \text{1. Simuloida } \theta ^{(1)} ,\dots, \theta ^{(N)} \ g(\theta) \text{:lta } \\ \text{2. Lasketaan } p ^{(j)}= \frac{w(\theta^{(j)})}{\sum_{i=1}^N w (\theta ^ {(j)})} ,\ \ w(\theta^{(j)}) = \frac{p(\theta^{(j)}|y)}{g(\theta^{(j)})} \\ \text{3. Bootstrap-otos } \theta ^{*1} ,\dots, \theta^{*N} \end{cases} \).

Markovin ketju Monte Carlo on geneerinen ja sopii pieni data. Esim. sivu42

Markovin ketju Monte Carlo

Simulointialgoritmeja \(\begin{cases} \text{1. kääntyvä Markovin ketju } \pi_i \\ \text{2. simulointi } \\ \text{3. Tutki kovergenssi } \\ \text{4. Käytä simulointeja jakauman kuvaamiseen} \end{cases} \).

Tasapaino ehto \(\begin{cases} \text{Globaali } & \sum \limits_{i\in S} \pi_i p _{ij} = \pi_j&\forall j \in S \\ \text{Lookaali } & \pi_ip _{ij } = \pi_j p _{ji} &\forall i,j \in S\\ & \text{ Lookaali- ⇒ Gloobaali } \end{cases} \).

Gibbs alogritmi \(\begin{cases} \text{1. Aseta alkuarvot } \theta _{1}^{(0)} , \theta _{2}^{(0)} ,\dots, \theta _{k}^{(0)} \\ \text{2. Generoi } \begin{align} \theta _{1} ^{(t+1)} \text{ from } p(\theta_1 |\theta _{2}^{(t)} , \theta _{3}^{(t)},\dots,\theta _{k}^{(t)}) \\ \theta _{2} ^{(t+1)} \text{ from } p(\theta_2 |\theta _{1}^{(t)}, \theta _{3}^{(t)} ,\dots,\theta _{k}^{(t)}) \end{align} \\ \text{3. Toista } \end{cases} \).

Metropolis-algoritmi \(\begin{cases} \text{1. Aseta alkuarvo }\theta ^{(0)} \\ \text{2. Generoi }\theta^* \text{ from }q(\theta^* | \theta^t) \\ \text{Symmetrisyysehto }q(\theta_a|\theta_b) =q(\theta_b|\theta_a) \\ \text{3. hyväksymis-tn } \alpha = \min \bigg\{ 1, \frac{p(\theta^*)p(y|\theta^*)}{p(\theta^t)p(y|\theta^t)} \bigg\} \\ \text{4. Aseta } \theta ^{(t+1)} = \begin{cases} \theta^* & tn=\alpha\\ \theta ^{(t)} & \text{muutoin} \end{cases} \\\text{5. Toista } \end{cases} \).

Metropolis-Hastings-algoritmi \(\alpha= \min \bigg\{ 1, \frac{p(\theta^*)p(y|\theta^*)q (\theta ^{t} |\theta^*)}{p(\theta^t)p(y|\theta^t)q (\theta ^{*} |\theta^t)} \bigg\}\), ei tarvitse täyttää symmetrisyysehtoa.

You must be logged in to post a comment.