I am seeing that in Pystan, an HDI function can be used to provide a 95% credible interval surrounding the posterior distribution. However, they say it will only work for unimodal distributions. If my model may have a multimodal distribution (up to 4 peaks), is there a way I can find the HDI in Pystan? Thanks!
Highest Density Interval (HDI) for Posterior Distribution Pystan
4.2k Views Asked by nik jacks At
1
There are 1 best solutions below
Related Questions in PYTHON
- How to store a date/time in sqlite (or something similar to a date)
- Instagrapi recently showing HTTPError and UnknownError
- How to Retrieve Data from an MySQL Database and Display it in a GUI?
- How to create a regular expression to partition a string that terminates in either ": 45" or ",", without the ": "
- Python Geopandas unable to convert latitude longitude to points
- Influence of Unused FFN on Model Accuracy in PyTorch
- Seeking Python Libraries for Removing Extraneous Characters and Spaces in Text
- Writes to child subprocess.Popen.stdin don't work from within process group?
- Conda has two different python binarys (python and python3) with the same version for a single environment. Why?
- Problem with add new attribute in table with BOTO3 on python
- Can't install packages in python conda environment
- Setting diagonal of a matrix to zero
- List of numbers converted to list of strings to iterate over it. But receiving TypeError messages
- Basic Python Question: Shortening If Statements
- Python and regex, can't understand why some words are left out of the match
Related Questions in BAYESIAN
- number of valid columns for ChoiceModelR
- How can be the `$ operator is invalid for atomic vectors` error solved?
- How optuna narrow the search scope step by step, by using the bayesian method
- how to compare the result from rstan with the result from survreg
- Adding a factor to a Bayesian Regression
- Bayesian Ridge Regression applied to binary classification. How to compare the closed-form solution with the MCMC solution?
- Solving question 8M9 from Bayesian Modeling and Computation in Python
- Random walk in rethinking::ulam
- YOLOv8: Optimising for map with confidence and iou in prediction
- "This initial value does not corresponding to a stochastic node in WINBUGS
- Translating WINBUGS model to JAGS model: possible directed cycle
- Show breakdates for R strucchange package
- PyMC and arviz problem when trying to get summary statistics
- How to do a Bayesian Repeated Measures ANOVA analysis with missing cells in R?
- How to fit sigmoidal curves and extract x at a specified value of y using Bayesian statistics?
Related Questions in STAN
- how to compare the result from rstan with the result from survreg
- Markdown RStan chunk not running
- Random walk in rethinking::ulam
- Estimate mean and SD of polygon area in Stan
- how can i modeled a STAN model like this?
- Rethinking: Zero-Inflated model with Random Effect?
- Stan dimensions mismatch
- Specifying intial values failed for brms with cmdstanr backend (but not rstan backend)
- How to specify an imputation model so that the resulting imputed variable approaches to a specific distribution, mean and standard deviation
- Dealing with missing data points for ODE model calibration using CmdStan (cmdstanr)
- Is there a way to output code chunk with stan formatting, reading file from R?
- How to increase size of output from multiple plots in R
- Stan: Exceptions returned: “wishart_lpdf: random variable is not symmetric” and “gamma_lpdf: Random variable is inf, but must be positive finite!”
- How can I run this parallel code in R/RStan?
- Doing Bayesian Meta-analysis using JAGS with nested random effects
Related Questions in PYSTAN
- I'm getting "ModuleNotFoundError: No module named 'Cython'" error when installing fbprophet or pystan via pip
- CompileError: command '/usr/bin/gcc' failed with exit code 1
- Stan dimensions mismatch
- pystan Related bug: http://bugs.python.org/issue1666807
- Using Dirichlet distribution in Stan
- AttributeError: 'Prophet' object has no attribute 'stan_backend' while running m=Prophet()
- (conda environment) distutils.errors.CompileError: command 'x86_64-conda-linux-gnu-cc' failed with exit status 1
- Segmentation fault in PyStan
- Migrating from PyStan2 to PyStan3
- How can we install fbprophet and pystan in conda prompt or in window prompt
- Pystan -- Library\\mingw-w64\\bin\\gcc.exe' failed with exit code 1
- Pystan 2.19.1.1- C++/MSVC compiler issues- cl.exe failed with exit status 2
- Extract and plot pystan3 prediction
- What do brackets mean after a type is specified when declaring variables in Stan?
- How to use functions of objects declared as data when declaring other objects in Stan/RStan?
Related Questions in CREDIBLE-INTERVAL
- reorder community order using multiSpeciesTP, siberdensityplot
- Analytic Highest Density Interval in Python (preferably for Beta distributions)
- How to find and plot different credible intervals?
- Calculate 95 % credible interval for multiple columns in data frame R
- Plotting both 50% quantile and credible interval from package 'mcp' output in R
- Extract credible intervals for robust correlations in R
- determine equal-tail credible interval
- Extracting posterior modes and credible intervals from glmmTMB output
- Gaussian Process Confidence vs Credible Intervals
- Extract posterior estimate and credible intervals for random effect for lme4 model in R
- Highest Density Interval (HDI) for Posterior Distribution Pystan
- Coverage probability estimation for Bayesian Credible interval (Normal Distribution)
- How to calculate a 95 credible region for a 2D joint distribution?
- Error propagation in a Bayesian analysis of a Markov chain
- Reduce credible intervals in Causal Impact model
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
I wouldn't consider this a Stan/PyStan-specific issue. The Highest Density Interval is by definition a single interval and therefore inappropriate for characterizing multimodal distributions. There is a nice work by Rob Hyndman, Computing and Graphing Highest Density Regions, that extends the concept to multimodal distributions, and this has been implemented in R under the hdrcde package.
As for Python, there's a discussion of this on the PyMC Discourse site, where it is recommended to use a function (
hpd_grid) that Osvaldo Martin wrote for his "Bayesian Analysis with Python" book. The source for that function is in the hpd.py file, and for a 95% region would be used likewhere
samplesare the posterior samples of one of your parameters, andintervalsare a list of tuples representing the regions of highest density.Example with Plot
Here's an example plot using some fake multimodal data.
Cautionary Note
It should be noted that multimodal posterior distributions on properly modeled parameters are typically rare, but do come up extremely frequently in non-converged MCMC sampling, especially when multiple chains are used (which is the best practice). If one expects multimodality a priori, then usually that leads to some form of mixture model which would eliminate the multimodality. If one doesn't expect multimodality, but the posteriors exhibit it anyway, then that's a red flag to be skeptical of the results.