extract_variable_array {posterior}R Documentation

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, ...)

## Default S3 method:
extract_variable_array(x, variable, ...)

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

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).

Value

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

See Also

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

Examples

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)


[Package posterior version 1.6.0 Index]