MCMCresult {compareMCMCs} | R Documentation |
R6 class to hold MCMC samples, timing results, and metrics
R6 class to hold MCMC samples, timing results, and metrics
MCMC
Optional name for the MCMC method.
samples
Matrix of MCMC samples. Rows are for MCMC iterations. Columns are for parameters. Columns must be named.
times
A list of times including elements for setup
,
burnin
, postburnin
(sampling for recorded samples), and
sampling
(normally burnin
+ postburnin
). Each list
element should be a single numeric value.
metrics
A list of MCMC performance metrics such as
effective sample size (ESS), efficiency, mean, median, and
credible interval boundaries. metrics
' is organized as a list
with three elements: byMCMC
, byParameter
, and other
'
(currently unused).
byMCMC
is for metrics with one number for an entire
MCMC sample (as opposed to one number for each parameter).
byMCMC
is a data frame with one row and columns for MCMC name
each metric. These would be metrics where there is a single
byParameter
is for metrics with one number for each parameter in each
MCMC sample. byParameter
is a data.frame
with one row for each
MCMC-x-parameter combination and columns for MCMC method,
parameter name, and
each metric. There will only be one MCMC method name
(all entries in the
MCMC column will be the same).
The MCMC columns in byMCMC
and byParameter
are useful for combining
metrics
from a list of MCMCresult
objects,
such as done by combineMetrics
, and for retaining
MCMC method labels if these data.frames
are copied and used
outside of
an MCMCresult
object.
other
is simply an arbitrary list. This allows arbitrarily structured
metrics to be saved.
Elements of metrics
are normally populated by addMetrics
or
compareMCMCs
(which calls addMetrics
).
sessionInfo
Result of running sessionInfo()
prior to calling
an MCMC engine, if requested.
new()
Create a new MCMCresult
object.
MCMCresult$new(...)
...
Arbitrary initialization. If a matrix is passed, it
will be used to initialize samples
and the metrics
elements.
If a list with a matrix element named samples
is passed, this element
will be used as if the matrix itself was passed. Any other named
elements of a list that correspond to fields of an MCMCresult
object
will be initialized from them.
setSamples()
Populate the samples and initialize the metrics
MCMCresult$setSamples(samples)
samples
A data.frame
with MCMC output.
NULL
rename()
Change the MCMC method name from oldName to newName
MCMCresult$rename(newName, oldName)
newName
New name for MCMC method in metrics
oldName
Old name for MCMC method in metrics
This change the MCMC
field and the corresponding columns
of metrics$byParameter
and metrics$byMCMC
.
If oldName
is not the MCMC method name, this function does nothing.
NULL
initializeMetrics()
Initialize metrics if necessary
MCMCresult$initializeMetrics(silent = FALSE)
silent
logical
indicating whether to emit warnings
This function does nothing if metrics are already initialized.
It does not clear metrics. See clearMetrics
for information on
how metrics are initialized.
logical
indicating whether metrics
is well-formed or not.
clearMetrics()
Clear (reset) byParameter
and/or byMCMC
metrics
MCMCresult$clearMetrics(byParameter = TRUE, byMCMC = TRUE)
byParameter
logical
indicating whether to clear byParameter
metrics
byMCMC
logical
indicating whether to clear byMCMC
metrics
byParameter
metrics are initialized to a data.frame
with columns for
MCMC
(all the same entry, the MCMC
field) and Parameter
(taken from column
names of the samples
).
byMCMC
metrics are initialized to a data.frame
with a column for MCMC
.
addMetricResult()
Add one set of metric results
MCMCresult$addMetricResult(metricResult)
metricResult
A list with possible elements byParameter
,
byMCMC
, and
other
. These are typically returned from a metric function
called via
addMetric
. Each is combined with previous metrics already in the
corresponding
elements of metrics
.
clone()
The objects of this class are cloneable with this method.
MCMCresult$clone(deep = FALSE)
deep
Whether to make a deep clone.
renameMCMC
to change the name of an MCMC
method throughout the structure of a list of MCMCresult
objects.