This is a function I use when the posterior is unimodal I do not remember but I think I found it somewhere in the web
brunero hpd<-function(x,p){ #generate an hpd set of level p, based #on a sample x from the posterior dx<-density(x) md<-dx$x[dx$y==max(dx$y)] px<-dx$y/sum(dx$y) pxs<--sort(-px) ct<-min(pxs[cumsum(pxs)< p]) list(hpdr=range(dx$x[px>=ct]),mode=md) } 2012/4/6 Gyanendra Pokharel <gyanendra.pokha...@gmail.com>: > Hi all, > I have the data from the posterior distribution for some parameter. I want > to find the 95% credible interval. I think "t.test(data)" is only for the > confidence interval. I did not fine function for the Bayesian credible > interval. Could some one suggest me? > > Thanks > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- ========================================================= Brunero Liseo Dip. di metodi e modelli per il territorio, l'economia e la finanza Sapienza Università di Roma Tel. +39 06 49766973 Fax +39 06 4957606 http://geostasto.eco.uniroma1.it/utenti/liseo ========================================================= ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.