Lecture 9:Markov Chain Monte Carlo Methods (二) (马尔科夫蒙特卡罗方法) 张伟平 Monday 2nd November,2009
Lecture 9: Markov Chain Monte Carlo Methods () (ÍâÅÑAk¤ê{) ‹ï² Monday 2nd November, 2009
Contents 1 Markov Chain Monte Carlo Methods y 1.4 The Gibbs Sampler....................... 1.4.1 The Slice Gibbs Sampler................ 12 1.5 Monitoring Convergence······ 21 1.5.1.Convergence diagnostics plots·..·········· 21 1.5.2 Monte Carlo Error .... 22 1.5.3 The Gelman-Rubin Method ............. 25 l.6 VinBUGS Introduction·.···.. 33 l.6.1'Building Bayesian models in WinBUGS·.·.·.· 33 1.6.2 Model specification in WinBUGS..········· 36 1.6.3 Data and initial value specification。..·.·.··· 38 1.6.4 Compiling model and simulating values .. 46 Previous Next First Last Back Forward 1
Contents 1 Markov Chain Monte Carlo Methods 1 1.4 The Gibbs Sampler . . . . . . . . . . . . . . . . . . . . . . . 1 1.4.1 The Slice Gibbs Sampler . . . . . . . . . . . . . . . . 12 1.5 Monitoring Convergence . . . . . . . . . . . . . . . . . . . . 21 1.5.1 Convergence diagnostics plots . . . . . . . . . . . . . 21 1.5.2 Monte Carlo Error . . . . . . . . . . . . . . . . . . . 22 1.5.3 The Gelman-Rubin Method . . . . . . . . . . . . . . 25 1.6 WinBUGS Introduction . . . . . . . . . . . . . . . . . . . . 33 1.6.1 Building Bayesian models in WinBUGS . . . . . . . 33 1.6.2 Model specification in WinBUGS . . . . . . . . . . . 36 1.6.3 Data and initial value specification . . . . . . . . . . 38 1.6.4 Compiling model and simulating values . . . . . . . 46 Previous Next First Last Back Forward 1
Chapter 1 Markov Chain Monte Carlo Methods 1.4 The Gibbs Sampler Gibbs抽样是MH算法的一个特例,其经常用于目标分布是多元分布的场合. 假设所有的一元条件分布(每个分量对其他分量的条件分布)都是可以确定的, Gibbsi抽样使用这些一元条件分布进行抽样. 令X=(X1,·,Xd)为R中的随机变量,定义d-1维的随机变量 X-j=(X1,…,Xj-1,Xj+1,…,Xa, 并记XX-的条件密度为f(XX-).则Gibbs抽样是从这d个条件分布中 产生候选点.算法如下: 1.在t=0时,初始化X(0) Previous Next First Last Back Forward 1
Chapter 1 Markov Chain Monte Carlo Methods 1.4 The Gibbs Sampler Gibbs ƒ¥MHé{òáA~, Ÿ²~^u8I©Ÿ¥ı©Ÿ|‹. b§kò^᩟ (zá©˛ÈŸ¶©˛^᩟)—¥å±(½, Gibbsƒ¶^˘ ò^᩟?1ƒ. -X = (X1, · · · , Xd)èRd•ëÅC˛, ½¬d − 1ëëÅC˛ X−j = (X1, · · · , Xj−1, Xj+1, · · · , Xd), øPXj |X−j^áó›èf(Xj |X−j ). KGibbsƒ¥l˘dá^᩟• )ˇ¿:. é{Xe: 1. 3t = 0û, –©zX(0); Previous Next First Last Back Forward 1
2.对t=1,2,·,T (a)令x1=X1(t-1). (b)对每个分量j=1,.,d, ()从f(Xz-)中产生候选点X() ()更新x=X() (c)今X(t)=(X(t),,X()(每个候选点都被接受) (d)增加t 注意在上述算法(b)步抽样中,各个分量依次被更新: x1(t)f(x1r2(t-1),…,xa(t-1): r2(t)~f(r2r1(t),x3(t-1),…,xd(t-1) xa(t)~f(zalzi(t),....xd_1(t)). Previous Next First Last Back Forward 2
2. Èt = 1, 2, · · · , T, (a) -x1 = X1(t − 1). (b) Èzᩲj = 1, . . . , d, (i) lf(Xj |x−j )•)ˇ¿:X∗ j (t). (ii) ç#xj = X∗ j (t). (c) -X(t) = (X∗ 1 (t), . . . , X∗ d (t))(záˇ¿:—…) (d) O\t 5ø3˛„é{(b)⁄ƒ•, àᩲùgç#: x1(t) ∼ f(x1|x2(t − 1), · · · , xd(t − 1)); x2(t) ∼ f(x2|x1(t), x3(t − 1), · · · , xd(t − 1)) . . . xd(t) ∼ f(xd|x1(t), · · · , xd−1(t)). Previous Next First Last Back Forward 2
从一元分布f(xz1(t),x2(t),…,xj-1(t),x5+1(t-1),…,x(t-1)中 抽样是比较容易的,因为f(xz-)xf(x),其中除了变量x,外,其他变量都是 常数 例1(Gibbs抽样:二元分布)使用Gibbs:抽样产生二元正态分布 N(41:2,ai,,P)的随机数 在二元正态场合,X1X2以及X2X1仍然服从正态分布,且易知 E[XlX2=x2l=h+p(2-2), 02 Var[X1|X2 =x2]=(1-p2)oi 类似可得X2X1的分布.因此 felx2)~N41+p(e2-42).(1-p)) 02 fe2lr)~N2+p2(e1-4,=1-p2) 因此,使用Gibbs算法如下 Previous Next First Last Back Forward 3
lò©Ÿf(xj |x1(t), x2(t), · · · , xj−1(t), xj+1(t − 1), · · · , xd(t − 1))• ƒ¥'N¥, œèf(xj |x−j ) ∝ f(x), Ÿ•ÿ C˛xj ,Ÿ¶C˛—¥ ~Í. ~ 1 (Gibbs ƒ: ©Ÿ) ¶^Gibbsƒ)©Ÿ N(µ1, µ2, σ2 1 , σ2 2 , ρ) ëÅÍ 3|‹, X1|X2±9X2|X1E,—l©Ÿ, Ö¥ E[X1|X2 = x2] = µ1 + ρ σ1 σ2 (x2 − µ2), V ar[X1|X2 = x2] = (1 − ρ 2 )σ 2 1 aqåX2|X1©Ÿ. œd f(x1|x2) ∼ N(µ1 + ρ σ1 σ2 (x2 − µ2), (1 − ρ 2 )σ 2 1 ) f(x2|x1) ∼ N(µ2 + ρ σ2 σ1 (x1 − µ1), = (1 − ρ 2 )σ 2 2 ) œd, ¶^Gibbsé{Xe Previous Next First Last Back Forward 3