Bbinomial: Bayesian analysis of binomial data

View source: R/Bbinomial.R

Bayesian binomial analysisR Documentation

Bayesian analysis of binomial data

Description

Draws random values from the posterior for a binomial likelihood and beta prior. Bbinom is deprecated and will be removed in the next version; use Bbinomial instead.

Usage

Bbinom(...)
Bbinomial(y, n, priors=NULL, draws=100000, ...)

Arguments

y

the number of successes

n

the number of trials

priors

an optional list with elements specifying the priors for the mode and concentration of the beta prior distribution; see Details.

draws

the number of MCMC draws to be returned.

...

other arguments to pass to the function.

Details

The function generates a vector of random draws from the posterior distribution of the probability of success. It uses conjugacy to determine the parameters of the posterior beta distribution, and draws independent values from this.

A prior can be specified with the priors argument. A beta prior is used, specified by mode, mode, and concentration, conc.

When priors = NULL (the default), a uniform prior corresponding to beta(1, 1) is used.

Value

Returns an object of class mcmcOutput.

Author(s)

Mike Meredith.

Examples

# Generate a sample from a binomial distribution, maybe the number of sites
#   where a species was detected:
n <- 10  # number of trials (sites visited)
( y <- rbinom(1, n, 0.75) ) # number of successes (sites where species detected)
Bbinomial(y, n)  # with uniform prior
Bbinomial(y, n, priors=list(mode=0.4, conc=5))  # with informative prior

mikemeredith/wiqid documentation built on Nov. 17, 2022, 5:10 a.m.