plotBUGSTrace: Trace Plots of MCMC Chains from BUGS

Description Usage Arguments Details See Also

View source: R/plotBUGSTrace.R

Description

Produces trace plots of the MCMC samples for each parameter in the fitted FCS2 model. These can be used to visualise the convergence of the MCMC chains and the autocorrelation.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
plotBUGSTrace(
  fit,
  variables = variable.names(fit, rw = "singular", spatial = "singular", hyperpar =
    "prec"),
  chains = 1:fit$bugsFit$n.chains,
  nPerPage = 12,
  col = chains + 1,
  ylab,
  ylim,
  main,
  ...
)

Arguments

fit

an "fcs2Fit" object containing a full FCS2 model fit, as returned from fcs2FitModel with runBUGS = TRUE.

variables

an optional character vector giving the names of the model variables to plot. fcs2:::variable.names.fcs2Fit can be used for this, but only singular variable names can be given.

chains

which MCMC chains to plot. Default to all.

nPerPage

the number of trace plots to create on each page.

col

a vector giving the colour to use for each chain in chains.

ylab, ylim, main, ...

further arguments passed to plot when creating each plot.

Details

If the MCMC chains have converged, the multiple chains (in different colours) should agree; Their values should not be identical but they should cover the same range of values as each other.

The MCMC chains should also mix well meaning that they should move about the parameter space quickly. A chain that moves slowly across the parameter space has high autocorrelation. This can also be verified by plotting the autocorrelation of a parameter using acf. The autocorrelation can be reduced by thinning the sample using thinBUGSSamples or by specifying a larger number for n.thin when fitting.

See Also

thinBUGSSamples


aquaMetrics/fcs2 documentation built on Aug. 21, 2021, 12:55 p.m.