extract-method: Extracts single samples from a multivariate Normal mixture

Description Arguments Details Value See Also Examples

Description

Calling extract() on an mcmcoutput object with a multivariate Normal mixture model extracts single samples.

Arguments

object

An mcmcoutput or mcmcoutputperm object containing the MCMC samples.

index

An integer specifying the dimension to extract.

Details

This function simplifies the analysis of multivariate Normal mixtures that come along with matrices instead of vectors for component parameters as it extracts the mean matrix, the variance matrices and in addition the inverted variance matrices with a single call. In additon, it enriches the output object with metadata like the dimension of the data r, the number of components K, and the distribution (in this case "normult).

Value

An mcmcextract object containing the parameters, weights, and metadata of the extracted dimension.

See Also

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# Generate a multivariate Normal mixture model.
means <- matrix(c(1, 2, 2, 4), nrow = 2) 
var1 <- matrix(c(1, 0.3, 0.3, 2), nrow=2)
var2 <- matrix(c(3, 0.3, 0.3, 6), nrow=2)
vars <- array(c(var1,var2), dim = c(2,2,2))
f_model <- model(dist='normult', K = 2, r = 2, par = list(mu=means, sigma=vars))
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)
# Extract a single MCMC sample.
f_output1 <- extract(f_output, index = 1000)

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