plotTraces-method: Plots traces of MCMC sampling

Description Arguments Details Value See Also Examples

Description

plotTraces() is a class method for mcmcoutput and mcmcoutputperm objects. For the former class it plots the traces of MCMC samples and for the latter of the corresponding permuted samples coming from relabeling.

Arguments

x

An mcmcoutput or mcmcoutputperm object containing all sampled values.

dev

A logical indicating, if the plots should be shown by a graphical device. If plots should be stored to a file set dev to FALSE.

lik

An integer indicating, if the log-likelihood traces should be plotted (default). If set to 0 the traces for the parameters and weights are plotted instead.

col

A logical indicating, if the plot should be colored.

...

Further arguments to be passed to the plotting function.

Details

Calling plotTraces() with lik set to 1, plots the MCMC traces of the mixture log-likelihood, the mixture log-likelihood of the prior distribution, or the log-likelihood of the complete data posterior, if the model has unknown indicators.

If lik is set to 0 the parameters of the components, the posterior parameters, and the parameters of the hierarchical prior are plotted together with K-1 weights.

Hierarchical priors

In case of hierarchical priors, the function also plots traces from the sampled hierarchical prior's parameters, in case lik is set to 1.

Posterior density parameters

In case posterior density parameters had been stored in MCMC sampling, the traces of these parameters are added to the plot.

Value

A plot of the traces of the MCMC samples.

See Also

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Define a Poisson mixture model with two components.
f_model <- model("poisson", par = list(lambda = c(0.3, 1.2)), K = 2)
# Simulate data from the mixture 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)
# Do not use a hierarchical prior.
setHier(f_prior) <- FALSE
# Start MCMC sampling.
f_output <- mixturemcmc(f_data, f_model, f_prior, f_mcmc)
f_outputperm <- mcmcpermute(f_output)
plotTraces(f_outputperm, lik = 0)

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