> library(LaplacesDemon)
> set.seed(1)
> theta <- rlnorm(10000,1,0.5)
> p.interval(theta, HPD=TRUE, MM=FALSE, plot=TRUE)
要是想看详细的教程的话,这里有一个,特别详细:
http://www.bayesian-inference.com/credible
不过话说,很多包都可以做HPDI的...比如这个——
http://svitsrv25.epfl.ch/R-doc/library/coda/html/HPDinterval.html