I am trying to calculate Bayesian Credible Intervals for a proportion (disease prevalence values to be more specific) and am having trouble using R to do this. I am working with ncredint() function but have not had success with it. Please help! Example: Positive samples = 3 Total sampled = 10 Prevalence = 0.3 pvec <- seq(1,10,by=1) npost = dbinom(pvec,10,prob=0.3, log=FALSE) ncredint(pvec, npost, tol=0.01, verbose=FALSE) But I don't get the right Bayesian CI. What am I doing wrong? Thanks! Tina -- View this message in context: http://r.789695.n4.nabble.com/Bayesian-Credible-Intervals-for-a-Proportion-tp3600976p3600976.html Sent from the R help mailing list archive at Nabble.com.
Bayesian Credible Intervals for a Proportion
3 messages · Greg Snow, tinazilla
It would help us to help you if you told us which package ncredint is in (it is not in any of the packages that is installed on the computer I am presently using, but could be in multiple others). Does this interval match what you are expecting?
library(TeachingDemos) hpd(qbeta, shape1=4, shape2=8)
[1] 0.09337233 0.58795256 -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of tinazilla Sent: Wednesday, June 15, 2011 6:42 PM To: r-help at r-project.org Subject: [R] Bayesian Credible Intervals for a Proportion I am trying to calculate Bayesian Credible Intervals for a proportion (disease prevalence values to be more specific) and am having trouble using R to do this. I am working with ncredint() function but have not had success with it. Please help! Example: Positive samples = 3 Total sampled = 10 Prevalence = 0.3 pvec <- seq(1,10,by=1) npost = dbinom(pvec,10,prob=0.3, log=FALSE) ncredint(pvec, npost, tol=0.01, verbose=FALSE) But I don't get the right Bayesian CI. What am I doing wrong? Thanks! Tina -- View this message in context: http://r.789695.n4.nabble.com/Bayesian-Credible-Intervals-for-a-Proportion-tp3600976p3600976.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help at 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.
Sorry, forgot to mention ncredint is from emdbook. Thanks, Tina -- View this message in context: http://r.789695.n4.nabble.com/Bayesian-Credible-Intervals-for-a-Proportion-tp3600976p3601584.html Sent from the R help mailing list archive at Nabble.com.