compare_draws()

Extract and stack draws from multiple groups (e.g., posterior and prior).

Usage

compare_draws(
    dt, *var_specs, groups=["posterior", "prior"], group_name="source"
)

Calls parameter_draws() for each group, adds a column identifying the source group, and concatenates the results into a single DataFrame for easy comparison.

Parameters

dt: xr.DataTree

ArviZ DataTree object.

*var_specs: str

Variable specifications (as for parameter_draws()).

groups: list[str] = ["posterior", "prior"]

Which groups to extract and stack. Default [“posterior”, “prior”].

group_name: str = "source"
Name of the column identifying the source group. Default “source”.

Returns

pl.DataFrame
Stacked draws with an additional column (group_name) indicating source.

Example

Extract posterior and prior for side-by-side forest plots

compare_df = compare_draws(dt, “beta[groups]”, groups=[“posterior”, “prior”]) # -> columns: chain, draw, groups, beta, source # -> source in {“posterior”, “prior”}