subseq-method: Extract sub-chains from MCMC samples

Description Arguments Details Value See Also Examples

Description

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.

Arguments

object

An mcmcoutput or mcmcoutputperm object containing samples from MCMC samples.

index

A logical array of dimension Mx1 defining the schema for the sub-chain.

Details

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.

Value

An mcmcoutput or mcmcoutputperm object containing the sub-chained MCMC samples.

See Also

Examples

 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)

simonsays1980/finmix documentation built on Dec. 23, 2021, 2:25 a.m.