post_subset: Extract samples from specific nodes

Description Usage Arguments Value See Also Examples

View source: R/post_subset.R

Description

Subsets a smaller portion from a mcmc.list object corresponding only to the node(s) requested.

Usage

1
2
3
4
5
6
7
8
post_subset(
  post,
  params,
  matrix = FALSE,
  iters = FALSE,
  chains = FALSE,
  auto_escape = TRUE
)

Arguments

post

A mcmc.list object.

params

A vector of regular expressions specifying the nodes to match for subsetting. Accepts multi-element vectors to match more than one node at a time. See match_params() and vignette("pattern-matching") for more details.

matrix

Return samples in matrix rather than mcmc.list format?

iters

Retain the iteration number of each sample if matrix = TRUE? Not used otherwise.

chains

Retain the chain number of each sample if matrix = TRUE? Not used otherwise.

auto_escape

Automatically escape "[" and "]" characters for pattern matching? See match_params() for details.

Value

A mcmc.list or matrix object, depending on the value of the matrix argument. Object contains all nodes that match the params argument; an error will be returned if no matches are found.

See Also

match_params()

Examples

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

# create mcmc.list with all nodes that contain "B0"
x1 = post_subset(cjs, "B0")

# create mcmc.list with all nodes that contain "b" or "B"
x2 = post_subset(cjs, c("b", "B"))

# perform the subset and return a matrix as output, while retaining the chain ID
x3 = post_subset(cjs, "B0", matrix = TRUE, chain = TRUE)

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