Description Usage Arguments Author(s) Examples
This is a variation on the tempering algorithm. It relies on alternative blocks of cold chains with blocks of very hot chains.
1 2 3 |
f |
a function computing log-densities |
param |
a list of named parameters passed on to 'f'; parameters must be given their initial values |
to.move |
a logical or an integer vector indicating which parts of 'param' should be moved in the MCMC |
n |
a number of iterations for the eMCMC |
cold.block.size |
the size of cold blocks |
hot.block.size |
the size of hot blocks |
sd |
the standard deviation of the proposal normal distribution |
min.temp |
the maximum temperature to be used |
max.temp |
the maximum temperature to be used |
Thibaut Jombart t.jombart@imperial.ac.uk
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | ## try with a basic normal density
f1 <- function(x){dnorm(x, log=TRUE)}
## basic MCMC
mc1 <- metro(f1)
plot(mc1)
## eMCMC
emc1 <- emcmc(f1)
plot(emc1[[1]]) # all chains
plot(emc1[[2]]) # thinned
## try with a mixture of densities
fmix <- function(x){log(dnorm(x, mean=-5) +
dnorm(x, mean=5, sd=.5))}
plot(function(x) exp(fmix(x)), xlim=c(-10,10))
title("Target density")
## basic MCMC
mc2 <- metro(fmix, list(x=0), n=6e4)
plot(mc2)
## eMCMC
emc2 <- emcmc(fmix)
plot(emc2[[1]]) # all chains
plot(emc2[[2]]) # thinned
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.