Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/Adaptive_MCMC.R
Add samples to an existing chain produced by MCMC
or MCMC.parallel
.
1 | MCMC.add.samples(MCMC.object, n.update, ...)
|
MCMC.object |
a list produced by |
n.update |
number of additional samples. |
... |
further arguments passed to |
Only objects generated with the option list = TRUE
can be
updated.
A list of chains produced by MCMC.parallel
can be
updated. However, the calculations are not performed in parallel
(i.e. only a single CPU is used).
A updated version of MCMC.object
.
Andreas Scheidegger, andreas.scheidegger@eawag.ch or scheidegger.a@gmail.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ## ----------------------
## Banana shaped distribution
## log-pdf to sample from
p.log <- function(x) {
B <- 0.03 # controls 'bananacity'
-x[1]^2/200 - 1/2*(x[2]+B*x[1]^2-100*B)^2
}
## ----------------------
## generate 200 samples
samp <- MCMC(p.log, n=200, init=c(0, 1), scale=c(1, 0.1),
adapt=TRUE, acc.rate=0.234, list=TRUE)
## ----------------------
## add 200 to the existing chain
samp <- MCMC.add.samples(samp, n.update=200)
str(samp)
|
Loading required package: parallel
Loading required package: coda
Loading required package: Matrix
generate 200 samples
generate 200 samples
List of 7
$ samples : num [1:400, 1:2] 0 0.859 -1.963 -2.241 -2.776 ...
$ log.p : num [1:400] -2 -2.76 -2.42 -2.6 -2.06 ...
$ cov.jump : num [1:2, 1:2] 84.73 -3.18 -3.18 8.45
$ n.sample : num 400
$ acceptance.rate : num 0.319
$ adaption : logi TRUE
$ sampling.parameters:List of 3
..$ sample.density:function (x)
..$ acc.rate : num 0.234
..$ gamma : num 0.5
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.