sixway {R2MLwiN} | R Documentation |
Draws a sixway plot of MCMC diagnostics.
Description
This function produces a variety of diagnostic plots and statistics for MCMC chains.
Usage
sixway(chain, name = NULL, acf.maxlag = 100, pacf.maxlag = 10, ...)
Arguments
chain |
A numeric vector, |
name |
The parameter name. If |
acf.maxlag |
Maximum lag at which to calculate the auto-correlation
function. |
pacf.maxlag |
Maximum lag at which to calculate the partial
auto-correlation function. |
... |
Other graphical parameters (see |
Details
A variety of plots and statistics are displayed in an R graphic window, including the following:
a trace plot of the plotted trajectory of an MCMC chain for a model parameter;
a kernel density plot; kernel density estimates are computed using
density
;a plotted autocorrelation function (uses
acf
);a plotted partial autocorrelation function (uses
pacf
);a plot of the estimated Monte Carlo standard error (
MCSE
) of the posterior estimate of the mean against the number of iterations. As MCMC is a simulation-based approach this induces (Monte Carlo) uncertainty due to the random numbers it uses. This uncertainty reduces with more iterations, and is measured by the MCSE, and so this graph details how long the chain needs to be run to achieve a specific MCSE;a box contains two contrasting accuracy diagnostics. The Raftery-Lewis diagnostic (
raftery.diag
) is a diagnostic based on a particular quantile of the distribution. The diagnostic Nhat is used to estimate the length of Markov chain required to estimate a particular quantile (e.g. the 2.5% and 97.5% quantiles) to a given accuracy. The Brooks-Draper diagnostic (BD
) is a diagnostic based on the mean of the distribution. It is used to estimate the length of Markov chain required to produce a mean estimate to k(=2) significant figures with a given accuracy;a box of summary statistics including the posterior mean, sd, mode, quantiles and the effective sample size (ESS) of the chain.
Author(s)
Zhang, Z., Charlton, C.M.J., Parker, R.M.A., Leckie, G., and Browne, W.J. (2016) Centre for Multilevel Modelling, University of Bristol.
See Also
BD
,MCSE
,density
,acf
,pacf
,raftery.diag
,effectiveSize
Examples
## Not run:
library(R2MLwiN)
# NOTE: if MLwiN not saved in location R2MLwiN defaults to, specify path via:
# options(MLwiN_path = 'path/to/MLwiN vX.XX/')
# If using R2MLwiN via WINE, the path may look like this:
# options(MLwiN_path = '/home/USERNAME/.wine/drive_c/Program Files (x86)/MLwiN vX.XX/')
## Example: tutorial
data(tutorial, package = "R2MLwiN")
(mymodel <- runMLwiN(normexam ~ 1 + standlrt + (1 + standlrt | school) + (1 | student),
estoptions = list(EstM = 1, resi.store.levs = 2), data = tutorial))
sixway(mymodel@chains[, "FP_standlrt", drop = FALSE], "beta_1")
## End(Not run)