ci.bayes.prop1: Bayesian credible interval for a single proportion

View source: R/statpsych3.R

ci.bayes.prop1R Documentation

Bayesian credible interval for a single proportion

Description

Computes a Bayesian credible interval for a single proportion using the mean and standard deviation of a prior Beta distribution along with sample information. The mean and standard deviation of the posterior Beta distribution are also reported. For a noninformative prior, set the prior mean to .5 and the prior standard deviation to 1/sqrt(12) (which corresponds to a Beta(1,1) distribution). The prior variance must be less than m(1 - m) where m is the prior mean.

Usage

ci.bayes.prop1(alpha, prior.mean, prior.sd, f, n)

Arguments

alpha

alpha level for 1-alpha credibility interval

prior.mean

mean of prior Beta distribution

prior.sd

standard deviation of prior Beta distribution

f

number of participants who have the attribute

n

sample size

Value

Returns a 1-row matrix. The columns are:

  • Posterior mean - posterior mean of Beta distributoin

  • Posterior SD - posterior standard deviation of Beta distributoin

  • LL - lower limit of the credible interval

  • UL - upper limit of the credible interval

References

\insertRef

Gelman2004statpsych

Examples

ci.bayes.prop1(.05, .4, .1, 12, 100)

# Should return:
#      Posterior mean Posterior SD       LL        UL
# [1,]           0.15   0.03273268  0.09218 0.2188484



statpsych documentation built on July 9, 2023, 6:50 p.m.