PyStan diagnostics

It seems that writing to a diagnostics file hasn’t quite been implemented for PyStan yet, so is there another way to get diagnostics about the sampler?

Raw values you can get with

fit.get_sampler_params()

Next release has pystan.diagnostics. It contains functions that will hint you if you have a problem with your model.

Is there a guide on how to interpret the statistics it returns? My divergence array is full of ones for instance, is this a count or a boolean? (I’m guessing it is bad either way).

This doesn’t use the new build in functions, but explains some of the interpretation of the diagnostics, https://betanalpha.github.io/assets/case_studies/pystan_workflow.html. More on divergences with corresponding R code (which is sufficiently easy to translate to Python) can be found at https://betanalpha.github.io/assets/case_studies/divergences_and_bias.html.

Is there any plan to integrate the stan_utility into PyStan?

It’s already merged.

See https://github.com/stan-dev/pystan/pull/433

To get it before 2.18 is released install from git

pip install git+https://github.com/stan-dev/pystan

What @ahartikainen. Note that I update the stan_utility functionality from time to time so the version in my case studies will always be the most up to date.

Yeah, sorry, I didn’t check if it was updated.

Oh, no worries. There hasn’t been any substantial change yet, but there will be at some point. I was just making the point that the diagnostics are still a matter of research and hence evolving, so while we’ll strive to keep the versions in the interfaces up to date the most advanced versions that I recommend will be in the case studies.

2 Likes