pull_post: Subset from posterior data.frame

View source: R/jagshelper1.R

pull_postR Documentation

Subset from posterior data.frame

Description

Extracts a subset vector or data.frame from a data.frame consisting of more columns, such that column names match a name given in the ⁠p=⁠ argument. This may be useful in creating smaller objects consisting of MCMC samples.

Usage

pull_post(x, p = NULL, exact = FALSE)

Arguments

x

Posterior data.frame

p

String to begin posterior names. If NULL is used, all parameters will be returned.

exact

Whether name must be an exact match (TRUE) or with initial sub-string matching only supplied characters (FALSE). Defaults to FALSE.

Value

A data.frame with a column associated with each (subsetted) parameter and a row associated with each MCMC iteration.

Author(s)

Matt Tyers

See Also

jags_df

Examples

out_df <- jags_df(asdf_jags_out)

b <- pull_post(out_df, p="b")
str(b)
a <- pull_post(out_df, p=c("a","sig_a"))
str(a)
sigs <- pull_post(out_df, p="sig")
str(sigs)
justsig <- pull_post(out_df, p="sig", exact=TRUE)
str(justsig)

jagshelper documentation built on Oct. 22, 2024, 1:06 a.m.