8
$\begingroup$

I would like to plot 2D confidence regions (at 1-sigma, 2-sigma) for a model that I've fit to data. I've used PyMC to generate 50k MCMC posterior samples for my model with 6 parameters.

I know the process to create confidence regions is something similar to: 1.) create a histogram of the samples in the 2D space 2.) identify iso-density contours 3.) from a selected start point (eg, the mean) integrate outwards perpendicular to iso-density contours until the desired fraction of sample points are contained in the region.

Is there a convenient function in the numpy/scipy/pymc/pylab/etc world that will create the 2D confidence region plot? Alternatively, where can I find a coded algorithm, or stand-alone tool, that will compute the contours for later plotting?

$\endgroup$
3
$\begingroup$

I once did something like this with pymc, matplotlib, and scipy that you could adapt, the relevant code is in this gist, and the resulting plot looks like this: enter image description here

$\endgroup$
  • $\begingroup$ Some type of description of the process would be very helpful.... $\endgroup$ – DilithiumMatrix Jun 30 '15 at 20:34
  • $\begingroup$ The link provided has enough explanation as well as code. $\endgroup$ – yoavram Dec 3 '15 at 17:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.