Create transformed parameters from original parameters in MCMC output
applyConversions(samples, conversions)An object of the same type as samples after application
of conversions.
One of: an MCMCresult object; a named
list of MCMCresult objects (such as returned by
compareMCMCs); a matrix of MCMC samples (such as
the samples element of an MCMCresult object); or a named
list of such matrices. In the first two cases, conversions will
be done in place (as a "side effect" modifying the arguments)
because MCMCresult objects are R6 objects and are thus
passed by reference.
One of: a list of conversion specifications (see
below); a named list of conversion specifications, with names
matching those of a list provided for samples.
A conversion specification is a named list. For each element:
its name will be the name of a new column appended to a samples matrix.
its value should be a character string that can be parsed as code
to calculate elements of the new column. It can use existing
column names in samples. Calculations will be done row-wise.
Column names are often something like "beta[2]". To have this
used as a name, enclose it in backticks, e.g. "`beta[2]`".
For example, an entry could be log_beta2 = "log(`beta\[2\]`)".
A list value of NULL will remove the named column.
The conversion specification list will be processed in order. This allows creating new columns and removing old ones in a sensible order.
If both conversions and samples are named lists, they will be
matched: the conversions element (itself a list of conversion
specifications) used on a samples element will have the same
name. If there is no conversions element for a given samples
element, that samples element will be included in the returned
list without any conversions.