Learn R Programming

SANple (version 0.2.0)

traceplot: Traceplot: plot MCMC chains

Description

Check the convergence of the MCMC through visual inspection of the chains.

Usage

traceplot(object, params, 
          show_density = TRUE, 
          show_burnin = TRUE, 
          length_burnin = NULL, 
          show_convergence = TRUE, 
          trunc_plot = 10)

Value

The function displays the traceplots of the MCMC algorithm.

Arguments

object

object of class SANmcmc (the result of a call to sample_fiSAN, sample_fSAN, or sample_CAM).

params

vector of strings with the names of the parameters to check.

show_density

logical (default TRUE). Whether a kernel estimate of the density should be plotted. The burn-in is always discarded.

show_burnin

logical (default TRUE). Whether the first part of the chains should be plotted in the traceplots.

length_burnin

if show_burnin = FALSE, the length of the burn-in to be discarded.

show_convergence

logical (default TRUE). Whether a superimposed red line of the cumulative mean should be plotted.

trunc_plot

integer (default = 10). For multidimensional parameters, the maximum number of components to be plotted.

Examples

Run this code
set.seed(123)
y <- c(rnorm(40,0,0.3), rnorm(20,5,0.3))
g <- c(rep(1,30), rep(2, 30))
out <- sample_fiSAN(nrep = 500, burn = 200, 
                    y = y, group = g, 
                    nclus_start = 2,
                    maxK = 20, maxL = 20,
                    beta = 1)
traceplot(out, params = c("mu", "sigma2"), trunc_plot = 2)


Run the code above in your browser using DataLab