posterior icon indicating copy to clipboard operation
posterior copied to clipboard

Applying a function to each chain

Open n-kall opened this issue 1 year ago • 1 comments

Are there simple ways (can be internal functions) to apply a function to each chain of a draws or rvar object?

For a draws object, I can do:

example_draws() |>
  extract_variable_matrix("mu") |>
  apply(MARGIN = 2, FUN = ess_bulk)

But the equivalent for an rvar is not immediately clear to me.

This is related to the automatic thinning via ess, which uses this method but if rvars become the default for summarise draws (#184 ), will need to be updated.

n-kall avatar Mar 11 '24 14:03 n-kall

I would do draws_of(x, with_chains = TRUE) then use apply()

It's a good question if we should export something - my thinking so far has been to keep that stuff internal unless/until a good internal API for it solidifies from repeated experience, then think about exporting.

mjskay avatar Mar 11 '24 14:03 mjskay