Learn R Programming

posterior (version 1.6.0)

extract_variable_array: Extract array of a single (possibly indexed) variable

Description

Extract an array of draws of a single variable, including any dimensions of variables with indices.

Usage

extract_variable_array(x, variable, ...)

# S3 method for default extract_variable_array(x, variable, ...)

# S3 method for draws extract_variable_array(x, variable, ...)

Value

An array with dimension niterations(x) x nchains(x) x any remaining dimensions determined by the indices of the variable x.

Arguments

x

(draws) A draws object or another R object for which the method is defined.

variable

(string) The name of the variable to extract. To extract all dimensions from variables with indices (e.g. "x[1]"), provide the base variable name (e.g. "x").

...

Arguments passed to individual methods (if applicable).

See Also

Other variable extraction methods: extract_variable(), extract_variable_matrix()

Examples

Run this code
x <- example_draws(example = "multi_normal")

mu <- extract_variable_array(x, variable = "mu")
str(mu)

mu1 <- extract_variable_array(x, variable = "mu[1]")
str(mu1)

Sigma <- extract_variable_array(x, variable = "Sigma")
str(Sigma)

Run the code above in your browser using DataLab