Using baysplot::ppc_dens_overlay() for hierarchical posterior predictions from CmdStan?

  • Can I use baysplot::ppc_dens_overlay() for hierarchical posterior predictions from CmdStan? (see an outline description of the hierarchical model here)
  • If yes, how to get the data right?

The posterior predictions generated from CmdStan should be an array of dim(S, J, N), where

  • S is the number of samples (2000 by default)
  • J is the number of entities (group) in my model
  • N is the number of calendar quarters

Q: I need to turn this ‘wide’ form into a ‘long’-form matrix of S rows and (JxN) columns (and also with a length-(JxN) vector as the group variable), right?

I have never tried baysplot, but if it would be helpful, you could do the same with python package arviz (there is a good manual on their website)

1 Like