posterior icon indicating copy to clipboard operation
posterior copied to clipboard

Representation as json

Open MansMeg opened this issue 6 years ago • 3 comments

Im impressed by the progress. Since Im finalizing the posteriordb beta, I realized that it would be good to formalize also how a posterior is represented as json. This would also enable cross-language representations.

Have you thought about this?

I currently represent draws as a named object of numeric arrays. Think a named list of a vector in R, with one vector per parameter.

MansMeg avatar Oct 30 '19 17:10 MansMeg

I have thought about this, but not sure if may ideas made sense. Bascially, one reason to have the draws_list class (i.e., a list of lists with one element per chain and a numeric vector per parameter per chain) was to represent draws coming from formats such a JSON.

paul-buerkner avatar Oct 30 '19 17:10 paul-buerkner

Have you thought about this?

Not much but seems like a good thing to think about

I currently represent draws as a named object of numeric arrays. Think a named list of a vector in R, with one vector per parameter.

Seems reasonable. If you read this into R (e.g. using jsonlite::fromJSON()) does it give you the structure that @paul-buerkner mentioned? If so then this would already work nicely with this package given that we have the draws_list format.

Also, are you keeping the markov chains separate or combining all chains?

jgabry avatar Oct 30 '19 21:10 jgabry

Hi! Me and @paul-buerkner spoke about this and we agree that this is working nicely with draws_list(). For the posteriorDB I need to tune a little anyway but otherwise just writing and reading a draws_list to json would probably work great. That would also be a good standard to transfer posteriors between languages, such as jsonstat. So when the formats are maturing we could formalize this as a JSON schema as well. https://json-stat.org/

MansMeg avatar Oct 31 '19 17:10 MansMeg