swapElements-method: Swap elements of MCMC samples

Description Arguments Details Value See Also Examples

Description

Calling swapElements() on an mcmcoutput object swaps all labels by the schema given in the index argument.

Arguments

object

An mcmcoutput object containing the sampled values.

index

An array specifying the extraction of the values.

Details

This function is merely a utility function that simplifies relabeling for users and developers. For relabeling the labels have to be permuted and depending on the MCMC sampling chosen there could be a lot of different slots that need to be permuted. swapElements() swaps the elements in any slot that needs to be relabeled.

Value

An mcmcoutput object with swapped elements.

See Also

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 
# Generate a model 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)
index <- matrix(c(1, 2), nrow = getM(f_output) + 1, 
                ncol = 2)[1:getM(f_output),]
swapElements(f_output, index)

## End(Not run)

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