Description Usage Arguments Value See Also Examples
Resume
will finish a file-backed MCMC that was interrupted. To resume
an MCMC run, specify the MCMC's backing path and the sampling will continue
from the last completed sample in the chain. Note, however, that the random
number generator state from when the MCMC was interrupted is not
restored, so the resulting chain my not be reproducible, even if a seed was
specified before the sampling was interrupted.
1 | Resume(backing.path)
|
backing.path |
directory path where the (partially completed) MCMC samples were saved |
A list of either matrix
or big.matrix
with the MCMC samples. Each row in the matrices corresponds to one sample
from the MCMC chain.
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 28 | # Setup the MCMC
n.iter <- 5
SampleX <- function(x) x + 1
backing.path <- tempfile()
dir.create(backing.path)
x <- 0
interrupt.mcmc <- TRUE
Mcmc <- InitMcmc(n.iter, backing.path=backing.path)
# Interrupt the MCMC during the third iteration
try({
samps <- Mcmc({
x <- SampleX(x)
if(x==3 && interrupt.mcmc) break
})
}, silent=TRUE)
# The sampling is incomplete
samps <- LoadMcmc(backing.path)
samps$x[,]
rm(samps)
# Resume the MCMC
interrupt.mcmc <- FALSE
samps <- Resume(backing.path)
# All samples are available
samps$x[,]
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.