Learn R Programming

tidybayes (version 0.12.1.9000)

as_sample_tibble: Get samples from a model as a tibble

Description

Extract samples from an MCMC fit into a wide-format data frame with a .chain and .iteration column, as well as all terms as columns. Generally speaking not as useful as spread_samples or gather_samples and is mainly used interally (see `Details`)

Usage

as_sample_tibble(model)

as_sample_data_frame(model)

# S3 method for default as_sample_tibble(model)

# S3 method for mcmc.list as_sample_tibble(model)

# S3 method for stanfit as_sample_tibble(model)

# S3 method for stanreg as_sample_tibble(model)

# S3 method for runjags as_sample_tibble(model)

# S3 method for jagsUI as_sample_tibble(model)

# S3 method for brmsfit as_sample_tibble(model)

# S3 method for matrix as_sample_tibble(model)

# S3 method for MCMCglmm as_sample_tibble(model)

Arguments

model

A supported Bayesian model fit / MCMC object. See tidybayes-models for a list of supported models.

Value

A data frame (actually, a tibble) with a .chain column, .iteration column, and one column for every parameter in model.

Details

You will not typically call this directly; instead use spread_samples or gather_samples. However, to provide support for new models in those functions, you must provide an implementation of this function, or an implementaiton of as.mcmc.list (as_sample_tibble should work on any model with an implementation of as.mcmc.list)

as_sample_data_frame is an alias.

See Also

spread_samples or gather_samples, which use this function internally and provides a friendly interface for extracting tidy data frames from model fits.

Examples

Run this code
# NOT RUN {
library(magrittr)

data(line, package = "coda")

line %>%
  as_sample_tibble()

# }

Run the code above in your browser using DataLab