Re: Bayesian 95% Credible interval

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Bayesian 95% Credible interval

brunero liseo
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 <[hidden email]>:

> 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]]
>
> ______________________________________________
> [hidden email] 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
=========================================================

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Bayesian 95% Credible interval

glsnow
The "emp.hpd" function in the TeachingDemos package will do this
(assumes a single interval result, either unimodal or multimodes but
the valleys between don't drop far enough to split the interval).  I
am sure there are similar functions in other packages as well.

On Fri, Apr 6, 2012 at 12:39 PM, Gyanendra Pokharel
<[hidden email]> wrote:

> 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]]
>
> ______________________________________________
> [hidden email] 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.



--
Gregory (Greg) L. Snow Ph.D.
[hidden email]

______________________________________________
[hidden email] 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.