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)isas.data.frame(x);parsis a regular expression unlessfixed = TRUE, as in brms. The columnsparsselects come in brms's order, which lists every population-level intercept first (b_Intercept,b_sigma_Intercept, thenb_x); with noparsthe columns are those ofvariables(), in its order. Aparsthat matches nothing returnsNULL, as in brms.nsamples(x)isndraws().nsamples(x, incl_warmup = TRUE)counts the iterations the sampler saved, warmup included, from the stanfit thatfrm_sample()keeps, as brms counts them.parnames(x)isvariables(); 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,parsnames variables exactly.- add_chain
If
TRUE, add thechainanditercolumns 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().