Learn R Programming

postpack (version 0.5.4)

array_format: 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)

Value

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

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.

Examples

Run this code
# 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)

Run the code above in your browser using DataLab