Learn R Programming

brms (version 0.6.0)

posterior_samples: Extract posterior samples

Description

Extract posterior samples of specified parameters

Usage

posterior_samples(x, pars = NA, parameters = NA, exact_match = FALSE,
  add_chains = FALSE, as.matrix = FALSE, ...)

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_chains
A flag indicating if the returned data.frame should contain information on the chains
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_i <- brm(rating ~ treat + period + carry + (1|subject), 
             data = inhaler, family = "cumulative")

#extract posterior samples of fixed effects 
samples1 <- posterior_samples(fit_i, "b_")
head(samples1)

#extract posterior samples of standard deviations of random effects
samples2 <- posterior_samples(fit_i, "sd_")
head(samples2)

Run the code above in your browser using DataLab