Description Usage Arguments References Examples
View source: R/MurraySchemePotts.R
This function allows you to simulate the parameters of a Potts model using the Murray Scheme.
1 2 |
beta.init |
Starting parameter values for the parameters of the Potts model. |
range.beta |
Range of values for the parameters of the Potts model. |
n.colors |
number of different "spins". |
col.obs |
Binary matrix of colors. |
N.run |
Number of MCMC runs to perform. |
Nb.list |
List of neighbours. |
Murray, I. and Ghahramani, Z. and MacKay, D. (2006) MCMC for doubly-intractable distributions. UAI Proceedings 22 359–366. Everitt, R. (2012) Bayesian Parameter Estimation for Latent Markov Random Fields and Social Networks. Journal of Computational and Graphical Statistics 21 940–960.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | beta = c(1.2, 1.2,1.2,1.2)
Obs.loc = expand.grid(1:5,1:5)
id.pos = sample(1:4, nrow(Obs.loc), replace = TRUE)
Res = SwendsenWangAlg(beta, Coord = as.matrix(Obs.loc), col.obs = id.pos, Nrun = 20)
par(mfrow = c(1,1))
col = grey.colors(4)
image(matrix(Res$col.new, ncol =5), col = col)
beta.init = runif(1,0,1)
set.seed(1)
beta.mcmc = MurraySchemePotts(beta.init = beta.init,Coords = Obs.loc ,n.colors = 4, col.obs = Res$col.new, N.run = 5000, range.beta = c(0,3))
Nbs = getBonds(as.matrix(Obs.loc), NN = 4, th = 2)
beta.mcmc.nb = MurraySchemePotts(beta.init = beta.init,Nb = Nbs,n.colors = 4, col.obs = Res$col.new, N.run = 5000, range.beta = c(0,3))
print(beta.mcmc$rate)
par(mfrow = c(2,2))
hist(beta.mcmc$beta.sample, breaks = 50, xlim = c(0,1.75))
plot(beta.mcmc$beta.sample, type = "l", ylim = c(0,1.75))
hist(beta.mcmc.nb$beta.sample, breaks = 50, xlim = c(0,1.75))
plot(beta.mcmc.nb$beta.sample, type = "l", ylim = c(0,1.75))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.