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

View source: R/array_format.R

array_formatR Documentation

Convert a vector to the array structure used in model

Description

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

Usage

array_format(v)

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

# 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 Dec. 28, 2022, 1:23 a.m.