Skip to contents

Extracts posterior samples for specified parameters from a fitted `rjuliabugs` object. Output can be returned in several formats depending on downstream analysis requirements.

Usage

extract(rjuliabugs, pars = NULL, type = "array", include = TRUE)

Arguments

rjuliabugs

An S3 object of class `rjuliabugs`, typically returned by a call to the `juliaBUGS()` function. Must contain a `params` 3D array and `mcmc` list with fields `params_to_save` and `n_chain`.

pars

Character vector of parameter names to extract. If `NULL`, defaults to `rjuliabugs$mcmc$params_to_save`.

type

Character string indicating output type: one of `"array"` (default), `"rvar"`, `"mcmc"`, or `"draws"`.

include

Logical; if `TRUE`, extract only `pars`; if `FALSE`, exclude `pars`.

Value

The posterior samples in the specified format:

  • a 3D `array` [iterations × chains × parameters],

  • a `posterior::rvar` object,

  • a `coda::mcmc` or `coda::mcmc.list`,

  • or a `posterior::draws_array`/`draws_list`.