Skip to contents

Convert the parameters in a monty_samples object into a long-format tibble with one row per parameter, sample and chain. Array parameters (beta[1], beta[2]) are split into a parameter name and index columns, and parameters from a grouped packer (beta<a>) into a parameter name and a group column.

Usage

tidy_pars(samples, vars = NULL, dims = NULL, labels = NULL)

Arguments

samples

A monty_samples object, from monty::monty_sample() or run_parameter_sets().

vars

Optional character vector of parameters to keep.

dims

Optional names for the dimensions of array variables. Either an unnamed character vector applied by position to every array variable (c("age", "vax")), or a named list giving the dimension names of each variable (list(S = c("age", "vax"), R = "age")). Dimensions that are not named produce columns index1, index2, and so on.

labels

Optional named list of labels for dimensions, for example list(age = c("child", "adult")). Labelled dimensions become factors. Use the name group to label parameter groups.

Value

A tibble with columns chain, iteration, sample, parameter (a factor, with levels in the order of the samples), index columns for array parameters, group for grouped parameters, and value.

Details

For a wide format with one column per parameter, use posterior::as_draws_df(), which monty supports directly. Its .chain, .iteration and .draw columns hold the same values as chain, iteration and sample here.