binombeta: Binomial sampling distribution with a beta distribution of...

Description Usage Arguments Value Source References See Also Examples

Description

Define the posterior distribution function for π ( θ | r ), with a beta prior distribution π ( θ; α, β ) and a binomial sampling distribution p ( r | θ ).

Usage

1
binombeta(alpha = 1, beta = 1, n, r, theta = seq(0, 1, 0.001))

Arguments

alpha

the parameter for the beta distribution ( ≥ 0 ).

beta

the parameter for the beta distribution ( ≥ 0 ).

n

the number of trials in binomial distribution.

r

the number of successes in n trials.

theta

the range of the probability of success.

Value

An object of class "g12post" is returned.

prior

the prior distribution, i.e. the beta(α,β) distribution.

likelihood

the likelihood function of r given θ, i.e. the binomial(n,r) distribution.

posterior

the posterior distribution of θ given r, i.e. the beta(α+r, β+n-r) distribution.

theta

the range of the probability of success.

pri.alpha

the alpha parameter for the beta distribution of prior.

pri.beta

the beta parameter for the beta distribution of prior.

pos.alpha

the alpha parameter for the beta distribution of posterior.

pos.beta

the beta parameter for the beta distribution of posterior.

model

the prior and likelihood type to produce the posterior.

Source

For code binombeta, based on

1
2
Curren,J.(2017) R topics documentated:bingcp-Package
'Bolstad'. Pp15.

For the theory, based on

1
The STATG012 slides2 Example3.6 on Moodle at UCL.

STATG012 slides2

References

Bolstad, W.M. 2007. Introduction to Bayesian Statistics. (2nd ed.). Hoboken, New Jersey: John Wiley & Sons, Inc.

See Also

summary.g12post for summararies of prior and posterior distribution.

plot.g12post for plots of prior and posterior distribution.

Examples

1
2
3
4
5
6
7
8
9
## simplest one with 3 successes in 10 trials and a constant
## (uniform beta(1,1)) prior, then the posterior distribution
## has exactly the same shape as the likelihood function.
a <- binombeta(n = 6, r = 2)
summary(a)

## example 3.6 : 3 successes in 10 trials and a beta(4,6) prior.
ex <- binombeta(4, 6, 10, 3)
plot(ex, lty = 1:2, col = c(4,2))

yijin71/statg012 documentation built on May 23, 2019, 4:04 p.m.