Title: | Bayesian Output Analysis Program (BOA) for MCMC |
---|---|
Description: | A menu-driven program and library of functions for carrying out convergence diagnostics and statistical and graphical analysis of Markov chain Monte Carlo sampling output. |
Authors: | Brian J. Smith [aut, cre] |
Maintainer: | Brian J. Smith <[email protected]> |
License: | GPL-2 |
Version: | 1.1.8-2 |
Built: | 2025-03-08 04:45:56 UTC |
Source: | https://github.com/brian-j-smith/boa |
Computes lag autocorrelations for the parameters in an MCMC sequence.
boa.acf(link, lags)
boa.acf(link, lags)
link |
Matrix whose columns and rows contain the monitored parameters
and the MCMC iterations, respectively. The iteration numbers and parameter
names must be assigned to |
lags |
Vector of lags at which to estimate the autocorrelation function. |
A matrix whose columns and rows contain the estimated autocorrelation functions at the specified lags and the monitored parameters, respectively.
Brian J. Smith
boa.plot
, boa.plot.acf
,
boa.print.acf
Extracts and sets the MCMC sequence(s) stored internally for use during a BOA session. Users can safely use this function to extract data. However, it should not be called directly to modify the stored MCMC sequence(s). Instead, data management should accomplished with the libboa.chain functions.
boa.chain(...)
boa.chain(...)
... |
A list may be given as the only argument, or a character string
given as the only argument, or any number of arguments may be in the
|
If no arguments are supplied, a list of the current values is returned. If a character string is given, the current value of the named variable is returned. Otherwise, no values are returned.
Master list containing all added MCMC sequences. Sequences may only be added to or deleted from the master list. The sequences in this list are never modified or used in any of the analyses. It serves as a template for the working list described below. The parameters and iterations may differ between the sequences. Each element in the list is a matrix whose columns and rows contain the monitored parameters and the MCMC iterations, respectively. The iteration numbers and parameter names are stored in the dimnames.
List containing the support for each of the parameters in 'master'. Each element in the list is a matrix whose columns and rows contain the monitored parameters and the support (lower and upper limits), respectively. The default for each parameter is c(-Inf, Inf).
Working list used in all analyses. This list is essentially a modifiable copy of 'master'. All data management functions operate on the working list.
List containing the support for each of the parameters in 'work'.
Logical value indicating that the working list is an
identical copy of the master list. This variable is automatically set to F
after a successful call to boa.chain.subset
or
boa.chain.collapse
. While work.sync = F
, only the master
list will be updated if MCMC sequences are added or deleted. A call to
boa.chain.reset
will reset this variable to T and copy the master
list to the working list.
When variables are set, boa.chain() modifies the internal list .boa.chain
.
If boa.chain() is called with either a list as the single argument, or with one
or more arguments in the <name> = <value>
form, the variables specified
by the names in the arguments are modified.
Brian J. Smith
Adds an MCMC sequence to the session lists of sequences. Most users should
not call this function directly. Passing improperly formatted data to this
function will most likely break the functions in this library. The preferred
method of adding a new sequence is to call the function boa.chain.import
.
boa.chain.add(link, lname)
boa.chain.add(link, lname)
link |
Matrix whose columns and rows contain the monitored parameters
and the MCMC iterations, respectively. The iteration numbers and parameter
names must be assigned to |
lname |
Character string giving the list name to use for the newly added MCMC sequence. |
A logical value indicating that 'link' has been successfully added.
Brian J. Smith
Concatenates together all of the MCMC sequences in the working session list of sequences. Only those parameters common to all sequences are kept.
boa.chain.collapse()
boa.chain.collapse()
A logical value indicating that the MCMC sequences have been collapsed. If the sequences share no common parameters, no modifications are made to the working list and FALSE is returned.
Brian J. Smith
codeboa.chain.reset, codeboa.chain.subset
Delete MCMC sequences from the session list of sequences.
boa.chain.del(lnames, pnames)
boa.chain.del(lnames, pnames)
lnames |
Character vector giving the names of the MCMC sequences in the session list of sequences to be deleted. If omitted, no sequences are deleted. |
pnames |
Character vector giving the names of the parameters in the MCMC sequences to be deleted. If omitted, no parameters are deleted. |
The specified MCMC sequences are deleted from the session lists of sequences.
Brian J. Smith
Evaluates a user-specified expression to formulate a new parameter in each of the system lists of MCMC sequences.
boa.chain.eval(expr, pname)
boa.chain.eval(expr, pname)
expr |
S expression object used to formulate the new parameter. Typically, the new parameter is a function of the existing parameters. |
pname |
Name given to the new parameter. |
The specified parameter is added to the session lists of MCMC sequences.
Brian J. Smith
Computes the Gelman and Rubin convergence diagnostics for a list of MCMC sequences. Estimates are calculated from the second half of each sequence.
boa.chain.gandr(chain, chain.support, alpha, pnames, window, to)
boa.chain.gandr(chain, chain.support, alpha, pnames, window, to)
chain |
List of matrices whose columns and rows contain the monitored parameters and the MCMC iterations, respectively. The iteration numbers and parameter names must be assigned to the dimnames. |
chain.support |
List of matrices whose columns and rows contain the monitored parameters and the support (lower and upper limits), respectively. |
alpha |
Quantile (1 - alpha / 2) at which to estimate the upper limit of the shrink factor. |
pnames |
Character vector giving the names of the parameters to use in the analysis. If omitted, all parameters are used. |
window |
Proportion of interations to include in the analysis. If omitted, 50% are included. |
to |
Largest iteration to include in the analysis. If omitted, no upper bound is set. |
psrf |
A vector containing the Gelman and Rubin (uncorrected) potential scale reduction factors for the monitored parameters. |
csrf |
A matrix whose columns and rows are the Gelman and Rubin corrected scale reduction factors (i.e. shrink factor estimates at the median and specified quantile of the sampling distribution) and the monitored parameters, respectively. A correction of (df + 3) / (df + 1) is applied to the scale reduction factors. |
mpsrf |
A numeric value giving the multivariate potential scale reduction factor proposed by Brooks and Gelman. |
window |
A numeric vector with two elements giving the range of the iterations used in the analysis. |
Brian J. Smith, Nicky Best, Kate Cowles
Brooks, S. and Gelman, A. (1998). General methods for monitoring convergence of iterative simulations. Journal of Computational and Graphical Statistics, 7(4), 434-55.
Gelman, A. and Rubin, D. B. (1992). Inference from iterative simulation using multiple sequences. Statistical Science, 7, 457-72.
boa.plot
, boa.plot.bandg
,
boa.plot.gandr
, boa.print.gandr
Reads an MCMC sequence from an external file and adds it to the session lists of sequences.
boa.chain.import(prefix, path = boa.par("path"), type = "ASCII")
boa.chain.import(prefix, path = boa.par("path"), type = "ASCII")
prefix |
Character string giving the prefix for the file(s) in which the MCMC sequence is stored. |
path |
Character string giving the directory path in which the file(s) subsides. |
type |
Character string specifying the type of data to be imported. Currently, the supported types are:
|
A logical value indicating that the specified file(s) has been successfully imported.
The imported MCMC sequence is automatically added to the session lists of
sequences via a call to boa.chain.add
.
Brian J. Smith
boa.chain.add
, boa.importASCII
,
boa.importBUGS
Returns summary information from a list of MCMC sequences.
boa.chain.info(chain, chain.support)
boa.chain.info(chain, chain.support)
chain |
List of matrices whose columns and rows contain the monitored parameters and the MCMC iterations, respectively. The iteration numbers and parameter names must be assigned to the dimnames. |
chain.support |
List of matrices whose columns and rows contain the monitored parameters and the support (lower and upper limits), respectively. |
lnames |
Character vector giving the names of the MCMC sequences in the session list of sequences. |
pnames |
List of character vectors giving the parameter names in each of the MCMC sequences. |
iter |
List of numeric vectors giving the iterations from each MCMC sequence. |
iter.range |
Matrix whose columns give the range of the iterations for the MCMC sequences named in the rows. |
support |
List of numeric vectors giving the support for the parameters in each of the MCMC sequences. |
Brian J. Smith
Returns the data in the working list of MCMC sequences to the state it was in
when originally imported. This function undoes any subsetting or collapsing
that was done via the boa.chain.collapse
or
boa.chain.subset
functions.
boa.chain.reset()
boa.chain.reset()
Returns the data in the working list of MCMC sequences to the state it was in
when originally imported. This function undoes any subsetting or collapsing
that was done via the boa.chain.collapse
or
boa.chain.subset
functions.
Brian J. Smith
boa.chain.collapse
, boa.chain.subset
Selects a subset of the MCMC sequences stored in the working session list of sequences.
boa.chain.subset(lnames, pnames, iter)
boa.chain.subset(lnames, pnames, iter)
lnames |
Character vector giving the names of the MCMC sequences to include in the subset. If omitted, all sequences are included. |
pnames |
Character vector giving the names of the parameters to include in the subset. If omitted, all parameters are included. |
iter |
Character vector giving the names of the parameters to include in the subset. If omitted, all parameters are included. |
A logical value indicating that the data has been successfully subsetted. If the requested subset contains no data, the working session list is not modified and FALSE is returned.
The subsetted data, if not an empty set, is copied to the working session list of MCMC sequences used in all analyses.
Brian J. Smith
boa.chain.collapse
, boa.chain.reset
Modifies the support (range of possible values) for the parameters in the session lists of MCMC sequences.
boa.chain.support(lnames, pnames, limits)
boa.chain.support(lnames, pnames, limits)
lnames |
Character vector giving the names of the MCMC sequences over which to apply the changes. If omitted, changes are applied to all sequences. |
pnames |
Character vector giving the names of the parameters whose support is to be modified. |
limits |
Numeric vector with two elements giving the lower and upper limits, respectively, of the support for the specified parameters. Unbounded lower or upper limits should be specified as -Inf or Inf, respectively. |
A logical vector with two elements indicating that the support has been changed for variables in the master list and working list of MCMC sequences, respectively.
The support for each of the specified parameters is changed in the session lists of MCMC sequences.
Brian J. Smith
Computes the Geweke convergence diagnostics for the parameters in an MCMC sequence.
boa.geweke(link, p.first, p.last)
boa.geweke(link, p.first, p.last)
link |
Matrix whose columns and rows contain the monitored parameters
and the MCMC iterations, respectively. The iteration numbers and parameter
names must be assigned to |
p.first |
Proportion of iterations to include in the first window. |
p.last |
Proportion of iterations to include in the last window. |
A matrix whose columns contain the Z-Scores and associated p-values and whose rows contain the monitored parameters.
Brian J. Smith
Geweke, J. (1992). Evaluating the accuracy of sampling-based approaches to calculating posterior moments. In Bayesian Statistics 4, (ed. J. M. Bernardo, J. O. Berger, A. P. Dawid, and A. F. M. Smith). Clarendon Press, Oxford, UK.
boa.plot
, boa.plot.geweke
,
boa.print.geweke
Computes the Heidleberger and Welch convergence diagnostics for the parameters in an MCMC sequence.
boa.handw(link, error, alpha)
boa.handw(link, error, alpha)
link |
Matrix whose columns and rows contain the monitored parameters
and the MCMC iterations, respectively. The iteration numbers and parameter
names must be assigned to |
error |
Accuracy of the posterior estimates for the parameters. |
alpha |
Alpha level for the confidence in the sample mean of the retained iterations. |
A matrix whose columns and rows are the Heidleberger and Welch convergence diagnostics (i.e. stationarity test, number of iterations to keep and to drop, Cramer-von-Mises statistic, halfwidth test, mean, and halfwidth) and the monitored parameters, respectively.
Brian J. Smith, Nicky Best, Kate Cowles
Heidelberger, P. and Welch, P. (1983). Simulation run length control in the presence of an initial transient. Operations Research, 31, 1109-44.
Estimates the highest probability density (HPD) interval for the given parameter draws. Uses the Chen and Shao algorithm assuming a unimodal marginal posterior distribution.
boa.hpd(x, alpha)
boa.hpd(x, alpha)
x |
MCMC draws from the marginal posterior to use in computing the HPD. |
alpha |
Specifies the 100*(1 - alpha)% interal to compute. |
A vector containing the lower and upper bound of the HPD interval, labeled "Lower Bound" and "Upper Bound", respectively.
Brian J. Smith
Chen, M-H. and Shao, Q-M. (1999). Monte Carlo estimation of Bayesian credible and HPD intervals. Journal of Computational and Graphical Statistics, 8(1), 69-92.
Import data from an ASCII text file. The variables and iterations should appear in the columns and rows, respectively, of the file. The variable names must be given in the first row. The iteration numbers are taken from the the column entitled "iter" (case-sensitive), if it exists; otherwise, the numbers 1..n are used, where n is the number of rows. The columns may be separated by white space or tabs.
boa.importASCII(prefix, path = NULL)
boa.importASCII(prefix, path = NULL)
prefix |
Character string giving the prefix for the files in which the ASCII data is stored. boa.importASCII() looks for the file "prefix.txt". |
path |
Character string giving the directory path in which the file subsides. This argument may be omitted if the file is located in the current working directory. The specified path should not end with a slash(es). |
If the data is successfully imported, a matrix is returned whose columns and rows contain the monitored parameters and the MCMC iterations, respectively. The iteration numbers and parameter names are stored in the dimnames of the returned matrix. Otherwise, NULL is returned.
Brian J. Smith
boa.chain.import
, boa.importBUGS
,
boa.importMatrix
Import data from BUGS output files.
boa.importBUGS(prefix, path = NULL)
boa.importBUGS(prefix, path = NULL)
prefix |
Character string giving the prefix for the files in which the BUGS output is stored. boa.importBUGS() looks for the two files "prefix.ind" and "prefix.out". |
path |
Character string giving the directory path in which the file subsides. This argument may be omitted if the file is located in the current working directory. The specified path should not end with a slash(es). |
If the data is successfully imported, a matrix is returned whose columns and rows contain the monitored parameters and the MCMC iterations, respectively. The iteration numbers and parameter names are stored in the dimnames of the returned matrix. Otherwise, NULL is returned.
Brian J. Smith
boa.chain.import
, boa.importASCII
,
boa.importMatrix
Import data from an S numeric matrix object. The variables and iterations should appear in the columns and rows, respectively, of the matrix. The variable names and iteration numbers may be optionally specified in the dimnames of the matrix object. Otherwise, the iterations will be numbered 1..n, where n is the number of rows.
boa.importMatrix(prefix)
boa.importMatrix(prefix)
prefix |
Character string giving the name of the S object. |
If the data is successfully imported, a matrix is returned whose columns and rows contain the monitored parameters and the MCMC iterations, respectively. The iteration numbers and parameter names are stored in the dimnames of the returned matrix. Otherwise, NULL is returned.
Brian J. Smith
boa.chain.import
, boa.importASCII
,
boa.importBUGS
boa.init() is the first function called to start a BOA session when using the command-line. It sets up the internal data structures and initializes them with the appropriate default values.
boa.init(recover = FALSE)
boa.init(recover = FALSE)
recover |
a logical value for use if the previous BOA menu session
terminated unexpectedly. It may be possible to crash the menu system by
supplying the wrong type of data. In the event of a crash, |
Brian J. Smith
Loads the data and global parameter settings from a previously saved BOA session.
boa.load(name, envir = globalenv())
boa.load(name, envir = globalenv())
name |
Character string giving the name of the object containing the session to be loaded. |
envir |
The 'environment' from which the object should come. For more
information, consult the help documentation in R on the |
A logical value indicating that the object was successfully loaded.
Brian J. Smith
Displays and sets the global parameters stored internally for use during a BOA session.
boa.par(...)
boa.par(...)
... |
A list may be given as the only argument, or a character string
given as the only argument, or any number of arguments may be in the
|
If no arguments are supplied, a list of the current values is returned. If a character string is given, the current value of the named variable is returned. Otherwise, a list of the named variables and their old values is returned, but not printed.
Numeric vector of lags at which to estimate the autocorrelation function.
Type I error rate used for all statistical tests and confidence intervals.
Character string giving the filename extension used when importing ASCII files.
Function for computing the bandwidth used in estimating the density functions for parameters. This should take one argument which is a numeric vector of data on which density estimation is to be performed. A constant bandwidth may be specified by having this function return the desired constant.
Number of iterations to include in each batch when computing batch means and lag-1 batch autocorrelations. The batch size has the single largest impact on the time required to compute summary statistics. The computation time is decreased dramatically as the batch size increases. Consequently, users may want to increase the value of this variable for long MCMC sequences.
Character string giving the name of the function that creates graphics windows on the current platform. For Unix systems this is either "motif", "openlook", or "X11". The default is "motif" for the UNIX S-PLUS, "win.graph" for Windows S-PLUS, "X11" for UNIX R, and "windows" for Windows R.
Numeric vector containing the active graphics windows in use by the program. This is automatically maintained by the program, user should not directly modify this variable.
Number of line segments within the MCMC sequence at which to plot the Gelman and Rubin shrink factors.
Proportion of iterations to include in the Brooks, Gelman, and Rubin Statistics.
Number of line segments within the MCMC sequence at which to plot the Geweke convergence diagnostics.
Proportion of iterations to include in the first window when computing the Geweke convergence diagnostics.
Proportion of iterations to include in the last window when computing the Geweke convergence diagnostics.
Accuracy of the posterior estimates when computing the Heidleberger and Welch convergence diagnostics.
Character string giving the type of window used in estimating the density functions for parameters. Other choices are "cosine", "rectangular", or "triangular".
Logical value indicating that a legend be included in the plots.
Character string giving the directory path in which the raw data files are stored. The default may be used if the files are located in the current working directory. The specified path should not end with a slash(es).
List specifying graphics parameters passed to the par
function for the construction of new plots.
Numeric vector giving the maximum number of rows and columns, respectively, of plots to include in a single graphics window.
Logical value indicating that a new graphics window be automatically opened upon successive calls to boa.plot(). Otherwise, previous graphics windows will be closed.
Logical value indicating that each plot should include only one MCMC sequence. Otherwise, all sequences are displayed on the same plot.
Vector of probabilities at which to compute the quantiles. Values must be between 0 and 1.
Desired amount of error in estimating the quantile specified in the Raftery and Lewis convergence diagnostics.
Delta valued used in computing the Raftery and Lewis convergence diagnostics.
Quantile to be estimated in computing the Raftery and Lewis convergence diagnostics.
Logical value indicating that a title be added to the plots.
When variables are set, boa.par() modifies the internal list .boa.par. If boa.par() is called with either a list as the single argument, or with one or more arguments in the <name> = <value> form, the variables specified by the names in the arguments are modified.
Brian J. Smith
Automatically generates the specified plot type for all parameters in the working session list of MCMC sequences. This function takes care of all the plotting tasks - opening windows, setting the number of plots per page, and adding titles.
boa.plot(type, dev = boa.par("dev"), mfdim = boa.par("plot.mfdim"), newplot = boa.par("plot.new"), onelink = boa.par("plot.onelink"), title = boa.par("title"))
boa.plot(type, dev = boa.par("dev"), mfdim = boa.par("plot.mfdim"), newplot = boa.par("plot.new"), onelink = boa.par("plot.onelink"), title = boa.par("title"))
type |
The type of plots to generate. The supported types are:
|
dev |
Character string giving the name of the function that creates graphics windows on the current platform. For Unix systems this is either "motif", "openlook", or "X11". For windows, this should be set to "win.graph" |
mfdim |
Numeric vector giving the maximum number of rows and columns, respectively, of plots to include in a single graphics window. If only one graphics window is opened, 'mfdim' is proportionately scaled down so as to minimize the number of empty frames within that window. |
newplot |
Logical value indicating that a new graphics window be automatically opened. Otherwise, previous graphics windows will be closed. |
onelink |
Logical value indicating that each plot should include only one MCMC sequence. Otherwise, all sequences are displayed on the same plot. |
title |
Logical value indicating that a title be added to the plot. |
A logical value indicating that the plots were successfully created.
Brian J. Smith
boa.plot.acf
, boa.plot.bandg
,
boa.plot.density
, boa.plot.gandr
,
boa.plot.geweke
, boa.plot.history
,
boa.plot.trace
Creates a single plot of the lag autocorrelations for a specified parameter.
boa.plot.acf(lname, pname, annotate = boa.par("legend"))
boa.plot.acf(lname, pname, annotate = boa.par("legend"))
lname |
Character string giving the name of the desired MCMC sequence in the working session list of sequences. |
pname |
Character string giving the name of the parameter to be plotted. |
annotate |
Logical value indicating that a legend be included in the plot. |
A logical value indicating that the plot was successfully created.
Brian J. Smith
Plots the Brooks and Gelman multivariate shrink factors within different line segments across the MCMC sequences. This diagnostic is a multivariate extension to the Gelman and Rubin shrink factors.
boa.plot.bandg(bins = boa.par("gandr.bins"), win = boa.par("gandr.win"), annotate = boa.par("legend"))
boa.plot.bandg(bins = boa.par("gandr.bins"), win = boa.par("gandr.win"), annotate = boa.par("legend"))
bins |
Number of line segments within the MCMC sequence at which to plot the Gelman and Rubin shrink factors. The first segment contains the first 50 iterations; the remaining iterations are partitioned into equal bins and added incrementally to construct the remaining line segments. The shrink factors are plotted against the maximum iteration number for the segment. Cubic splines are used to interpolate through the point estimates for each segment. |
win |
Proportion of iterations to include in the Brooks, Gelman, and Rubin Statistics. |
annotate |
Logical value indicating that a legend be included in the plot. |
A logical value indicating that the plot was successfully created.
Brian J. Smith
boa.chain.gandr
, boa.plot
,
boa.plot.gandr
, boa.print.gandr
Estimates and displays, in a single plot, the density function(s) for the specified parameter(s).
boa.plot.density(lnames, pname, bandwidth = boa.par("bandwidth"), window = boa.par("kernel"), annotate = boa.par("legend"))
boa.plot.density(lnames, pname, bandwidth = boa.par("bandwidth"), window = boa.par("kernel"), annotate = boa.par("legend"))
lnames |
Character vector giving the names of the desired MCMC sequence in the working session list of sequences. |
pname |
Character string giving the name of the parameter to be plotted. |
bandwidth |
Function for computing the bandwidth used in estimating the density functions for parameters. This should take one argument which is a numeric vector of data on which density estimation is to be performed. A constant bandwidth may be specified by having this function return the desired constant. |
window |
Character string giving the type of window used in estimating the density functions for the parameters. Available choices are "cosine", "gaussian", "rectangular", or "triangular". |
annotate |
Logical value indicating that a legend be included in the plot. |
A logical value indicating that the plot was successfully created.
Brian J. Smith
Creates a single plot of the Gelman and Rubin shrink factors within different line segments for a parameter in an MCMC sequence.
boa.plot.gandr(pname, bins = boa.par("gandr.bins"), alpha = boa.par("alpha"), win = boa.par("gandr.win"), annotate = boa.par("legend"))
boa.plot.gandr(pname, bins = boa.par("gandr.bins"), alpha = boa.par("alpha"), win = boa.par("gandr.win"), annotate = boa.par("legend"))
pname |
Character string giving the name of the parameter in the working session list of MCMC sequences to be plotted. |
bins |
Number of line segments within the MCMC sequence at which to plot the Gelman and Rubin shrink factors. The first segment contains the first 50 iterations; the remaining iterations are partitioned into equal bins and added incrementally to construct the remaining line segments. The shrink factors are plotted against the maximum iteration number for the segment. Cubic splines are used to interpolate through the point estimates for each segment. |
alpha |
Quantile (1 - alpha / 2) at which to estimate the upper limit of the shrink factor. |
win |
Proportion of iterations to include in the Brooks, Gelman, and Rubin Statistics. |
annotate |
Logical value indicating that a legend be included in the plot. |
A logical value indicating that the plot was successfully created.
Brian J. Smith
boa.chain.gandr
, boa.plot
,
boa.plot.bandg
, boa.print.gandr
Creates a single plot of the Geweke convergence diagnostics within different line segments for a parameter in an MCMC sequence.
boa.plot.geweke(lname, pname, bins = boa.par("geweke.bins"), p.first = boa.par("geweke.first"), p.last = boa.par("geweke.last"), alpha = boa.par("alpha"), annotate = boa.par("legend"))
boa.plot.geweke(lname, pname, bins = boa.par("geweke.bins"), p.first = boa.par("geweke.first"), p.last = boa.par("geweke.last"), alpha = boa.par("alpha"), annotate = boa.par("legend"))
lname |
Character string giving the name of the desired MCMC sequence in the working session list of sequences. |
pname |
Character string giving the name of the parameter to be plotted. |
bins |
Number of line segments within the MCMC sequence at which to plot the Geweke convergence diagnostics. The ith line segment contains the last ((bins - i + 1) / bins)*100 bins. This may lead to segments in which there are too few iterations to compute the convergence diagnostics. Such segments, if they exist, are automatically omitted from the calculations. |
p.first |
Proportion of iterations to include in the first window. |
p.last |
Proportion of iterations to include in the last window. |
alpha |
Alpha level for the rejection region lines drawn on the graph. |
annotate |
Logical value indicating that a legend be included in the plot. |
A logical value indicating that the plot was successfully created.
Brian J. Smith, Nicky Best, Kate Cowles
boa.geweke
, boa.plot
,
boa.print.geweke
Computes and displays, in a single plot, the running mean(s) for the specified parameter(s).
boa.plot.history(lnames, pname, annotate = boa.par("legend"))
boa.plot.history(lnames, pname, annotate = boa.par("legend"))
lnames |
Character vector giving the name of the desired MCMC sequence in the working session list of sequences. |
pname |
Character vector giving the names of the parameters to be plotted. |
annotate |
Logical value indicating that a legend be included in the plot. |
A logical value indicating that the plot was successfully created.
Brian J. Smith
Set Plotting Parameters
boa.plot.par(mfdim = c(1, 1), title = TRUE)
boa.plot.par(mfdim = c(1, 1), title = TRUE)
mfdim |
Numeric vector with two elements giving the number of rows and column, respectively, of plots to display on the page. Plots will be drawn row-by-row. |
title |
Logical value indicating that a title be added to the plot. |
Brian J. Smith
Adds a title to the graphics window. This function should be called after all plots have been added to the target graphics window.
boa.plot.title(text)
boa.plot.title(text)
text |
Character string giving the title to be centered and displayed across the top of the graphics window. |
Brian J. Smith
Displays, in a single plot, the trace histories for the specified parameter(s).
boa.plot.trace(lnames, pname, annotate = boa.par("legend"))
boa.plot.trace(lnames, pname, annotate = boa.par("legend"))
lnames |
Character vector giving the name of the desired MCMC sequence in the working session list of sequences. |
pname |
Character string giving the name of the parameters to be plotted. |
annotate |
Logical value indicating that a legend be included in the plot. |
A logical value indicating that the plot was successfully created.
Brian J. Smith
Iteratively calls boa.acf() to display the lag autocorrelations for the parameters in each of the MCMC sequences in the working session list of sequences.
boa.print.acf(lags = boa.par("acf.lags"))
boa.print.acf(lags = boa.par("acf.lags"))
lags |
Numeric vector of lags at which to estimate the autocorrelation functions. |
Brian J. Smith
boa.acf
, boa.plot
,
boa.plot.acf
Iteratively computes and displays the correlation matrices for the parameters in each of the MCMC sequences in the working session list of sequences.
boa.print.cor()
boa.print.cor()
Brian J. Smith
Calls boa.chain.gandr() and displays the Gelman and Rubin convergence diagnostics for the MCMC sequences in the working session list of sequences.
boa.print.gandr(alpha = boa.par("alpha"), win = boa.par("gandr.win"))
boa.print.gandr(alpha = boa.par("alpha"), win = boa.par("gandr.win"))
alpha |
Quantile (1 - alpha / 2) at which to estimate the upper limit of the corrected shrink factor. |
win |
Proportion of iterations to include in the Brooks, Gelman, and Rubin Statistics. |
Brian J. Smith
boa.chain.gandr
, boa.plot
,
boa.plot.bandg
, boa.plot.gandr
Iteratively calls boa.geweke() to display the Geweke convergence diagnostics for the parameters in each of the MCMC sequences in the working session list of sequences.
boa.print.geweke(p.first = boa.par("geweke.first"), p.last = boa.par("geweke.last"))
boa.print.geweke(p.first = boa.par("geweke.first"), p.last = boa.par("geweke.last"))
p.first |
Proportion of iterations to include in the first window. |
p.last |
Proportion of iterations to include in the last window. |
Brian J. Smiht
boa.geweke
, boa.plot
,
boa.plot.geweke
Iteratively calls boa.handw() to display the Heidelberger and Welch convergence diagnostics for the parameters in each of the MCMC sequences in the working session list of sequences.
boa.print.handw(error = boa.par("handw.error"), alpha = boa.par("alpha"))
boa.print.handw(error = boa.par("handw.error"), alpha = boa.par("alpha"))
error |
Accuracy of the posterior estimates for the monitored parameters. |
alpha |
Alpha level for the confidence in the sample mean of the retained iterations. |
Brian J. Smith
Iteratively calls boa.hpd() to display the highest probability density (HPD) intervals for the parameters in each of the MCMC sequences in the working session list of sequences.
boa.print.hpd(alpha = boa.par("alpha"))
boa.print.hpd(alpha = boa.par("alpha"))
alpha |
Specifies the 100*(1-alpha)% HPD intervals to be computed. |
Brian J. Smith
Iteratively calls boa.chain.info() to display information from the MCMC sequences in the specified session list of sequences.
boa.print.info(which = "work")
boa.print.info(which = "work")
which |
Character string specifying which session list of MCMC sequences for which to print information. The two choices are "work" (used in all analyses) or "data" (the template for "work"). |
The full list obtained from boa.chain.info() is returned, but not printed.
Brian J. Smith
Displays a description of and the current value for all global parameters.
boa.print.par(group)
boa.print.par(group)
group |
Character string specifying which parameter group to display. The groups are "Analysis", "Data", and "Plot". If omitted, information on all global parameters is displayed. |
The character matrix obtained from boa.pardesc() is returned, but not printed.
Brian J. Smith
Iteratively calls boa.randl() to display the Raftery and Lewis convergence diagnostics for the parameters in each of the MCMC sequences in the working session list of sequences.
boa.print.randl(q = boa.par("randl.q"), error = boa.par("randl.error"), prob = 1 - boa.par("alpha"), delta = boa.par("randl.delta"))
boa.print.randl(q = boa.par("randl.q"), error = boa.par("randl.error"), prob = 1 - boa.par("alpha"), delta = boa.par("randl.delta"))
q |
Quantile to be estimated. |
error |
Desired amount of error in estimating the specified quantile 'q'. |
prob |
Probability of attaining the desired degree of 'error'. |
delta |
Delta value used in computing the convergence diagnostic. |
Brian J. Smith
Iteratively calls boa.stats() to display summary statistics for the parameters in each of the MCMC sequences in the working session list of sequences.
boa.print.stats(probs = boa.par("quantiles"), batch.size = boa.par("batch.size"))
boa.print.stats(probs = boa.par("quantiles"), batch.size = boa.par("batch.size"))
probs |
Vector of probabilities at which to compute the quantiles. Values must be between 0 and 1. |
batch.size |
Number of iterations to include in each batch when computing batch means and lag-1 batch autocorrelation function. |
Brian J. Smith
boa.quit() is called to end a BOA session. It removes the objects used to store the session lists of MCMC sequences and the global parameters. Failure to do this may result in lost or lingering data.
boa.quit()
boa.quit()
Brian J. Smith
Computes the Raftery and Lewis convergence diagnostics for the parameters in an MCMC sequence.
boa.randl(link, q, error, prob, delta)
boa.randl(link, q, error, prob, delta)
link |
Matrix whose columns and rows contain the monitored parameters
and the MCMC iterations, respectively. The iteration numbers and parameter
names must be assigned to |
q |
Quantile to be estimated. |
error |
Desired amount of error in estimating the specified quantile 'q'. |
prob |
Probability of attaining the desired degree of error - 'error'. |
delta |
Delta value used in computing the convergence diagnostics. |
A matrix whose columns and rows are the Raftery and Lewis convergence diagnostics (i.e. thin, burn-in, total, lower bound, and dependence factor) and the monitored parameters, respectively.
Brian J. Smith, Nicky Best, Kate Cowles
Raftery, A. L. and Lewis, S. (1992a). Comment: One long run with diagnostics: Implementation strategies for Markov chain Monte Carlo. Statistical Science, 7, 493-7.
Raftery, A. L. and Lewis, S. (1992b). How many iterations in the Gibbs sampler? In Bayesian Statistics 4, (ed. J. M. Bernardo, J. O. Berger, A. P. Dawid, and A. F. M. Smith), pp. 763-74. Oxford University Press.
Save the current state of the session lists of MCMC sequences and the global parameters to a database object.
boa.save(name, envir = globalenv(), replace = FALSE)
boa.save(name, envir = globalenv(), replace = FALSE)
name |
Character string giving the name of the object to which the current session should be saved. |
envir |
The 'environment' to which the object should be saved. For more information, consult the help documentation in R on the assign() function. |
replace |
Logical value indicating whether object |
A logical value indicating that the session was successfully saved to the specified object.
Brian J. Smith
Computes summary statistics for the parameters in an MCMC sequence.
boa.stats(link, probs, batch.size)
boa.stats(link, probs, batch.size)
link |
Matrix whose columns and rows contain the monitored parameters
and the MCMC iterations, respectively. The iteration numbers and parameter
names must be assigned to |
probs |
Vector of probabilities at which to compute the quantiles. Values must be between 0 and 1. |
batch.size |
Number of iterations to include in each batch when computing batch means and lag-1 batch autocorrelations. |
A matrix whose columns and rows contain the summary statistics (i.e. sample mean, standard deviation, naive standard error, MC error, batch standard error, lag-1 batch autocorrelation, specified quantiles, minimum and maximum iteration numbers, and total iterations in the sample) and the monitored parameters, respectively.
Brian J. Smith
The Line example involves a linear regression analysis of the data points (1,1), (2,3), (3,3), (4,3), and (5,5). The proposed Bayesian model is
with the following priors:
Two parallel chains from the MCMC sampler were generated and the output saved in the S data frames line1 and line2.
data(line)
data(line)
The data frames line1 and line2 each containing 200 observations.
Spiegelhalter, D., Thomas, A. and Best, N., (2000). WinBugs Version 1.4 User Manual.