tidy: Convert MCMC Sample Chains produced by 'runjags' to a tibble

Description Usage Arguments Value Usage notes Examples

Description

If the class of obj is runjags, the mcmc field is extracted and processed. If runjags.list or mcmc.list, tidy calls itself recursively on each element of obj, row_bind()s the results together and returns the resulting tibble. If mcmc, obj is processed as described in Usage notes below.

Usage

1
2
3
4
5
6
7
tidy(
  obj,
  chain = 1,
  augment = NULL,
  indexedPattern = "([:alnum:\\.]*)\\[(\\d*)\\]",
  ...
)

Arguments

obj

the object to be converted. See Usage notes below.

chain

the chain id

augment

If not NULL, the function which augments the converted obj. The functions first argument should be the tidied version of obj. Other arguments can be defined in .... with columns that are relevant to future processing. See Usage notes below.

indexedPattern

the regular expression used to identify indexed model parameters. Ensure that the pattern includes groups to return the "array" name and the index. The default value isn't perfect - it allows, for example, _3a to be a valid variable name - but it sould be good enough for most purposes.

...

Arguments passwed to augment.

Value

the corresponding tibble. See Usage notes below.

Usage notes

Typically, the CRM model parameters are of little intrest in their own right. The probabiities derived from them are more relevant. If the JAGS code derives these probabilities, they will be returned in the tibble as described below. If not, the augment argument provides a hook to allow them to be derived. augment is called immediately before the transformed obj is returned, so it must process obj in its transformed state. The transformed object is in normal form, which means that usually it must be spread() or pivoted _wider so that all model parameters are available in a single row. This is slightly awkward, but takes little time. See the vignette for an example.

Assuming that augment is NULL, the tibble returned by this function contains the following columns: Chain: an integer containing the index of the corresponding mcmc object in the input mcmc.list. If the input was an mcmc object, Chain is 1 for all rows. Sample: the sample number, from the inputmcmc object. Parameter: the name of the column in the input mcmc object to which value relates. If the JAGS model parameter is indexed (for example, alpha[1]), Parameter contains the array name (here, alpha) and Index contains the array index (here, 1). Index: if the corresponding Parameter is indexed, the value of the index. Otherwise, NA. Value: The value of this Parameter drawn in this Sample Thin: The value of the thinning parameter of the MCMC process used to generate the samples of this Chain.

If augment is not NULL, the return value depends on the actions of augment.

Examples

1
2

PuzzledFace/crmReporter documentation built on June 21, 2020, 12:52 a.m.