Skip to contents

Generic function to convert an object to a posterior::rvar representation. This is typically used to convert Markov Chain Monte Carlo (MCMC) output into a more flexible and vectorized format.

Usage

as_rvar(x, ...)

# S3 method for class 'rjuliabugs'
as_rvar(x, ...)

# S3 method for class 'array'
as_rvar(x, n_mcmc = NULL, ...)

Arguments

x

An object to convert (e.g., a rjuliabugs object or a 3D numeric array).

...

Further arguments passed to specific methods.

n_mcmc

(For arrays only) Number of Markov Chain Monte Carlo (MCMC) chains. Required if x is an array.

Value

An object of class rvar, or an updated rjuliabugs object with params converted to rvar.

An object of class "rjuliabugs" (a named list) with the following elements:

params

Posterior samples, converted to the requested format: rvar for as_rvar, mcmc/mcmc.list for as_mcmc, draws_array for as_draws.

name

The name of the Julia sampler object.

sampler

The sampler object returned by AbstractMCMC.sample in Julia.

n_threads

Number of Julia threads detected.

mcmc

A list of MCMC configuration parameters, now including posterior_type indicating the format of params.

control

Control options passed to and used by the sampler.

An object of class rvar (from the posterior package). The input 3D array (iterations × chains × parameters) is converted into a posterior rvar object, where each parameter is represented as a random variable across iterations and chains.