cmdstanpy icon indicating copy to clipboard operation
cmdstanpy copied to clipboard

notebook - CmdStanPy to Arviz

Open mitzimorris opened this issue 3 years ago • 4 comments

Summary:

We need a case study with examples on how the CmdStanPy - Arviz interface works.

Description:

This should be another example in this list:

  • https://mc-stan.org/cmdstanpy/users-guide/examples.html

From README.md

CmdStanPy produces a MCMC sample (or point estimate) from the posterior; other packages do analysis and visualization.

We need to show how easy this is - highlight use of stan_variables, etc.

Current Version:

mitzimorris avatar Oct 22 '21 20:10 mitzimorris

I have a notebook here: https://github.com/maxbiostat/StanConnect2021_Biostatistics/blob/main/talk_1/Coding%20the%20BYM2%20model%20for%20disconnected%20graphs%20in%20Stan.ipynb

but any of the Stan case studies would be fair game.

mitzimorris avatar Oct 22 '21 20:10 mitzimorris

I also have the first 5 chapters of McElreath’s Rethinking translated to CmdStanPy+Arviz as options, I can upload them somewhere

WardBrian avatar Oct 22 '21 21:10 WardBrian

Should be "produces an MCMC sample" (for those following along at home, the choice of "an" vs. "a" in English s pronunciation based).

Does CmdStanPy also return samples from VI and from Laplace approximations derived from optimization? The only point estimates we expose are from optimization, but they exist under the hood for VI, too.

Plus, CmdStanPy can produce penalized maximum likelihood estimates, which aren't technically point estimates from Bayesian posteriors (we turn off the Jacobian, so they're not actually MAP estimates from the unconstrained Bayesian estimates, either).

You can see how I described the inference capabilities on the mc-stan.org home page.

bob-carpenter avatar Oct 22 '21 21:10 bob-carpenter

One of the Arviz devs (@OriolAbril) put together this notebook which does more or less exactly this: https://oriolabrilpla.cat/python/arviz/stan/xarray/xarray-einstats/2022/04/25/einstats-hmm-cmdstanpy.html

I suppose a question is if we need another version of this kind of thing which lives specifically inside the cmdstanpy documentation?

WardBrian avatar May 16 '22 18:05 WardBrian