array_format: Convert a vector to the array structure used in model

Description Usage Arguments Details Value Note Examples

View source: R/array_format.R

Description

Use element names to place vector elements in the appropriate location of an array.

Usage

1

Arguments

v

A vector with names indicating the index location of each element in a new array. See the details (particularly the example) for more about what this means.

Details

Suppose you have an AxB matrix in your model, and you would like to create an object that stores the posterior means in the same AxB matrix as found in the model. For an AxB matrix, this is not too difficult to do "by-hand". However, if there are also dimensions C, D, and E, missing values, etc. it becomes more difficult.

Value

An array with elements of v placed in the appropriate location based on their index names.

Note

Up to 10 dimensions are currently supported. Please submit an issue should you find that you need more dimensions.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# load example mcmc.list
data(cjs)

# find an array node from your model
match_params(cjs, "SIG")

# extract the posterior mean of it
SIG_mean = post_summ(cjs, "SIG")["mean",]

# note that it has element names
SIG_mean

# create a matrix with elements in the proper place
array_format(SIG_mean)

postpack documentation built on June 3, 2021, 1:07 a.m.