rearray: Recover array structure for multidimensional nodes

Description Usage Arguments Value See Also Examples

View source: R/rearray.R

Description

Converts summaries of multidimensional nodes of rjags or mcmc.list objects to a list of arrays.

Usage

1
rearray(x, param, fields, regex = FALSE, ...)

Arguments

x

The rjags, rjags.parallel, or mcmc.list object for which array structure will be recovered.

param

Character vector of exact names of multidimensional parameters (if regex is FALSE, the default), or a regular expression pattern that will be compared to all available multidimensional parameters (if regex is TRUE). If left unspecified, arrays will be returned for all multidimensional parameters in x.

fields

A vector (character or integer) that indicates the summary fields that should be included as array slices. Valid fields are: 'mean', 'sd', 'Rhat', 'n.eff', and a range of quantiles. By default, these quantiles include '2.5%', '25%', '50%', '75%', and '97.5%', but if a vector of alternative quantiles is passed via probs (see examples), then those quantiles' names may be used. Note that 'Rhat' and 'n.eff' are only available if x is an rjags or rjags.parallel object. If left unspecified, all available fields are returned.

regex

Logical. If regex is TRUE, then param should be a single string giving a text pattern to be matched. Parameters with names matching the pattern will be returned (unless the match is inverted by passing invert=TRUE via ..., which results in all parameters that do not match the pattern being returned). Text pattern matching uses regular expressions (regex).

...

Additional arguments passed to jagsresults.

Value

A list of arrays (one per multidimensional model parameter specified in param) containing node summaries for the requested fields. Fields (e.g. 'mean', 'sd', 'Rhat', etc.) will be included as the final (right-most) dimension.

See Also

jagsresults

Examples

1
2
3
4
5
6
7
data(simgrowth)
a <- rearray(simgrowth)
str(a)
a2 <- rearray(simgrowth, param='lambda', fields=c('mean', '50%', 'n.eff'))
str(a2)
a3 <- rearray(simgrowth, param='log.r', probs=seq(0, 1, 0.1))
str(a3)

johnbaums/jagstools documentation built on May 19, 2019, 3:03 p.m.