Description Arguments Details Value See Also Examples
Calling subseq()
on an mcmcoutput
or mcmcoutputperm
object creates a
sub-chain defined by the argument index
. Sub-chains can be used to further
investigate convergence of MCMC sampling.
object |
An |
index |
A logical |
Running MCMC sampling should by time result in a roughly stationary sequence
of random draws. If trace plots do not show this stationary pattern MCMC
sampling should be run with a longer burn-in period until the sampling
distribution has converged. Another possibility is to remove the first draws.
Removing the first draws can be achieved by calling subseq()
on the object
holding the MCMC samples.
In case of autocorrelations in the traces it is also possible to extract
every t
-th value by setting the index
argument accordingly.
An mcmcoutput
or mcmcoutputperm
object containing the
sub-chained MCMC samples.
mcmcoutput for the class storing MCMC samples
mcmcoutputperm for the corresponding class for re-labeled MCMC samples
plotTraces()
for plotting traces to be used for a convergence analysis
swapElements()
for swapping elements in MCMC samples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # Define a mixture of Poisson distributions.
f_model <- model("poisson", par = list(lambda = c(0.3, 1.2)), K = 2)
# Simulate data from the model.
f_data <- simulate(f_model)
# Define the hyper-parameters for MCMC sampling.
f_mcmc <- mcmc(storepost = FALSE)
# Define the prior distribution by relying on the data.
f_prior <- priordefine(f_data, f_model)
# Start MCMC sampling.
f_output <- mixturemcmc(f_data, f_model, f_prior, f_mcmc)
# Define a sub-chain randomly.
index <- array(sample(c(FALSE, TRUE), size = getM(f_output), replace = TRUE))
# Extract the sub-chain.
subseq(f_output, index)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.