Format formula-derived parameter names and extract exact indexed JAGS parameter columns.

format_parameter_names(
  parameters,
  formula_parameters = NULL,
  formula_random = NULL,
  formula_prefix = TRUE,
  formula_scale = NULL
)

JAGS_parameter_names(parameters, formula_parameter = NULL)

JAGS_regex_escape(x)

JAGS_indexed_parameter_columns(columns, parameter)

JAGS_indexed_parameter_matrix(samples, parameter, drop_missing = TRUE)

JAGS_indexed_parameter_vector(row, parameter)

Arguments

parameters

a vector of parameter names

formula_parameters

a vector of formula parameter prefix names

formula_random

a vector of random effects grouping factors

formula_prefix

whether the formula_parameters names should be kept. Defaults to TRUE.

formula_scale

optional nested list containing scaling info. When provided, intercepts from parameters with log_intercept = TRUE attribute will be renamed to exp(intercept).

formula_parameter

a formula parameter prefix name

x

character vector to escape for regular-expression matching.

columns

character vector of column names.

parameter

exact unindexed JAGS parameter name.

samples

matrix, data frame, mcmc, or mcmc.list object.

drop_missing

whether missing indexed columns should return NULL. If FALSE, a zero-column matrix with the input row count is returned.

row

named row vector, list, or one-row data frame.

Value

format_parameter_names(), JAGS_parameter_names(), and JAGS_regex_escape() return character vectors. JAGS_indexed_parameter_columns() returns a logical vector. JAGS_indexed_parameter_matrix() returns a matrix of exact indexed parameter columns sorted by numeric index, or NULL when none are present and drop_missing = TRUE. JAGS_indexed_parameter_vector() returns indexed row values sorted by numeric index.

Examples

format_parameter_names(c("mu_x_cont", "mu_x_fac3t", "mu_x_fac3t__xXx__x_cont"),
                       formula_parameters = "mu")
#> [1] "(mu) x_cont"         "(mu) x_fac3t"        "(mu) x_fac3t:x_cont"