Skip to contents

Assembles a fitted model's posterior draws into an [iteration, chain, parameter] array – the layout expected by bayesplot and analogous to posterior::as_draws_array(). Multiple chains are recognised from a 3D draws array, a $chain_id row map, or an $n_chains count over chain-major rows; a single pooled chain yields a one-chain array.

Usage

tulpa_draws_array(fit)

Arguments

fit

A tulpa_fit (or subclass) carrying posterior $draws.

Value

A numeric array with dimensions [n_iter, n_chain, n_param] and the parameter names on the third dimension, or NULL if the fit carries no draws. Chains of unequal length are truncated to the shortest.

Details

As with posterior_sample(), a fit that carries no draws returns NULL with a message naming its backend and the representation it carries instead.

Examples

# \donttest{
set.seed(1)
d <- data.frame(x = rnorm(60))
d$y <- rpois(60, exp(0.5 + 0.3 * d$x))
fit <- tulpa(y ~ x, data = d, family = "poisson", mode = "hmc",
             control = list(n_iter = 400L, warmup = 200L, n_chains = 2L,
                            seed = 1L))
dim(tulpa_draws_array(fit))   # [iteration, chain, parameter]
# }