binobp {Bolstad}R Documentation

Binomial sampling with a beta prior

Description

Evaluates and plots the posterior density for \pi, the probability of a success in a Bernoulli trial, with binomial sampling and a continous beta(a,b) prior.

Usage

binobp(x, n, a = 1, b = 1, pi = seq(0, 1, by = 0.001), ...)

Arguments

x

the number of observed successes in the binomial experiment.

n

the number of trials in the binomial experiment.

a

parameter for the beta prior - must be greater than zero

b

parameter for the beta prior - must be greater than zero

pi

A range of values for the prior to be calculated over.

...

additional arguments that are passed to Bolstad.control

Value

An object of class 'Bolstad' is returned. This is a list with the following components:

prior

the prior density of \pi, i.e. the beta(a,b) density

likelihood

the likelihood of x given \pi and n, i.e. the binomial(n,\pi) density

posterior

the posterior density of \pi given x and n - i.e. the beta(a+x,b+n-x) density

pi

the values of \pi for which the posterior density was evaluated

mean

the posterior mean

var

the posterior variance

sd

the posterior std. deviation

quantiles

a set of quantiles from the posterior

cdf

a cumulative distribution function for the posterior

quantileFun

a quantile function for the posterior

See Also

binodp binogcp

Examples


## simplest call with 6 successes observed in 8 trials and a beta(1,1) uniform
## prior
binobp(6,8)

## 6 successes observed in 8 trials and a non-uniform beta(0.5,6) prior
binobp(6,8,0.5,6)

## 4 successes observed in 12 trials with a non uniform beta(3,3) prior
## plot the stored prior, likelihood and posterior
results = binobp(4, 12, 3, 3)
decomp(results)



[Package Bolstad version 0.2-41 Index]