Calculate, print and plot the Monte Carlo error of the samples from a 'JointAI' model, combining the samples from all MCMC chains.
Arguments
- x
object inheriting from class 'JointAI'
- subset
subset of parameters/variables/nodes (columns in the MCMC sample). Follows the same principle as the argument
monitor_paramsin*_imp.- exclude_chains
optional vector of the index numbers of chains that should be excluded
- start
the first iteration of interest (see
window.mcmc)- end
the last iteration of interest (see
window.mcmc)- thin
thinning interval (integer; see
window.mcmc). For example,thin = 1(default) will keep the MCMC samples from all iterations;thin = 5would only keep every 5th iteration.- digits
number of digits for the printed output
- warn
logical; should warnings be given? Default is
TRUE.- mess
logical; should messages be given? Default is
TRUE.- ...
Arguments passed on to
mcmcse::mcse.matsizerepresents the batch size in “
bm” and the truncation point in “bartlett” and “tukey”. Default isNULLwhich implies that an optimal batch size is calculated using thebatchSizefunction. Can take character values of “sqroot” and “cuberoot” or any numeric value between 1 and n/2. “sqroot” means size is \(\lfloor n^{1/2} \rfloor\) and “cuberoot” means size is \(\lfloor n^{1/3} \rfloor\).ga function such that \(E(g(x))\) is the quantity of interest. The default is
NULL, which causes the identity function to be used.methodany of “
bm”,“obm”,“bartlett”, “tukey”. “bm” represents batch means estimator, “obm” represents overlapping batch means estimator with, “bartlett” and “tukey” represents the modified-Bartlett window and the Tukey-Hanning windows for spectral variance estimators.rThe lugsail parameters (
r) that converts a lag window into its lugsail equivalent. Larger values ofrwill typically imply less underestimation of “cov”, but higher variability of the estimator. Default isr = 3andr = 1,2are also good choices although may lead to underestimates of the variance.r > 5is not recommended.
- data_scale
logical; show the Monte Carlo error of the sample transformed back to the scale of the data (
TRUE) or on the sampling scale (this requires the argumentkeep_scaled_mcmc = TRUEto be set when fitting the model)- plotpars
optional; list of parameters passed to
plot()- ablinepars
optional; list of parameters passed to
abline()- minlength
number of characters the variable names are abbreviated to
Value
An object of class MCElist with elements unscaled,
scaled and digits. The first two are matrices with
columns est (posterior mean), MCSE (Monte Carlo error),
SD (posterior standard deviation) and MCSE/SD
(Monte Carlo error divided by post. standard deviation.)
Note
Lesaffre & Lawson (2012; p. 195) suggest the Monte Carlo error of a parameter should not be more than 5% of the posterior standard deviation of this parameter (i.e., \(MCSE/SD \le 0.05\)).
Long variable names:
The default plot margins may not be wide enough when variable names are
longer than a few characters. The plot margin can be adjusted (globally)
using the argument "mar" in par.
See also
The vignette
Parameter Selection
provides some examples how to specify the argument subset.
