tulpa_draws_array: Posterior draws as a 3D array

View source: R/convergence.R

tulpa_draws_arrayR Documentation

Posterior draws as a 3D array

Description

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⁠.

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.

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.

See Also

posterior_sample(), tulpa_posterior_draws(), diagnostics()

Examples


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]


tulpa documentation built on Oct. 19, 2026, 5:09 p.m.