如何找到后验分布的支持来应用Metropolis-Hastings MCMC算法?

M Silva 11/01/2013. 1 answers, 596 views
bayesian mcmc inference

我试图使用Metropolis-Hastings采样器使用MCMC算法从后验分布中进行采样。

我应该如何处理我被困在后验区域的概率为零的情况?

存在这些区域是因为后验分布被截断,并且由于计算机上的数值限制,如果距离平均值很远,则可能性变为零。 也就是说,可能性是正常分配的; 如果距离平均值100个标准偏差,则计算机出现零概率。

我想知道的是如何选择链的初始值,以确保它包含在后部的支持中。

1 Answers


Teco 11/26/2013.

这是一个实现问题,因为从理论上讲,MCMC对截断分布没有问题。

让$ D $成为你后路的支持。 只需将你的log-posterior定义为$ - \ infty $ if $ $ theta \ not \ in D $并选择一个合适的值作为初始点$ D $。

例如,假设$ x_1,\ dots,x_n \ stackrel {ind。} {\ sim} \ exp(\ lambda)$和$ \ lambda \ sim Unif(0,10)$。 以下代码显示了如何使用包'mcmc'为此模型实现Metropolis-Hastings。

library(mcmc)

set.seed(123)
x = rexp(100,1)  # The theoretical value of lambda is 1

# logposterior    
logpost = function(lambda){
if(lambda>0 & lambda <10) return(sum(dexp(x,lambda,log=T)))
else return(-Inf)
}

# Metropolis-Hastings

NS = 55000

out <- metrop(logpost, scale = .5, initial = 1, nbatch = NS)

out$accept

lambdap =   out$batch[ , 1][seq(5000,NS,25)] # posterior simulations after burning and thinning

hist(lambdap) 

HighResolutionMusic.com - Download Hi-Res Songs

1 (G)I-DLE

POP/STARS flac

(G)I-DLE. 2018. Writer: Riot Music Team;Harloe.
2 Ariana Grande

​Thank U, Next flac

Ariana Grande. 2018. Writer: Crazy Mike;Scootie;Victoria Monét;Tayla Parx;TBHits;Ariana Grande.
3 Clean Bandit

Baby flac

Clean Bandit. 2018. Writer: Jack Patterson;Kamille;Jason Evigan;Matthew Knott;Marina;Luis Fonsi.
4 Imagine Dragons

Bad Liar flac

Imagine Dragons. 2018. Writer: Jorgen Odegard;Daniel Platzman;Ben McKee;Wayne Sermon;Aja Volkman;Dan Reynolds.
5 Halsey

Without Me flac

Halsey. 2018. Writer: Halsey;Delacey;Louis Bell;Amy Allen;Justin Timberlake;Timbaland;Scott Storch.
6 BTS

Waste It On Me flac

BTS. 2018. Writer: Steve Aoki;Jeff Halavacs;Ryan Ogren;Michael Gazzo;Nate Cyphert;Sean Foreman;RM.
7 Nicki Minaj

No Candle No Light flac

Nicki Minaj. 2018. Writer: Denisia “Blu June” Andrews;Kathryn Ostenberg;Brittany "Chi" Coney;Brian Lee;TJ Routon;Tushar Apte;ZAYN;Nicki Minaj.
8 Backstreet Boys

Chances flac

Backstreet Boys. 2018.
9 BlackPink

Kiss And Make Up flac

BlackPink. 2018. Writer: Soke;Kny Factory;Billboard;Chelcee Grimes;Teddy Park;Marc Vincent;Dua Lipa.
10 Little Mix

The Cure flac

Little Mix. 2018. Writer: Pete Kelleher;Camille Purcell;Tom Barnes;Ben Kohn.
11 Fitz And The Tantrums

HandClap flac

Fitz And The Tantrums. 2017. Writer: Fitz And The Tantrums;Eric Frederic;Sam Hollander.
12 Diplo

Close To Me flac

Diplo. 2018. Writer: Ellie Goulding;Savan Kotecha;Peter Svensson;Ilya;Swae Lee;Diplo.
13 The Chainsmokers

Beach House flac

The Chainsmokers. 2018. Writer: Andrew Taggart.
14 Bradley Cooper

Always Remember Us This Way flac

Bradley Cooper. 2018. Writer: Lady Gaga;Dave Cobb.
15 Kelly Clarkson

Never Enough flac

Kelly Clarkson. 2018. Writer: Benj Pasek;Justin Paul.
16 Lady Gaga

I'll Never Love Again flac

Lady Gaga. 2018. Writer: Benjamin Rice;Lady Gaga.
17 Frida Sundemo

Apologize flac

Frida Sundemo. 2018.
18 Little Mix

Woman Like Me flac

Little Mix. 2018. Writer: Nicki Minaj;Steve Mac;Ed Sheeran;Jess Glynne.
19 Imagine Dragons

Machine flac

Imagine Dragons. 2018. Writer: Wayne Sermon;Daniel Platzman;Dan Reynolds;Ben McKee;Alex Da Kid.
20 Billie Eilish

When The Party's Over flac

Billie Eilish. 2018. Writer: Billie Eilish;FINNEAS.

Related questions

Hot questions

Language

Popular Tags