@helske I’d love to hear if tidybayes helps with your time series analyses. I think `tidybayes::spread_samples`

might help; it can generate a tidy data frame based on parameters with an arbitrary number of indices. For example, `spread_samples(m, x[i,j,k])`

will give you a data frame with columns `.chain`

, `.iteration`

, `x`

, `i`

, `j`

, and `k`

, where the value of `x`

on a given row is the value of the parameter `x[i,j,k]`

on the given `.chain`

and `.iteration`

.

This also works on multiple variables with shared indices, and indices are not required to be of the same number for each variable. E.g., `spread_samples(m, x[i,j], z[i])`

will give a data frame with columns `.chain`

, `.iteration`

, `x`

, `i`

, `j`

, and `z`

, where the value of `x`

on a given row is the value of the parameter `x[i,j]`

on the given `.chain`

and `.iteration`

, and `z`

is the value of `z[i]`

on the given `.chain`

and `.iteration`

(so values of z will be repeated across rows with the same `i`

, `.chain`

, and `.iteration`

but different `j`

).

@jonah I love the idea of being able to pass tidy data back into bayesplot! Does bayesplot mostly take a matrix of samples? If so, the easiest approach might be for me to make a function to invert the `spread_samples`

and `gather_samples`

functions in tidybayes to turn tidy data frames back into matrices (or data frames with `x[i]`

-ish names). I could imagine a nice workflow like:

```
m %>%
spread_samples(...) %>%
#some transformations of tidy samples %>%
unspread_samples(...) %>%
bayesplot::some_function(...)
```