Skip to contents

posterior_samples(), nsamples() and parnames() are brms spellings that brms itself deprecated and still answers. Each warns and then does what brms's does, so a ported script runs.

  • posterior_samples(x) is as.data.frame(x); pars is a regular expression unless fixed = TRUE, as in brms. The columns pars selects come in brms's order, which lists every population-level intercept first (b_Intercept, b_sigma_Intercept, then b_x); with no pars the columns are those of variables(), in its order. A pars that matches nothing returns NULL, as in brms.

  • nsamples(x) is ndraws(). nsamples(x, incl_warmup = TRUE) counts the iterations the sampler saved, warmup included, from the stanfit that frm_sample() keeps, as brms counts them.

  • parnames(x) is variables(); the generic is frmtmb's (frmtmb::parnames()), which answers it on a fit too.

Use as_draws(x) for a posterior draws object, as.data.frame(x), ndraws() and variables() in new code.

Usage

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

# S3 method for class 'frmtmb_draws'
posterior_samples(
  x,
  pars = NA,
  fixed = FALSE,
  add_chain = FALSE,
  subset = NULL,
  as.matrix = FALSE,
  as.array = FALSE,
  ...
)

nsamples(object, ...)

# S3 method for class 'frmtmb_draws'
nsamples(object, subset = NULL, incl_warmup = FALSE, ...)

# S3 method for class 'frmtmb_draws'
parnames(x, ...)

Arguments

x, object

A frmtmb_draws.

pars

Variable names. A regular expression unless fixed = TRUE; NA (the default) takes all of them.

...

Refused: an argument the method does not have is an error naming it.

fixed

If TRUE, pars names variables exactly.

add_chain

If TRUE, add the chain and iter columns brms adds.

subset

Draw indices to keep.

as.matrix, as.array

Return a matrix or a draws-by-chains-by-variables array instead of a data frame.

incl_warmup

If TRUE, count the iterations the sampler saved, warmup included, as brms does. The draws themselves hold the post-warmup iterations only; the count is read from the stanfit's record, and draws with no stanfit behind them refuse it.

Value

A data frame (or matrix, or array) of draws for posterior_samples(), one integer for nsamples(), and a character vector for parnames().