View
3.642
Download
0
Category
Preview:
Citation preview
Replica exchange MCMC
with Stan and R
Kentaro Matsuura
June 4, 2016
Tokyo.Stan
Example data
โข N = 50 # number of data points
2
Model (Assumptions)
โข ๐ ๐ ~ Normal sin ๐ฝ ๐ ๐ , ๐๐
โข angular rate: ๐ฝ ~ Normal+ 0, 50
โข noise scale: ๐๐ ~ Student_t+ 4, 0, 5
3
๐ = 1,โฆ ,๐
Stan Code 4
R Code 5
Result | trace plot 6
This chain seems good.
Should I set initial values
around (b, s_y)=(24, 0.3) ?
By the way
A contour map of log-posterior can be visualized.
Because the number of parameters is just two in this model.
7
For later explanation, I visualized ๐ธ
๐(โ โ log-posterior )
๐ธ: Energy, ๐: Temperature
higher log-posterior lower ๐ธ
๐previous model is correspond to ๐ = 1
Contour map of ๐ธ/๐ (at ๐ = 1) 8
Contour map of ๐ธ/๐ (at ๐ = 1) 9
around (24, 0.3)
๐ธ โ 33
around (0.5, 0.3)
๐ธ โ 28
10
Replica exchange MCMC (also known as parallel tempering)
Setting initial values is generally difficult.
References
โข Y. Iba, "Extended Ensemble Monte Carlo," Int. J. Mod.
Phys. C, 12, pp.623-652, 2001.
โข Movie by Y. Iba (in Japanese):
ใฌใใชใซไบคๆMCMC่ฌ็พฉ ๏ผไผๅบญๅนธไบบ๏ผ ้ฃๆๅบฆโ โ https://www.youtube.com/watch?v=1c7mQIhEqmQ
โข Books (in Japanese)
โ ็ฆๅณถๅญๆฒป (2006) ใตใคใณใญใตใฃใฆ็ฉๅใใๆนๆณ ็ขบ็็ๆ ๅ ฑๅฆ็ใจ็ตฑ่จๅๅญฆ(SGCใฉใคใใฉใช 50) p.60-66.
โ ไผๅบญใปใ (2005) ่จ็ฎ็ตฑ่จII (็ตฑ่จ็งๅญฆใฎใใญใณใใฃใข 12) p.74-78
11
Overview 12
Monte Carlo Step
๐5
๐4
๐3
๐2
๐1 = 1
>>>>
๐๐๐๐๐๐๐๐ = 5
Annealing and Heating 13
๐โ๐๐โ
๐๐๐๐๐๐๐
๐1 = 1
Sampling from joint distribution
โข Theoretically, Replica exchange MCMC
does sampling from the following joint
distribution:
๐ ๐ฝ1, โฆ , ๐ฝ๐๐_๐๐๐๐๐๐๐ =
๐=1
๐_๐๐๐๐๐๐๐
๐ ๐ฝ๐|๐ = ๐๐
where ๐ ๐ฝ๐|๐ = ๐๐ โ exp โ๐ธ ๐ฝ๐
๐๐
14
Exchange probability of replicas
๐ = min 1,exp โ๐ธ๐โฒ๐๐โ๐ธ๐๐๐โฒ
exp โ๐ธ๐๐๐โ๐ธ๐โฒ๐๐โฒ
= min 1, exp ๐ธ๐ โ ๐ธ๐โฒ ร1
๐๐โ1
๐๐โฒ
15
Pseudo Code 16
set T of replicas: T = (1, T2, T3, ..., TN_replica)set initial values: x = (x0, x0, ..., x0)
for e in 1, ..., N_exchangefor r in 1, ..., N_replica
short sampling started from x[r] at each T[r]endsave MCMC samples at T = 1
exchange replicas if p < unif(0,1)
for r in 1, ..., N_replicaupdate x[r]
endend
Stan Code 17
R Code and Settings
โข R Code:
โข ๐๐๐๐๐๐๐๐ = 10
โข ๐๐๐ฅ๐โ๐๐๐๐ = 100
โข ๐ = 1, 1.54, โฆ , 32.37, 50
โข ๐ฅ0 = ๐, ๐๐ฆ 0= 24. 2, 0.4
โข iter=70 and warmup=50 each short sampling
(i.e. 20 MCMC samples)
18
๐๐๐๐๐๐๐๐ needs โ ๐
geometric progression
deep local minimum โ
https://gist.github.com/MatsuuraKentaro/bccf13af3ba52c9d6c379c0032725b91
Result | Exchanges of replicas 19
Result | ๐ธ (Energy) 20
Result | ๐ธ (Energy) 21
Result | trace plot (at ๐ = 1) 22
Discussion
โข Can I re-use warmup result in Stan?
i.e. step size &
diagonal elements of inverse mass matrix
โข How to set iter and warmup of each short
sampling?
warmup=50 is usually too short as total sampling.
But, total warmup is 50*100 in this case.
Does it make sense?
23
Recommended