Learn R Programming

brms (version 0.9.1)

posterior_samples.brmsfit: Extract posterior samples

Description

Extract posterior samples of specified parameters

Usage

## S3 method for class 'brmsfit':
posterior_samples(x, pars = NA, parameters = NA,
  exact_match = FALSE, add_chain = FALSE, add_chains = FALSE,
  subset = NULL, as.matrix = FALSE, ...)

posterior_samples(x, pars = NA, ...)

Arguments

x
An R object typically of class brmsfit
pars
Names of parameters for which posterior samples should be returned, as given by a character vector or regular expressions. By default, all posterior samples of all parameters are extracted
parameters
A deprecated alias of pars
exact_match
Indicates whether parameter names should be matched exactly or treated as regular expression. Default is FALSE.
add_chain
A flag indicating if the returned data.frame should contain two additional columns. The chain column indicates the chain in which each sample was generated, the iter column indicates the iteration number within
add_chains
A deprecated alias of add_chain. Note that the chain column will be named chains instead.
subset
A numeric vector indicating the rows (i.e., posterior samples) to be returned. If NULL (the default), all posterior samples are returned.
as.matrix
Should the output be a matrix instead of a data.frame? Defaults to FALSE
...
additional arguments

Value

  • A data frame containing the posterior samples, with one column per parameter.

Details

Currently there are methods for brmsfit objects.

Examples

Run this code
fit <- brm(rating ~ treat + period + carry + (1|subject), 
           data = inhaler, family = "cumulative")

#extract posterior samples of fixed effects 
samples1 <- posterior_samples(fit, "^b")
head(samples1)

#extract posterior samples of standard deviations of random effects
samples2 <- posterior_samples(fit, "^sd")
head(samples2)

Run the code above in your browser using DataLab